@gravity-ui/aikit 3.6.0 → 3.6.1-beta.b13dac3fda8fb7076e9217f88ca8b7d1a94c3ce7.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 (151) hide show
  1. package/build/cjs/components/atoms/IntersectionContainer/IntersectionContainer.js +7 -1
  2. package/build/cjs/components/atoms/IntersectionContainer/IntersectionContainer.js.map +1 -1
  3. package/build/cjs/components/organisms/Header/Header.js +2 -1
  4. package/build/cjs/components/organisms/Header/Header.js.map +1 -1
  5. package/build/cjs/components/organisms/Header/i18n/en.json +1 -0
  6. package/build/cjs/components/organisms/Header/i18n/index.d.ts +4 -4
  7. package/build/cjs/components/organisms/Header/i18n/ru.json +1 -0
  8. package/build/cjs/components/organisms/Header/types.d.ts +4 -0
  9. package/build/cjs/components/organisms/Header/types.js +1 -0
  10. package/build/cjs/components/organisms/Header/types.js.map +1 -1
  11. package/build/cjs/components/organisms/Header/useHeader.d.ts +1 -0
  12. package/build/cjs/components/organisms/Header/useHeader.js +14 -2
  13. package/build/cjs/components/organisms/Header/useHeader.js.map +1 -1
  14. package/build/cjs/components/organisms/MessageList/MessageList.css +5 -0
  15. package/build/cjs/components/organisms/MessageList/MessageList.js +2 -2
  16. package/build/cjs/components/organisms/MessageList/MessageList.js.map +1 -1
  17. package/build/cjs/components/organisms/MessageList/usePopup.js +11 -1
  18. package/build/cjs/components/organisms/MessageList/usePopup.js.map +1 -1
  19. package/build/cjs/components/organisms/PromptInput/PromptInput.js +10 -5
  20. package/build/cjs/components/organisms/PromptInput/PromptInput.js.map +1 -1
  21. package/build/cjs/components/pages/ChatContainer/ChatContainer.css +13 -0
  22. package/build/cjs/components/pages/ChatContainer/ChatContainer.js +63 -7
  23. package/build/cjs/components/pages/ChatContainer/ChatContainer.js.map +1 -1
  24. package/build/cjs/components/pages/ChatContainer/ChatLayout.d.ts +14 -0
  25. package/build/cjs/components/pages/ChatContainer/ChatLayout.js +11 -0
  26. package/build/cjs/components/pages/ChatContainer/ChatLayout.js.map +1 -0
  27. package/build/cjs/components/pages/ChatContainer/index.d.ts +1 -0
  28. package/build/cjs/components/pages/ChatContainer/index.js.map +1 -1
  29. package/build/cjs/components/pages/ChatContainer/screenTypes.d.ts +49 -0
  30. package/build/cjs/components/pages/ChatContainer/screenTypes.js +3 -0
  31. package/build/cjs/components/pages/ChatContainer/screenTypes.js.map +1 -0
  32. package/build/cjs/components/pages/ChatContainer/types.d.ts +2 -1
  33. package/build/cjs/components/pages/ChatContainer/types.js.map +1 -1
  34. package/build/cjs/components/pages/ChatContainer/useChatContainer.d.ts +1 -1
  35. package/build/cjs/components/pages/ChatContainer/useChatContainer.js.map +1 -1
  36. package/build/cjs/components/pages/ChatContainer/useChatScreenNavigation.d.ts +14 -0
  37. package/build/cjs/components/pages/ChatContainer/useChatScreenNavigation.js +132 -0
  38. package/build/cjs/components/pages/ChatContainer/useChatScreenNavigation.js.map +1 -0
  39. package/build/cjs/components/templates/UserInstructionsScreen/UserInstructionsScreen.css +21 -0
  40. package/build/cjs/components/templates/UserInstructionsScreen/UserInstructionsScreen.d.ts +3 -0
  41. package/build/cjs/components/templates/UserInstructionsScreen/UserInstructionsScreen.js +88 -0
  42. package/build/cjs/components/templates/UserInstructionsScreen/UserInstructionsScreen.js.map +1 -0
  43. package/build/cjs/components/templates/UserInstructionsScreen/i18n/en.json +9 -0
  44. package/build/cjs/components/templates/UserInstructionsScreen/i18n/index.d.ts +13 -0
  45. package/build/cjs/components/templates/UserInstructionsScreen/i18n/index.js +10 -0
  46. package/build/cjs/components/templates/UserInstructionsScreen/i18n/index.js.map +1 -0
  47. package/build/cjs/components/templates/UserInstructionsScreen/i18n/ru.json +9 -0
  48. package/build/cjs/components/templates/UserInstructionsScreen/index.d.ts +2 -0
  49. package/build/cjs/components/templates/UserInstructionsScreen/index.js +6 -0
  50. package/build/cjs/components/templates/UserInstructionsScreen/index.js.map +1 -0
  51. package/build/cjs/components/templates/UserInstructionsScreen/types.d.ts +31 -0
  52. package/build/cjs/components/templates/UserInstructionsScreen/types.js +3 -0
  53. package/build/cjs/components/templates/UserInstructionsScreen/types.js.map +1 -0
  54. package/build/cjs/components/templates/index.d.ts +1 -0
  55. package/build/cjs/components/templates/index.js +1 -0
  56. package/build/cjs/components/templates/index.js.map +1 -1
  57. package/build/cjs/hooks/ChatViewActivity.d.ts +9 -0
  58. package/build/cjs/hooks/ChatViewActivity.js +9 -0
  59. package/build/cjs/hooks/ChatViewActivity.js.map +1 -0
  60. package/build/cjs/hooks/useChatScrollActivity.d.ts +3 -0
  61. package/build/cjs/hooks/useChatScrollActivity.js +84 -0
  62. package/build/cjs/hooks/useChatScrollActivity.js.map +1 -0
  63. package/build/cjs/hooks/useScrollPreservation.js +11 -4
  64. package/build/cjs/hooks/useScrollPreservation.js.map +1 -1
  65. package/build/cjs/hooks/useSmartScroll.js +13 -9
  66. package/build/cjs/hooks/useSmartScroll.js.map +1 -1
  67. package/build/cjs/hooks/useVirtualStickToBottom.js +28 -18
  68. package/build/cjs/hooks/useVirtualStickToBottom.js.map +1 -1
  69. package/build/cjs/package.json +1 -1
  70. package/build/docs/INDEX.md +2 -0
  71. package/build/docs/components/organisms/Header.md +4 -0
  72. package/build/docs/components/pages/ChatContainer.md +57 -0
  73. package/build/docs/components/templates/UserInstructionsScreen.md +104 -0
  74. package/build/docs/guides/CHAT_SCREEN_NAVIGATION.md +76 -0
  75. package/build/docs/guides/COMPONENTS.md +8 -7
  76. package/build/docs/guides/PROJECT_STRUCTURE.md +2 -1
  77. package/build/esm/components/atoms/IntersectionContainer/IntersectionContainer.js +7 -1
  78. package/build/esm/components/atoms/IntersectionContainer/IntersectionContainer.js.map +1 -1
  79. package/build/esm/components/organisms/Header/Header.js +3 -2
  80. package/build/esm/components/organisms/Header/Header.js.map +1 -1
  81. package/build/esm/components/organisms/Header/i18n/en.json +1 -0
  82. package/build/esm/components/organisms/Header/i18n/index.d.ts +4 -4
  83. package/build/esm/components/organisms/Header/i18n/ru.json +1 -0
  84. package/build/esm/components/organisms/Header/types.d.ts +4 -0
  85. package/build/esm/components/organisms/Header/types.js +1 -0
  86. package/build/esm/components/organisms/Header/types.js.map +1 -1
  87. package/build/esm/components/organisms/Header/useHeader.d.ts +1 -0
  88. package/build/esm/components/organisms/Header/useHeader.js +14 -2
  89. package/build/esm/components/organisms/Header/useHeader.js.map +1 -1
  90. package/build/esm/components/organisms/MessageList/MessageList.css +5 -0
  91. package/build/esm/components/organisms/MessageList/MessageList.js +2 -2
  92. package/build/esm/components/organisms/MessageList/MessageList.js.map +1 -1
  93. package/build/esm/components/organisms/MessageList/usePopup.js +12 -2
  94. package/build/esm/components/organisms/MessageList/usePopup.js.map +1 -1
  95. package/build/esm/components/organisms/PromptInput/PromptInput.js +10 -5
  96. package/build/esm/components/organisms/PromptInput/PromptInput.js.map +1 -1
  97. package/build/esm/components/pages/ChatContainer/ChatContainer.css +13 -0
  98. package/build/esm/components/pages/ChatContainer/ChatContainer.js +65 -9
  99. package/build/esm/components/pages/ChatContainer/ChatContainer.js.map +1 -1
  100. package/build/esm/components/pages/ChatContainer/ChatLayout.d.ts +14 -0
  101. package/build/esm/components/pages/ChatContainer/ChatLayout.js +8 -0
  102. package/build/esm/components/pages/ChatContainer/ChatLayout.js.map +1 -0
  103. package/build/esm/components/pages/ChatContainer/index.d.ts +1 -0
  104. package/build/esm/components/pages/ChatContainer/index.js.map +1 -1
  105. package/build/esm/components/pages/ChatContainer/screenTypes.d.ts +49 -0
  106. package/build/esm/components/pages/ChatContainer/screenTypes.js +2 -0
  107. package/build/esm/components/pages/ChatContainer/screenTypes.js.map +1 -0
  108. package/build/esm/components/pages/ChatContainer/types.d.ts +2 -1
  109. package/build/esm/components/pages/ChatContainer/types.js.map +1 -1
  110. package/build/esm/components/pages/ChatContainer/useChatContainer.d.ts +1 -1
  111. package/build/esm/components/pages/ChatContainer/useChatContainer.js.map +1 -1
  112. package/build/esm/components/pages/ChatContainer/useChatScreenNavigation.d.ts +14 -0
  113. package/build/esm/components/pages/ChatContainer/useChatScreenNavigation.js +129 -0
  114. package/build/esm/components/pages/ChatContainer/useChatScreenNavigation.js.map +1 -0
  115. package/build/esm/components/templates/UserInstructionsScreen/UserInstructionsScreen.css +21 -0
  116. package/build/esm/components/templates/UserInstructionsScreen/UserInstructionsScreen.d.ts +3 -0
  117. package/build/esm/components/templates/UserInstructionsScreen/UserInstructionsScreen.js +85 -0
  118. package/build/esm/components/templates/UserInstructionsScreen/UserInstructionsScreen.js.map +1 -0
  119. package/build/esm/components/templates/UserInstructionsScreen/i18n/en.json +9 -0
  120. package/build/esm/components/templates/UserInstructionsScreen/i18n/index.d.ts +13 -0
  121. package/build/esm/components/templates/UserInstructionsScreen/i18n/index.js +6 -0
  122. package/build/esm/components/templates/UserInstructionsScreen/i18n/index.js.map +1 -0
  123. package/build/esm/components/templates/UserInstructionsScreen/i18n/ru.json +9 -0
  124. package/build/esm/components/templates/UserInstructionsScreen/index.d.ts +2 -0
  125. package/build/esm/components/templates/UserInstructionsScreen/index.js +2 -0
  126. package/build/esm/components/templates/UserInstructionsScreen/index.js.map +1 -0
  127. package/build/esm/components/templates/UserInstructionsScreen/types.d.ts +31 -0
  128. package/build/esm/components/templates/UserInstructionsScreen/types.js +2 -0
  129. package/build/esm/components/templates/UserInstructionsScreen/types.js.map +1 -0
  130. package/build/esm/components/templates/index.d.ts +1 -0
  131. package/build/esm/components/templates/index.js +1 -0
  132. package/build/esm/components/templates/index.js.map +1 -1
  133. package/build/esm/hooks/ChatViewActivity.d.ts +9 -0
  134. package/build/esm/hooks/ChatViewActivity.js +5 -0
  135. package/build/esm/hooks/ChatViewActivity.js.map +1 -0
  136. package/build/esm/hooks/useChatScrollActivity.d.ts +3 -0
  137. package/build/esm/hooks/useChatScrollActivity.js +81 -0
  138. package/build/esm/hooks/useChatScrollActivity.js.map +1 -0
  139. package/build/esm/hooks/useScrollPreservation.js +11 -4
  140. package/build/esm/hooks/useScrollPreservation.js.map +1 -1
  141. package/build/esm/hooks/useSmartScroll.js +13 -9
  142. package/build/esm/hooks/useSmartScroll.js.map +1 -1
  143. package/build/esm/hooks/useVirtualStickToBottom.js +28 -18
  144. package/build/esm/hooks/useVirtualStickToBottom.js.map +1 -1
  145. package/build/esm/package.json +1 -1
  146. package/docs/CHAT_SCREEN_NAVIGATION.md +76 -0
  147. package/docs/COMPONENTS.md +8 -7
  148. package/docs/PROJECT_STRUCTURE.md +2 -1
  149. package/llms-full.txt +10 -8
  150. package/llms.txt +2 -0
  151. package/package.json +11 -1
@@ -5,12 +5,18 @@ const tslib_1 = require("tslib");
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = tslib_1.__importDefault(require("react"));
7
7
  const uikit_1 = require("@gravity-ui/uikit");
8
+ const ChatViewActivity_1 = require("../../../hooks/ChatViewActivity.js");
8
9
  const cn_1 = require("../../../utils/cn.js");
9
10
  require("./IntersectionContainer.css");
10
11
  const b = (0, cn_1.block)('intersection-container');
11
12
  const IntersectionContainer = ({ children, onIntersect, options, className, }) => {
13
+ const { active } = (0, ChatViewActivity_1.useChatViewActivity)();
12
14
  const [ref, setRef] = react_1.default.useState(null);
13
- (0, uikit_1.useIntersection)({ element: ref, onIntersect, options });
15
+ (0, uikit_1.useIntersection)({
16
+ element: active ? ref : null,
17
+ onIntersect: active ? onIntersect : undefined,
18
+ options,
19
+ });
14
20
  if (onIntersect) {
15
21
  return ((0, jsx_runtime_1.jsx)("div", { className: b('container', className), ref: setRef, children: children }));
16
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IntersectionContainer.js","sourceRoot":"../../../../../src","sources":["components/atoms/IntersectionContainer/IntersectionContainer.tsx"],"names":[],"mappings":";;;;;AAAA,0DAA0B;AAE1B,6CAAkD;AAElD,6CAAwC;AAExC,uCAAsC;AAEtC,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,wBAAwB,CAAC,CAAC;AASnC,MAAM,qBAAqB,GAAG,CAAC,EAClC,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,GACiB,EAAE,EAAE;IAC9B,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAE3D,IAAA,uBAAe,EAAC,EAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAC,CAAC,CAAC;IAEtD,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,CACH,gCAAK,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,YACjD,QAAQ,GACP,CACT,CAAC;IACN,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAnBW,QAAA,qBAAqB,yBAmBhC","sourcesContent":["import React from 'react';\n\nimport {useIntersection} from '@gravity-ui/uikit';\n\nimport {block} from '../../../utils/cn';\n\nimport './IntersectionContainer.scss';\n\nconst b = block('intersection-container');\n\ninterface IIntersectionContainerProps {\n children?: React.ReactNode;\n onIntersect?: () => void;\n options?: IntersectionObserverInit;\n className?: string;\n}\n\nexport const IntersectionContainer = ({\n children,\n onIntersect,\n options,\n className,\n}: IIntersectionContainerProps) => {\n const [ref, setRef] = React.useState<Element | null>(null);\n\n useIntersection({element: ref, onIntersect, options});\n\n if (onIntersect) {\n return (\n <div className={b('container', className)} ref={setRef}>\n {children}\n </div>\n );\n }\n\n return children;\n};\n"]}
1
+ {"version":3,"file":"IntersectionContainer.js","sourceRoot":"../../../../../src","sources":["components/atoms/IntersectionContainer/IntersectionContainer.tsx"],"names":[],"mappings":";;;;;AAAA,0DAA0B;AAE1B,6CAAkD;AAElD,yEAAoE;AACpE,6CAAwC;AAExC,uCAAsC;AAEtC,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,wBAAwB,CAAC,CAAC;AASnC,MAAM,qBAAqB,GAAG,CAAC,EAClC,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,GACiB,EAAE,EAAE;IAC9B,MAAM,EAAC,MAAM,EAAC,GAAG,IAAA,sCAAmB,GAAE,CAAC;IACvC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAE3D,IAAA,uBAAe,EAAC;QACZ,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;QAC5B,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;QAC7C,OAAO;KACV,CAAC,CAAC;IAEH,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,CACH,gCAAK,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,YACjD,QAAQ,GACP,CACT,CAAC;IACN,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAxBW,QAAA,qBAAqB,yBAwBhC","sourcesContent":["import React from 'react';\n\nimport {useIntersection} from '@gravity-ui/uikit';\n\nimport {useChatViewActivity} from '../../../hooks/ChatViewActivity';\nimport {block} from '../../../utils/cn';\n\nimport './IntersectionContainer.scss';\n\nconst b = block('intersection-container');\n\ninterface IIntersectionContainerProps {\n children?: React.ReactNode;\n onIntersect?: () => void;\n options?: IntersectionObserverInit;\n className?: string;\n}\n\nexport const IntersectionContainer = ({\n children,\n onIntersect,\n options,\n className,\n}: IIntersectionContainerProps) => {\n const {active} = useChatViewActivity();\n const [ref, setRef] = React.useState<Element | null>(null);\n\n useIntersection({\n element: active ? ref : null,\n onIntersect: active ? onIntersect : undefined,\n options,\n });\n\n if (onIntersect) {\n return (\n <div className={b('container', className)} ref={setRef}>\n {children}\n </div>\n );\n }\n\n return children;\n};\n"]}
@@ -18,6 +18,7 @@ require("./Header.css");
18
18
  const b = (0, cn_1.block)('header');
19
19
  // Icons for base actions
20
20
  const ACTION_ICONS = {
21
+ [types_1.HeaderAction.Back]: icons_1.ArrowLeft,
21
22
  [types_1.HeaderAction.NewChat]: icons_1.Plus,
22
23
  [types_1.HeaderAction.History]: icons_1.ClockArrowRotateLeft,
23
24
  [types_1.HeaderAction.Folding]: icons_1.ChevronsCollapseUpRight, // Default icon, will be switched based on state
@@ -90,7 +91,7 @@ function Header(props) {
90
91
  ]
91
92
  .filter(Boolean)
92
93
  .join('. ');
93
- return ((0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { ref: buttonRef, tooltipTitle: label, "aria-label": label, size: actionSize, view: "flat", onClick: action.onClick, className: b('action-button'), qa: (_c = actionQa === null || actionQa === void 0 ? void 0 : actionQa[action.id]) !== null && _c !== void 0 ? _c : `header-action-${action.id}`, children: (0, jsx_runtime_1.jsx)(uikit_1.Button.Icon, { children: (0, jsx_runtime_1.jsxs)("span", { className: b('action-icon'), children: [(0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: IconComponent, size: iconSize }), isHistory && historyActivity && ((0, jsx_runtime_1.jsxs)("span", { className: b('activity'), "aria-hidden": true, children: [historyActivity.isGenerating && ((0, jsx_runtime_1.jsx)(uikit_1.Spin, { size: "xs", className: b('activity-spinner') })), !historyActivity.isGenerating && historyActivity.hasUnread && ((0, jsx_runtime_1.jsx)("span", { className: b('unread-dot') }))] }))] }) }) }, action.id));
94
+ return ((0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { ref: buttonRef, tooltipTitle: label, "aria-label": label, size: actionSize, view: "flat", disabled: action.disabled, onClick: action.onClick, className: b('action-button'), qa: (_c = actionQa === null || actionQa === void 0 ? void 0 : actionQa[action.id]) !== null && _c !== void 0 ? _c : `header-action-${action.id}`, children: (0, jsx_runtime_1.jsx)(uikit_1.Button.Icon, { children: (0, jsx_runtime_1.jsxs)("span", { className: b('action-icon'), children: [(0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: IconComponent, size: iconSize }), isHistory && historyActivity && ((0, jsx_runtime_1.jsxs)("span", { className: b('activity'), "aria-hidden": true, children: [historyActivity.isGenerating && ((0, jsx_runtime_1.jsx)(uikit_1.Spin, { size: "xs", className: b('activity-spinner') })), !historyActivity.isGenerating && historyActivity.hasUnread && ((0, jsx_runtime_1.jsx)("span", { className: b('unread-dot') }))] }))] }) }) }, action.id));
94
95
  }, [actionIcons, actionQa, actionSize, actionTooltipTexts, historyActivity, iconSize, t]);
95
96
  // Render additional action
96
97
  const renderAdditionalAction = (0, react_1.useCallback)((action, index) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sourceRoot":"../../../../../src","sources":["components/organisms/Header/Header.tsx"],"names":[],"mappings":";;AAgEA,wBA4UC;;;AA5YD,uDAA4D;AAE5D,6CAQ2B;AAC3B,6CAA6F;AAI7F,iFAAuE;AACvE,+DAA0D;AAC1D,6CAAwC;AACxC,oEAAsD;AACtD,sEAAwD;AAExD,0CAA4B;AAC5B,sCAMiB;AACjB,8CAAkD;AAElD,wBAAuB;AAEvB,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,QAAQ,CAAC,CAAC;AAE1B,yBAAyB;AACzB,MAAM,YAAY,GAAuC;IACrD,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,YAAI;IAC5B,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,4BAAoB;IAC5C,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,+BAAuB,EAAE,gDAAgD;IACjG,CAAC,oBAAY,CAAC,KAAK,CAAC,EAAE,aAAK;CAC9B,CAAC;AAEF,2BAA2B;AAC3B,MAAM,aAAa,GAAG;IAClB,SAAS,EAAE,6BAAqB;IAChC,MAAM,EAAE,+BAAuB;CAClC,CAAC;AAIF,SAAS,qBAAqB,CAC1B,IAAoB,EACpB,UAAqC;;IAErC,uCAAW,IAAI,KAAE,EAAE,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,IAAI,CAAC,EAAE,CAAC,mCAAI,oBAAoB,IAAI,CAAC,EAAE,EAAE,IAAE;AACjF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,MAAM,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,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAE5C,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,aAAW,EAAE,aACxC,CAAC,QAAQ,IAAI,WAAW,CAAC,IAAI,CAC1B,iCAAK,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,aACpB,QAAQ,IAAI,WAAW,EACvB,WAAW,IACV,CACT,EAGA,SAAS,IAAI,CACV,iCAAK,SAAS,EAAE,kBAAkB,aAC7B,KAAK,IAAI,CACN,uBAAC,YAAI,IAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC,KAAK,EAAC,OAAO,EAAC,aAAa,EAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,YACnE,KAAK,GACH,CACV,EACA,OAAO,IAAI,gCAAK,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,YAAG,OAAO,GAAO,IACvD,CACT,EAEA,YAAY,IACX,CACT,CAAC;AACN,CAAC","sourcesContent":["import React, {useCallback, useMemo, useState} from 'react';\n\nimport {\n ChevronsCollapseUpRight,\n ChevronsExpandUpRight,\n ClockArrowRotateLeft,\n Ellipsis,\n Plus,\n Sparkles,\n Xmark,\n} from '@gravity-ui/icons';\nimport {Button, Icon, Menu, MenuItem, Sheet, Spin, Text, useUniqId} from '@gravity-ui/uikit';\n\nimport {Action} from 'src/types';\n\nimport {getControlIconSize} from '../../../hooks/useMobileControlSize';\nimport {isActionConfig} from '../../../utils/actionUtils';\nimport {block} from '../../../utils/cn';\nimport {ActionButton} from '../../atoms/ActionButton';\nimport {ButtonGroup} from '../../molecules/ButtonGroup';\n\nimport {i18n} from './i18n';\nimport {\n HeaderAction,\n HeaderActionGroup,\n type HeaderActionOrderItem,\n type HeaderMenuItem,\n type HeaderProps,\n} from './types';\nimport {ActionItem, useHeader} from './useHeader';\n\nimport './Header.scss';\n\nconst b = block('header');\n\n// Icons for base actions\nconst ACTION_ICONS: Record<HeaderAction, typeof Xmark> = {\n [HeaderAction.NewChat]: Plus,\n [HeaderAction.History]: ClockArrowRotateLeft,\n [HeaderAction.Folding]: ChevronsCollapseUpRight, // Default icon, will be switched based on state\n [HeaderAction.Close]: Xmark,\n};\n\n// Icons for folding states\nconst FOLDING_ICONS = {\n collapsed: ChevronsExpandUpRight,\n opened: ChevronsCollapseUpRight,\n};\n\ntype NormalizedMenuItem = HeaderMenuItem & {qa: string};\n\nfunction getNormalizedMenuItem(\n item: HeaderMenuItem,\n menuItemQa: HeaderProps['menuItemQa'],\n): NormalizedMenuItem {\n return {...item, qa: menuItemQa?.[item.id] ?? `header-menu-item-${item.id}`};\n}\n\n/**\n * Header component for displaying chat header with navigation and actions\n *\n * @param props - Component props\n * @returns Header component\n */\nexport function Header(props: HeaderProps) {\n const {t} = i18n.useTranslation();\n const {\n title,\n preview,\n icon,\n baseActions,\n additionalActions,\n actionsPlacement,\n actionsOrder,\n actionSize,\n isMobile,\n actionIcons,\n menuItems,\n menuButtonTooltip,\n menuButtonIcon,\n menuButtonQa,\n menuItemQa,\n showSheetTitle,\n titlePosition,\n withIcon,\n showTitle = true,\n className,\n historyButtonRef,\n qa,\n actionQa,\n actionTooltipTexts,\n } = useHeader(props);\n\n const historyActivity = props.historyActivity;\n const [isMenuSheetVisible, setIsMenuSheetVisible] = useState(false);\n const menuSheetId = useUniqId();\n\n const iconSize = getControlIconSize(actionSize);\n\n // Determine class for title positioning\n const titlePositionClass = b('title-container', {position: titlePosition});\n\n const iconElement = icon ? (\n <div className={b('icon')}>{icon}</div>\n ) : (\n <Icon data={Sparkles} size={16} />\n );\n\n // Render base action\n const renderBaseAction = useCallback(\n (action: ActionItem, ref?: React.RefObject<HTMLElement>) => {\n const actionId = action.id as HeaderAction;\n const IconComponent =\n actionIcons?.[actionId] ??\n (actionId === HeaderAction.Folding && action.foldingState\n ? FOLDING_ICONS[action.foldingState]\n : ACTION_ICONS[actionId]);\n\n if (!IconComponent) {\n return null;\n }\n\n // Get tooltip text\n let tooltipKey = `action-tooltip-${action.id}`;\n let tooltipOverride: string | undefined;\n if (action.id === HeaderAction.Folding && action.foldingState) {\n tooltipKey = `action-tooltip-folding-${action.foldingState}`;\n tooltipOverride = actionTooltipTexts?.[HeaderAction.Folding]?.[action.foldingState];\n } else {\n tooltipOverride =\n actionTooltipTexts?.[action.id as Exclude<HeaderAction, HeaderAction.Folding>];\n }\n\n // Determine ref for history button\n const buttonRef = action.id === HeaderAction.History ? ref : undefined;\n\n const isHistory = actionId === HeaderAction.History;\n let activityText: string | undefined;\n if (isHistory && historyActivity) {\n if (historyActivity.isGenerating) {\n activityText = t('activity-generating');\n if (historyActivity.hasUnread) {\n activityText = t('activity-generating-unread');\n }\n } else if (historyActivity.hasUnread) {\n activityText = t('activity-unread');\n }\n }\n const label = [\n tooltipOverride ?? t(tooltipKey as Parameters<typeof i18n>[0]),\n activityText,\n ]\n .filter(Boolean)\n .join('. ');\n\n return (\n <ActionButton\n key={action.id}\n ref={buttonRef as React.Ref<HTMLButtonElement>}\n tooltipTitle={label}\n aria-label={label}\n size={actionSize}\n view=\"flat\"\n onClick={action.onClick}\n className={b('action-button')}\n qa={actionQa?.[action.id as HeaderAction] ?? `header-action-${action.id}`}\n >\n <Button.Icon>\n <span className={b('action-icon')}>\n <Icon data={IconComponent} size={iconSize} />\n {isHistory && historyActivity && (\n <span className={b('activity')} aria-hidden>\n {historyActivity.isGenerating && (\n <Spin size=\"xs\" className={b('activity-spinner')} />\n )}\n {!historyActivity.isGenerating && historyActivity.hasUnread && (\n <span className={b('unread-dot')} />\n )}\n </span>\n )}\n </span>\n </Button.Icon>\n </ActionButton>\n );\n },\n [actionIcons, actionQa, actionSize, actionTooltipTexts, historyActivity, iconSize, t],\n );\n\n // Render additional action\n const renderAdditionalAction = useCallback(\n (action: Action, index: number) => {\n const id = `additional-${index}`;\n\n if (!isActionConfig(action)) {\n return <React.Fragment key={id}>{action}</React.Fragment>;\n }\n\n return (\n <ActionButton\n key={`${index}`}\n {...action}\n view={action.view || 'flat'}\n size={action.size ?? actionSize}\n >\n {action.icon || action.label}\n </ActionButton>\n );\n },\n [actionSize],\n );\n\n const normalizedMenuItems = useMemo(\n () => menuItems.map((item) => getNormalizedMenuItem(item, menuItemQa)),\n [menuItems, menuItemQa],\n );\n\n const headerMenu = useMemo(() => {\n if (normalizedMenuItems.length === 0) {\n return null;\n }\n\n const switcherContent = menuButtonIcon ?? <Icon data={Ellipsis} size={iconSize} />;\n const switcherTooltip = menuButtonTooltip ?? t('action-tooltip-menu');\n const switcherQa = menuButtonQa ?? 'header-menu-button';\n\n if (isMobile) {\n return (\n <React.Fragment>\n <ActionButton\n tooltipTitle={switcherTooltip}\n aria-label={switcherTooltip}\n size={actionSize}\n view=\"flat\"\n className={b('action-button')}\n qa={switcherQa}\n onClick={() => setIsMenuSheetVisible(true)}\n >\n {switcherContent}\n </ActionButton>\n <Sheet\n id={menuSheetId}\n title={t('menu-sheet-title')}\n open={isMenuSheetVisible}\n onOpenChange={setIsMenuSheetVisible}\n contentClassName={b('menu-sheet-content', {\n 'without-title': !showSheetTitle,\n })}\n qa=\"header-menu-sheet-container\"\n >\n <Menu\n inline\n size=\"xl\"\n qa=\"header-menu-sheet\"\n aria-label={t('menu-sheet-title')}\n >\n {normalizedMenuItems.map((item) => (\n <MenuItem\n key={item.id}\n className={b('menu-item')}\n disabled={item.disabled}\n qa={item.qa}\n onClick={() => {\n setIsMenuSheetVisible(false);\n item.onClick();\n }}\n >\n <span className={b('menu-item-content')}>\n {item.icon ? (\n <span className={b('menu-item-icon')}>{item.icon}</span>\n ) : null}\n {item.label}\n </span>\n </MenuItem>\n ))}\n </Menu>\n </Sheet>\n </React.Fragment>\n );\n }\n\n return (\n <Menu\n aria-label={t('menu-sheet-title')}\n trigger={\n <ActionButton\n tooltipTitle={switcherTooltip}\n aria-label={switcherTooltip}\n size={actionSize}\n view=\"flat\"\n className={b('action-button')}\n qa={switcherQa}\n >\n {switcherContent}\n </ActionButton>\n }\n >\n {normalizedMenuItems.map((item) => (\n <MenuItem\n key={item.id}\n disabled={item.disabled}\n qa={item.qa}\n onClick={item.onClick}\n icon={item.icon ? <span>{item.icon}</span> : undefined}\n >\n {item.label}\n </MenuItem>\n ))}\n </Menu>\n );\n }, [\n actionSize,\n iconSize,\n isMobile,\n isMenuSheetVisible,\n menuSheetId,\n normalizedMenuItems,\n menuButtonIcon,\n menuButtonQa,\n menuButtonTooltip,\n showSheetTitle,\n t,\n ]);\n\n const [leftBaseActions, rightBaseActions] = useMemo(() => {\n const left: ActionItem[] = [];\n const right: ActionItem[] = [];\n baseActions.forEach((action) => {\n (actionsPlacement.base?.[action.id as HeaderAction] === 'left' ? left : right).push(\n action,\n );\n });\n return [left, right];\n }, [actionsPlacement.base, baseActions]);\n\n const renderActions = (side: 'left' | 'right') => {\n const sideAdditionalActions =\n (actionsPlacement.additional ?? 'right') === side ? additionalActions : [];\n const sideMenu = (actionsPlacement.menu ?? 'right') === side ? headerMenu : null;\n const sideBaseActions = side === 'left' ? leftBaseActions : rightBaseActions;\n if (sideAdditionalActions.length === 0 && !sideMenu && sideBaseActions.length === 0) {\n return null;\n }\n const legacyOrder: HeaderActionOrderItem[] = [\n ...(sideAdditionalActions.length > 0 ? [HeaderActionGroup.Additional] : []),\n ...(sideMenu ? [HeaderActionGroup.Menu] : []),\n ...sideBaseActions.map((action) => action.id as HeaderAction),\n ];\n const requestedOrder = actionsOrder[side] ?? [];\n const available = new Set(legacyOrder);\n const ordered = [...new Set([...requestedOrder, ...legacyOrder])].filter((item) =>\n available.has(item),\n );\n\n const renderOrderedAction = (item: HeaderActionOrderItem) => {\n if (item === HeaderActionGroup.Additional) {\n return sideAdditionalActions.map((action, index) =>\n renderAdditionalAction(action, index),\n );\n }\n if (item === HeaderActionGroup.Menu) {\n return <React.Fragment key=\"menu\">{sideMenu}</React.Fragment>;\n }\n const action = sideBaseActions.find((candidate) => candidate.id === item);\n return action ? renderBaseAction(action, historyButtonRef) : null;\n };\n\n return <ButtonGroup>{ordered.map(renderOrderedAction)}</ButtonGroup>;\n };\n\n const leftActions = renderActions('left');\n const rightActions = renderActions('right');\n\n return (\n <div className={b('', className)} data-qa={qa}>\n {(withIcon || leftActions) && (\n <div className={b('left')}>\n {withIcon && iconElement}\n {leftActions}\n </div>\n )}\n\n {/* Center part: title with preview */}\n {showTitle && (\n <div className={titlePositionClass}>\n {title && (\n <Text title={title} as=\"div\" variant=\"subheader-2\" className={b('title')}>\n {title}\n </Text>\n )}\n {preview && <div className={b('preview')}>{preview}</div>}\n </div>\n )}\n\n {rightActions}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"Header.js","sourceRoot":"../../../../../src","sources":["components/organisms/Header/Header.tsx"],"names":[],"mappings":";;AAkEA,wBA6UC;;;AA/YD,uDAA4D;AAE5D,6CAS2B;AAC3B,6CAA6F;AAI7F,iFAAuE;AACvE,+DAA0D;AAC1D,6CAAwC;AACxC,oEAAsD;AACtD,sEAAwD;AAExD,0CAA4B;AAC5B,sCAMiB;AACjB,8CAAkD;AAElD,wBAAuB;AAEvB,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,QAAQ,CAAC,CAAC;AAE1B,yBAAyB;AACzB,MAAM,YAAY,GAAuC;IACrD,CAAC,oBAAY,CAAC,IAAI,CAAC,EAAE,iBAAS;IAC9B,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,YAAI;IAC5B,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,4BAAoB;IAC5C,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,+BAAuB,EAAE,gDAAgD;IACjG,CAAC,oBAAY,CAAC,KAAK,CAAC,EAAE,aAAK;CAC9B,CAAC;AAEF,2BAA2B;AAC3B,MAAM,aAAa,GAAG;IAClB,SAAS,EAAE,6BAAqB;IAChC,MAAM,EAAE,+BAAuB;CAClC,CAAC;AAIF,SAAS,qBAAqB,CAC1B,IAAoB,EACpB,UAAqC;;IAErC,uCAAW,IAAI,KAAE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EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtE,CAAC,CAAC;QAEF,OAAO,uBAAC,yBAAW,cAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAe,CAAC;IACzE,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAE5C,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,aAAW,EAAE,aACxC,CAAC,QAAQ,IAAI,WAAW,CAAC,IAAI,CAC1B,iCAAK,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,aACpB,QAAQ,IAAI,WAAW,EACvB,WAAW,IACV,CACT,EAGA,SAAS,IAAI,CACV,iCAAK,SAAS,EAAE,kBAAkB,aAC7B,KAAK,IAAI,CACN,uBAAC,YAAI,IAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC,KAAK,EAAC,OAAO,EAAC,aAAa,EAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,YACnE,KAAK,GACH,CACV,EACA,OAAO,IAAI,gCAAK,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,YAAG,OAAO,GAAO,IACvD,CACT,EAEA,YAAY,IACX,CACT,CAAC;AACN,CAAC","sourcesContent":["import React, {useCallback, useMemo, useState} from 'react';\n\nimport {\n ArrowLeft,\n ChevronsCollapseUpRight,\n ChevronsExpandUpRight,\n ClockArrowRotateLeft,\n Ellipsis,\n Plus,\n Sparkles,\n Xmark,\n} from '@gravity-ui/icons';\nimport {Button, Icon, Menu, MenuItem, Sheet, Spin, Text, useUniqId} from '@gravity-ui/uikit';\n\nimport {Action} from 'src/types';\n\nimport {getControlIconSize} from '../../../hooks/useMobileControlSize';\nimport {isActionConfig} from '../../../utils/actionUtils';\nimport {block} from '../../../utils/cn';\nimport {ActionButton} from '../../atoms/ActionButton';\nimport {ButtonGroup} from '../../molecules/ButtonGroup';\n\nimport {i18n} from './i18n';\nimport {\n HeaderAction,\n HeaderActionGroup,\n type HeaderActionOrderItem,\n type HeaderMenuItem,\n type HeaderProps,\n} from './types';\nimport {ActionItem, useHeader} from './useHeader';\n\nimport './Header.scss';\n\nconst b = block('header');\n\n// Icons for base actions\nconst ACTION_ICONS: Record<HeaderAction, typeof Xmark> = {\n [HeaderAction.Back]: ArrowLeft,\n [HeaderAction.NewChat]: Plus,\n [HeaderAction.History]: ClockArrowRotateLeft,\n [HeaderAction.Folding]: ChevronsCollapseUpRight, // Default icon, will be switched based on state\n [HeaderAction.Close]: Xmark,\n};\n\n// Icons for folding states\nconst FOLDING_ICONS = {\n collapsed: ChevronsExpandUpRight,\n opened: ChevronsCollapseUpRight,\n};\n\ntype NormalizedMenuItem = HeaderMenuItem & {qa: string};\n\nfunction getNormalizedMenuItem(\n item: HeaderMenuItem,\n menuItemQa: HeaderProps['menuItemQa'],\n): NormalizedMenuItem {\n return {...item, qa: menuItemQa?.[item.id] ?? `header-menu-item-${item.id}`};\n}\n\n/**\n * Header component for displaying chat header with navigation and actions\n *\n * @param props - Component props\n * @returns Header component\n */\nexport function Header(props: HeaderProps) {\n const {t} = i18n.useTranslation();\n const {\n title,\n preview,\n icon,\n baseActions,\n additionalActions,\n actionsPlacement,\n actionsOrder,\n actionSize,\n isMobile,\n actionIcons,\n menuItems,\n menuButtonTooltip,\n menuButtonIcon,\n menuButtonQa,\n menuItemQa,\n showSheetTitle,\n titlePosition,\n withIcon,\n showTitle = true,\n className,\n historyButtonRef,\n qa,\n actionQa,\n actionTooltipTexts,\n } = useHeader(props);\n\n const historyActivity = props.historyActivity;\n const [isMenuSheetVisible, setIsMenuSheetVisible] = useState(false);\n const menuSheetId = useUniqId();\n\n const iconSize = getControlIconSize(actionSize);\n\n // Determine class for title positioning\n const titlePositionClass = b('title-container', {position: titlePosition});\n\n const iconElement = icon ? (\n <div className={b('icon')}>{icon}</div>\n ) : (\n <Icon data={Sparkles} size={16} />\n );\n\n // Render base action\n const renderBaseAction = useCallback(\n (action: ActionItem, ref?: React.RefObject<HTMLElement>) => {\n const actionId = action.id as HeaderAction;\n const IconComponent =\n actionIcons?.[actionId] ??\n (actionId === HeaderAction.Folding && action.foldingState\n ? FOLDING_ICONS[action.foldingState]\n : ACTION_ICONS[actionId]);\n\n if (!IconComponent) {\n return null;\n }\n\n // Get tooltip text\n let tooltipKey = `action-tooltip-${action.id}`;\n let tooltipOverride: string | undefined;\n if (action.id === HeaderAction.Folding && action.foldingState) {\n tooltipKey = `action-tooltip-folding-${action.foldingState}`;\n tooltipOverride = actionTooltipTexts?.[HeaderAction.Folding]?.[action.foldingState];\n } else {\n tooltipOverride =\n actionTooltipTexts?.[action.id as Exclude<HeaderAction, HeaderAction.Folding>];\n }\n\n // Determine ref for history button\n const buttonRef = action.id === HeaderAction.History ? ref : undefined;\n\n const isHistory = actionId === HeaderAction.History;\n let activityText: string | undefined;\n if (isHistory && historyActivity) {\n if (historyActivity.isGenerating) {\n activityText = t('activity-generating');\n if (historyActivity.hasUnread) {\n activityText = t('activity-generating-unread');\n }\n } else if (historyActivity.hasUnread) {\n activityText = t('activity-unread');\n }\n }\n const label = [\n tooltipOverride ?? t(tooltipKey as Parameters<typeof i18n>[0]),\n activityText,\n ]\n .filter(Boolean)\n .join('. ');\n\n return (\n <ActionButton\n key={action.id}\n ref={buttonRef as React.Ref<HTMLButtonElement>}\n tooltipTitle={label}\n aria-label={label}\n size={actionSize}\n view=\"flat\"\n disabled={action.disabled}\n onClick={action.onClick}\n className={b('action-button')}\n qa={actionQa?.[action.id as HeaderAction] ?? `header-action-${action.id}`}\n >\n <Button.Icon>\n <span className={b('action-icon')}>\n <Icon data={IconComponent} size={iconSize} />\n {isHistory && historyActivity && (\n <span className={b('activity')} aria-hidden>\n {historyActivity.isGenerating && (\n <Spin size=\"xs\" className={b('activity-spinner')} />\n )}\n {!historyActivity.isGenerating && historyActivity.hasUnread && (\n <span className={b('unread-dot')} />\n )}\n </span>\n )}\n </span>\n </Button.Icon>\n </ActionButton>\n );\n },\n [actionIcons, actionQa, actionSize, actionTooltipTexts, historyActivity, iconSize, t],\n );\n\n // Render additional action\n const renderAdditionalAction = useCallback(\n (action: Action, index: number) => {\n const id = `additional-${index}`;\n\n if (!isActionConfig(action)) {\n return <React.Fragment key={id}>{action}</React.Fragment>;\n }\n\n return (\n <ActionButton\n key={`${index}`}\n {...action}\n view={action.view || 'flat'}\n size={action.size ?? actionSize}\n >\n {action.icon || action.label}\n </ActionButton>\n );\n },\n [actionSize],\n );\n\n const normalizedMenuItems = useMemo(\n () => menuItems.map((item) => getNormalizedMenuItem(item, menuItemQa)),\n [menuItems, menuItemQa],\n );\n\n const headerMenu = useMemo(() => {\n if (normalizedMenuItems.length === 0) {\n return null;\n }\n\n const switcherContent = menuButtonIcon ?? <Icon data={Ellipsis} size={iconSize} />;\n const switcherTooltip = menuButtonTooltip ?? t('action-tooltip-menu');\n const switcherQa = menuButtonQa ?? 'header-menu-button';\n\n if (isMobile) {\n return (\n <React.Fragment>\n <ActionButton\n tooltipTitle={switcherTooltip}\n aria-label={switcherTooltip}\n size={actionSize}\n view=\"flat\"\n className={b('action-button')}\n qa={switcherQa}\n onClick={() => setIsMenuSheetVisible(true)}\n >\n {switcherContent}\n </ActionButton>\n <Sheet\n id={menuSheetId}\n title={t('menu-sheet-title')}\n open={isMenuSheetVisible}\n onOpenChange={setIsMenuSheetVisible}\n contentClassName={b('menu-sheet-content', {\n 'without-title': !showSheetTitle,\n })}\n qa=\"header-menu-sheet-container\"\n >\n <Menu\n inline\n size=\"xl\"\n qa=\"header-menu-sheet\"\n aria-label={t('menu-sheet-title')}\n >\n {normalizedMenuItems.map((item) => (\n <MenuItem\n key={item.id}\n className={b('menu-item')}\n disabled={item.disabled}\n qa={item.qa}\n onClick={() => {\n setIsMenuSheetVisible(false);\n item.onClick();\n }}\n >\n <span className={b('menu-item-content')}>\n {item.icon ? (\n <span className={b('menu-item-icon')}>{item.icon}</span>\n ) : null}\n {item.label}\n </span>\n </MenuItem>\n ))}\n </Menu>\n </Sheet>\n </React.Fragment>\n );\n }\n\n return (\n <Menu\n aria-label={t('menu-sheet-title')}\n trigger={\n <ActionButton\n tooltipTitle={switcherTooltip}\n aria-label={switcherTooltip}\n size={actionSize}\n view=\"flat\"\n className={b('action-button')}\n qa={switcherQa}\n >\n {switcherContent}\n </ActionButton>\n }\n >\n {normalizedMenuItems.map((item) => (\n <MenuItem\n key={item.id}\n disabled={item.disabled}\n qa={item.qa}\n onClick={item.onClick}\n icon={item.icon ? <span>{item.icon}</span> : undefined}\n >\n {item.label}\n </MenuItem>\n ))}\n </Menu>\n );\n }, [\n actionSize,\n iconSize,\n isMobile,\n isMenuSheetVisible,\n menuSheetId,\n normalizedMenuItems,\n menuButtonIcon,\n menuButtonQa,\n menuButtonTooltip,\n showSheetTitle,\n t,\n ]);\n\n const [leftBaseActions, rightBaseActions] = useMemo(() => {\n const left: ActionItem[] = [];\n const right: ActionItem[] = [];\n baseActions.forEach((action) => {\n (actionsPlacement.base?.[action.id as HeaderAction] === 'left' ? left : right).push(\n action,\n );\n });\n return [left, right];\n }, [actionsPlacement.base, baseActions]);\n\n const renderActions = (side: 'left' | 'right') => {\n const sideAdditionalActions =\n (actionsPlacement.additional ?? 'right') === side ? additionalActions : [];\n const sideMenu = (actionsPlacement.menu ?? 'right') === side ? headerMenu : null;\n const sideBaseActions = side === 'left' ? leftBaseActions : rightBaseActions;\n if (sideAdditionalActions.length === 0 && !sideMenu && sideBaseActions.length === 0) {\n return null;\n }\n const legacyOrder: HeaderActionOrderItem[] = [\n ...(sideAdditionalActions.length > 0 ? [HeaderActionGroup.Additional] : []),\n ...(sideMenu ? [HeaderActionGroup.Menu] : []),\n ...sideBaseActions.map((action) => action.id as HeaderAction),\n ];\n const requestedOrder = actionsOrder[side] ?? [];\n const available = new Set(legacyOrder);\n const ordered = [...new Set([...requestedOrder, ...legacyOrder])].filter((item) =>\n available.has(item),\n );\n\n const renderOrderedAction = (item: HeaderActionOrderItem) => {\n if (item === HeaderActionGroup.Additional) {\n return sideAdditionalActions.map((action, index) =>\n renderAdditionalAction(action, index),\n );\n }\n if (item === HeaderActionGroup.Menu) {\n return <React.Fragment key=\"menu\">{sideMenu}</React.Fragment>;\n }\n const action = sideBaseActions.find((candidate) => candidate.id === item);\n return action ? renderBaseAction(action, historyButtonRef) : null;\n };\n\n return <ButtonGroup>{ordered.map(renderOrderedAction)}</ButtonGroup>;\n };\n\n const leftActions = renderActions('left');\n const rightActions = renderActions('right');\n\n return (\n <div className={b('', className)} data-qa={qa}>\n {(withIcon || leftActions) && (\n <div className={b('left')}>\n {withIcon && iconElement}\n {leftActions}\n </div>\n )}\n\n {/* Center part: title with preview */}\n {showTitle && (\n <div className={titlePositionClass}>\n {title && (\n <Text title={title} as=\"div\" variant=\"subheader-2\" className={b('title')}>\n {title}\n </Text>\n )}\n {preview && <div className={b('preview')}>{preview}</div>}\n </div>\n )}\n\n {rightActions}\n </div>\n );\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  {
2
+ "action-tooltip-back": "Back",
2
3
  "action-tooltip-newChat": "New chat",
3
4
  "action-tooltip-history": "History",
4
5
  "action-tooltip-folding-collapsed": "Expand",
@@ -1,13 +1,13 @@
1
- export declare const i18n: ((key: "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", params?: import("@gravity-ui/i18n").Params) => string) & {
1
+ export declare const i18n: ((key: "action-tooltip-back" | "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", params?: import("@gravity-ui/i18n").Params) => string) & {
2
2
  Translation: import("react").ComponentType<{
3
3
  children: (props: {
4
- t: (key: "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", params?: import("@gravity-ui/i18n").Params) => string;
4
+ t: (key: "action-tooltip-back" | "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", params?: import("@gravity-ui/i18n").Params) => string;
5
5
  }) => React.ReactNode;
6
6
  }>;
7
7
  useTranslation: () => {
8
- t: (key: "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", params?: import("@gravity-ui/i18n").Params) => string;
8
+ t: (key: "action-tooltip-back" | "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", params?: import("@gravity-ui/i18n").Params) => string;
9
9
  };
10
10
  keysetData: {
11
- "g-aikit-Header": Record<"action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", import("@gravity-ui/i18n").KeyData>;
11
+ "g-aikit-Header": Record<"action-tooltip-back" | "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close" | "action-tooltip-menu" | "menu-sheet-title" | "activity-generating" | "activity-unread" | "activity-generating-unread", import("@gravity-ui/i18n").KeyData>;
12
12
  };
13
13
  };
@@ -1,4 +1,5 @@
1
1
  {
2
+ "action-tooltip-back": "Назад",
2
3
  "action-tooltip-newChat": "Новый чат",
3
4
  "action-tooltip-history": "История",
4
5
  "action-tooltip-folding-collapsed": "Развернуть",
@@ -10,6 +10,7 @@ export type HeaderMenuItem = {
10
10
  icon?: React.ReactNode;
11
11
  };
12
12
  export declare enum HeaderAction {
13
+ Back = "back",
13
14
  NewChat = "newChat",
14
15
  History = "history",
15
16
  Folding = "folding",
@@ -40,6 +41,9 @@ export type HeaderProps = {
40
41
  title?: string;
41
42
  preview?: React.ReactNode;
42
43
  baseActions?: HeaderAction[];
44
+ handleBack?: () => void;
45
+ /** Disable built-in actions while a navigation check is pending. */
46
+ actionsDisabled?: boolean;
43
47
  handleNewChat?: () => void;
44
48
  handleHistoryToggle?: () => void;
45
49
  /** Shared activity summary; the history button remains available during generation. */
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HeaderActionGroup = exports.HeaderAction = void 0;
4
4
  var HeaderAction;
5
5
  (function (HeaderAction) {
6
+ HeaderAction["Back"] = "back";
6
7
  HeaderAction["NewChat"] = "newChat";
7
8
  HeaderAction["History"] = "history";
8
9
  HeaderAction["Folding"] = "folding";
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../../../../../src","sources":["components/organisms/Header/types.ts"],"names":[],"mappings":";;;AAcA,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;AACnB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED,mFAAmF;AACnF,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IACzB,kCAAa,CAAA;IACb,8CAAyB,CAAA;AAC7B,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B","sourcesContent":["import type {ButtonButtonProps, IconData} from '@gravity-ui/uikit';\n\nimport type {Action} from '../../../types/common';\nimport type {ChatActivitySnapshot} from '../../../utils/chatActivity';\n\nexport type HeaderMenuItem = {\n id: string;\n label: string;\n onClick: () => void;\n disabled?: boolean;\n /** Optional leading icon (rendered only when provided) */\n icon?: React.ReactNode;\n};\n\nexport enum HeaderAction {\n NewChat = 'newChat',\n History = 'history',\n Folding = 'folding',\n Close = 'close',\n}\n\n/** Composite and service action groups that can participate in header ordering. */\nexport enum HeaderActionGroup {\n Menu = 'menu',\n Additional = 'additional',\n}\n\nexport type HeaderActionSide = 'left' | 'right';\n\nexport type HeaderActionsPlacement = {\n /** Side for individual built-in actions. Unspecified actions stay on the right. */\n base?: Partial<Record<HeaderAction, HeaderActionSide>>;\n /** Side for the menu button. */\n menu?: HeaderActionSide;\n /** Side for the whole additional actions group. */\n additional?: HeaderActionSide;\n};\n\nexport type HeaderActionOrderItem = HeaderAction | HeaderActionGroup;\n\nexport type HeaderActionsOrder = Partial<\n Record<HeaderActionSide, readonly HeaderActionOrderItem[]>\n>;\n\nexport type HeaderActionTooltipTexts = Partial<\n Record<Exclude<HeaderAction, HeaderAction.Folding>, string>\n> & {\n /** Tooltip texts for {@link HeaderAction.Folding}. */\n [HeaderAction.Folding]?: Partial<Record<'collapsed' | 'opened', string>>;\n};\n\nexport type HeaderProps = {\n // Content\n icon?: React.ReactNode;\n title?: string;\n preview?: React.ReactNode;\n\n // Actions\n baseActions?: HeaderAction[];\n handleNewChat?: () => void;\n handleHistoryToggle?: () => void;\n /** Shared activity summary; the history button remains available during generation. */\n historyActivity?: Pick<ChatActivitySnapshot, 'isGenerating' | 'hasUnread'>;\n handleFolding?: (value: 'collapsed' | 'opened') => void;\n handleClose?: () => void;\n additionalActions?: Action[];\n actionsPlacement?: HeaderActionsPlacement;\n /** Order of action groups on each side. Unlisted available actions keep their legacy order. */\n actionsOrder?: HeaderActionsOrder;\n /** Default size for built-in, menu, and configured additional action buttons. */\n actionSize?: ButtonButtonProps['size'];\n /** Custom icons for built-in actions. Unspecified actions keep their default icons. */\n actionIcons?: Partial<Record<HeaderAction, IconData>>;\n\n /**\n * Menu items for the \"...\" dropdown. Labels and handlers are provided by the consumer.\n * The menu button is rendered only when the array is non-empty.\n */\n menuItems?: HeaderMenuItem[];\n /** Tooltip for the menu button (default: built-in i18n) */\n menuButtonTooltip?: string;\n /** Custom menu button icon (default: horizontal Ellipsis) */\n menuButtonIcon?: React.ReactNode;\n /** data-qa for the menu button (default: `header-menu-button`) */\n menuButtonQa?: string;\n /** data-qa overrides per menu item id (default: `header-menu-item-${id}`) */\n menuItemQa?: Partial<Record<string, string>>;\n /** Show the mobile menu sheet title (default: `true`); it stays in `aria-label` either way */\n showSheetTitle?: boolean;\n\n /**\n * Notification callback fired by ChatContainer when the history popup is toggled\n * via the Header action button. Receives the next open state (the value the chat\n * will be in after the toggle).\n */\n onHistoryToggle?: (open: boolean) => void;\n\n // Refs\n historyButtonRef?: React.RefObject<HTMLElement>;\n\n // Folding state\n foldingState?: 'collapsed' | 'opened';\n\n // Display settings\n titlePosition?: 'left' | 'center'; // default: left\n withIcon?: boolean; // default: true\n showTitle?: boolean; // default: true - controls visibility of title and preview\n\n className?: string;\n\n /** QA/test identifier on header root */\n qa?: string;\n /** Per base action `data-qa` (defaults to `header-action-${id}`) */\n actionQa?: Partial<Record<HeaderAction, string>>;\n /**\n * Override tooltip texts per base action. When a value is undefined, the built-in\n * localized string is used (e.g. `i18n('action-tooltip-newChat')`).\n */\n actionTooltipTexts?: HeaderActionTooltipTexts;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"../../../../../src","sources":["components/organisms/Header/types.ts"],"names":[],"mappings":";;;AAcA,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;AACnB,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAED,mFAAmF;AACnF,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IACzB,kCAAa,CAAA;IACb,8CAAyB,CAAA;AAC7B,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B","sourcesContent":["import type {ButtonButtonProps, IconData} from '@gravity-ui/uikit';\n\nimport type {Action} from '../../../types/common';\nimport type {ChatActivitySnapshot} from '../../../utils/chatActivity';\n\nexport type HeaderMenuItem = {\n id: string;\n label: string;\n onClick: () => void;\n disabled?: boolean;\n /** Optional leading icon (rendered only when provided) */\n icon?: React.ReactNode;\n};\n\nexport enum HeaderAction {\n Back = 'back',\n NewChat = 'newChat',\n History = 'history',\n Folding = 'folding',\n Close = 'close',\n}\n\n/** Composite and service action groups that can participate in header ordering. */\nexport enum HeaderActionGroup {\n Menu = 'menu',\n Additional = 'additional',\n}\n\nexport type HeaderActionSide = 'left' | 'right';\n\nexport type HeaderActionsPlacement = {\n /** Side for individual built-in actions. Unspecified actions stay on the right. */\n base?: Partial<Record<HeaderAction, HeaderActionSide>>;\n /** Side for the menu button. */\n menu?: HeaderActionSide;\n /** Side for the whole additional actions group. */\n additional?: HeaderActionSide;\n};\n\nexport type HeaderActionOrderItem = HeaderAction | HeaderActionGroup;\n\nexport type HeaderActionsOrder = Partial<\n Record<HeaderActionSide, readonly HeaderActionOrderItem[]>\n>;\n\nexport type HeaderActionTooltipTexts = Partial<\n Record<Exclude<HeaderAction, HeaderAction.Folding>, string>\n> & {\n /** Tooltip texts for {@link HeaderAction.Folding}. */\n [HeaderAction.Folding]?: Partial<Record<'collapsed' | 'opened', string>>;\n};\n\nexport type HeaderProps = {\n // Content\n icon?: React.ReactNode;\n title?: string;\n preview?: React.ReactNode;\n\n // Actions\n baseActions?: HeaderAction[];\n handleBack?: () => void;\n /** Disable built-in actions while a navigation check is pending. */\n actionsDisabled?: boolean;\n handleNewChat?: () => void;\n handleHistoryToggle?: () => void;\n /** Shared activity summary; the history button remains available during generation. */\n historyActivity?: Pick<ChatActivitySnapshot, 'isGenerating' | 'hasUnread'>;\n handleFolding?: (value: 'collapsed' | 'opened') => void;\n handleClose?: () => void;\n additionalActions?: Action[];\n actionsPlacement?: HeaderActionsPlacement;\n /** Order of action groups on each side. Unlisted available actions keep their legacy order. */\n actionsOrder?: HeaderActionsOrder;\n /** Default size for built-in, menu, and configured additional action buttons. */\n actionSize?: ButtonButtonProps['size'];\n /** Custom icons for built-in actions. Unspecified actions keep their default icons. */\n actionIcons?: Partial<Record<HeaderAction, IconData>>;\n\n /**\n * Menu items for the \"...\" dropdown. Labels and handlers are provided by the consumer.\n * The menu button is rendered only when the array is non-empty.\n */\n menuItems?: HeaderMenuItem[];\n /** Tooltip for the menu button (default: built-in i18n) */\n menuButtonTooltip?: string;\n /** Custom menu button icon (default: horizontal Ellipsis) */\n menuButtonIcon?: React.ReactNode;\n /** data-qa for the menu button (default: `header-menu-button`) */\n menuButtonQa?: string;\n /** data-qa overrides per menu item id (default: `header-menu-item-${id}`) */\n menuItemQa?: Partial<Record<string, string>>;\n /** Show the mobile menu sheet title (default: `true`); it stays in `aria-label` either way */\n showSheetTitle?: boolean;\n\n /**\n * Notification callback fired by ChatContainer when the history popup is toggled\n * via the Header action button. Receives the next open state (the value the chat\n * will be in after the toggle).\n */\n onHistoryToggle?: (open: boolean) => void;\n\n // Refs\n historyButtonRef?: React.RefObject<HTMLElement>;\n\n // Folding state\n foldingState?: 'collapsed' | 'opened';\n\n // Display settings\n titlePosition?: 'left' | 'center'; // default: left\n withIcon?: boolean; // default: true\n showTitle?: boolean; // default: true - controls visibility of title and preview\n\n className?: string;\n\n /** QA/test identifier on header root */\n qa?: string;\n /** Per base action `data-qa` (defaults to `header-action-${id}`) */\n actionQa?: Partial<Record<HeaderAction, string>>;\n /**\n * Override tooltip texts per base action. When a value is undefined, the built-in\n * localized string is used (e.g. `i18n('action-tooltip-newChat')`).\n */\n actionTooltipTexts?: HeaderActionTooltipTexts;\n};\n"]}
@@ -4,6 +4,7 @@ import { type HeaderMenuItem, type HeaderProps } from "./types.js";
4
4
  export type ActionItem = {
5
5
  id: string;
6
6
  type: 'base' | 'additional';
7
+ disabled?: boolean;
7
8
  onClick?: () => void;
8
9
  foldingState?: 'collapsed' | 'opened';
9
10
  };
@@ -5,7 +5,7 @@ const react_1 = require("react");
5
5
  const uikit_1 = require("@gravity-ui/uikit");
6
6
  const types_1 = require("./types.js");
7
7
  function useHeader(props) {
8
- const { icon, title, preview, baseActions = [], handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState = 'opened', additionalActions = [], actionsPlacement = {}, actionsOrder = {}, actionSize: actionSizeProp, actionIcons, menuItems = [], menuButtonTooltip, menuButtonIcon, menuButtonQa, menuItemQa, showSheetTitle = true, titlePosition = 'left', withIcon = true, showTitle = true, className, historyButtonRef, qa, actionQa, actionTooltipTexts, } = props;
8
+ const { icon, title, preview, baseActions = [], actionsDisabled, handleBack, handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState = 'opened', additionalActions = [], actionsPlacement = {}, actionsOrder = {}, actionSize: actionSizeProp, actionIcons, menuItems = [], menuButtonTooltip, menuButtonIcon, menuButtonQa, menuItemQa, showSheetTitle = true, titlePosition = 'left', withIcon = true, showTitle = true, className, historyButtonRef, qa, actionQa, actionTooltipTexts, } = props;
9
9
  const isMobile = (0, uikit_1.useMobile)();
10
10
  const actionSize = actionSizeProp !== null && actionSizeProp !== void 0 ? actionSizeProp : (isMobile ? 'xl' : 'm');
11
11
  // Build base actions
@@ -17,6 +17,7 @@ function useHeader(props) {
17
17
  actions.push({
18
18
  id: action,
19
19
  type: 'base',
20
+ disabled: actionsDisabled,
20
21
  onClick: () => {
21
22
  const newState = foldingState === 'opened' ? 'collapsed' : 'opened';
22
23
  handleFolding(newState);
@@ -27,6 +28,7 @@ function useHeader(props) {
27
28
  return;
28
29
  }
29
30
  const actionMap = {
31
+ [types_1.HeaderAction.Back]: handleBack,
30
32
  [types_1.HeaderAction.NewChat]: handleNewChat,
31
33
  [types_1.HeaderAction.History]: handleHistoryToggle,
32
34
  [types_1.HeaderAction.Close]: handleClose,
@@ -36,12 +38,22 @@ function useHeader(props) {
36
38
  actions.push({
37
39
  id: action,
38
40
  type: 'base',
41
+ disabled: actionsDisabled,
39
42
  onClick: handler,
40
43
  });
41
44
  }
42
45
  });
43
46
  return actions;
44
- }, [baseActions, handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState]);
47
+ }, [
48
+ baseActions,
49
+ actionsDisabled,
50
+ handleBack,
51
+ handleNewChat,
52
+ handleHistoryToggle,
53
+ handleClose,
54
+ handleFolding,
55
+ foldingState,
56
+ ]);
45
57
  return {
46
58
  title,
47
59
  preview,
@@ -1 +1 @@
1
- {"version":3,"file":"useHeader.js","sourceRoot":"../../../../../src","sources":["components/organisms/Header/useHeader.ts"],"names":[],"mappings":";;AAeA,8BA6HC;AA5ID,iCAAqC;AAErC,6CAA4C;AAI5C,sCAA4E;AAS5E,SAAgB,SAAS,CAAC,KAAkB;IA0BxC,MAAM,EACF,IAAI,EACJ,KAAK,EACL,OAAO,EACP,WAAW,GAAG,EAAE,EAChB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,YAAY,GAAG,QAAQ,EACvB,iBAAiB,GAAG,EAAE,EACtB,gBAAgB,GAAG,EAAE,EACrB,YAAY,GAAG,EAAE,EACjB,UAAU,EAAE,cAAc,EAC1B,WAAW,EACX,SAAS,GAAG,EAAE,EACd,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,GAAG,IAAI,EACrB,aAAa,GAAG,MAAM,EACtB,QAAQ,GAAG,IAAI,EACf,SAAS,GAAG,IAAI,EAChB,SAAS,EACT,gBAAgB,EAChB,EAAE,EACF,QAAQ,EACR,kBAAkB,GACrB,GAAG,KAAK,CAAC;IAEV,MAAM,QAAQ,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC7B,MAAM,UAAU,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAE7D,qBA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B;QAChB,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,WAAW;QACX,aAAa;QACb,QAAQ;QACR,SAAS;QACT,SAAS;QACT,gBAAgB;QAChB,EAAE;QACF,QAAQ;QACR,kBAAkB;QAClB,SAAS;QACT,iBAAiB;QACjB,cAAc;QACd,YAAY;QACZ,UAAU;QACV,cAAc;KACjB,CAAC;AACN,CAAC","sourcesContent":["import React, {useMemo} from 'react';\n\nimport {useMobile} from '@gravity-ui/uikit';\n\nimport type {Action} from '../../../types/common';\n\nimport {HeaderAction, type HeaderMenuItem, type HeaderProps} from './types';\n\nexport type ActionItem = {\n id: string;\n type: 'base' | 'additional';\n onClick?: () => void;\n foldingState?: 'collapsed' | 'opened';\n};\n\nexport function useHeader(props: HeaderProps): {\n title: string | undefined;\n preview: React.ReactNode | undefined;\n icon: React.ReactNode | undefined;\n baseActions: ActionItem[];\n additionalActions: Action[];\n actionsPlacement: NonNullable<HeaderProps['actionsPlacement']>;\n actionsOrder: NonNullable<HeaderProps['actionsOrder']>;\n actionSize: NonNullable<HeaderProps['actionSize']>;\n isMobile: boolean;\n actionIcons?: HeaderProps['actionIcons'];\n titlePosition: 'left' | 'center';\n withIcon: boolean;\n showTitle: boolean;\n className?: string;\n historyButtonRef?: React.RefObject<HTMLElement>;\n qa?: string;\n actionQa?: HeaderProps['actionQa'];\n actionTooltipTexts?: HeaderProps['actionTooltipTexts'];\n menuItems: HeaderMenuItem[];\n menuButtonTooltip?: string;\n menuButtonIcon?: React.ReactNode;\n menuButtonQa?: string;\n menuItemQa?: HeaderProps['menuItemQa'];\n showSheetTitle: boolean;\n} {\n const {\n icon,\n title,\n preview,\n baseActions = [],\n handleNewChat,\n handleHistoryToggle,\n handleClose,\n handleFolding,\n foldingState = 'opened',\n additionalActions = [],\n actionsPlacement = {},\n actionsOrder = {},\n actionSize: actionSizeProp,\n actionIcons,\n menuItems = [],\n menuButtonTooltip,\n menuButtonIcon,\n menuButtonQa,\n menuItemQa,\n showSheetTitle = true,\n titlePosition = 'left',\n withIcon = true,\n showTitle = true,\n className,\n historyButtonRef,\n qa,\n actionQa,\n actionTooltipTexts,\n } = props;\n\n const isMobile = useMobile();\n const actionSize = actionSizeProp ?? (isMobile ? 'xl' : 'm');\n\n // Build base actions\n const baseActionsList = useMemo(() => {\n const actions: ActionItem[] = [];\n\n baseActions.forEach((action) => {\n if (action === HeaderAction.Folding) {\n if (handleFolding) {\n actions.push({\n id: action,\n type: 'base',\n onClick: () => {\n const newState = foldingState === 'opened' ? 'collapsed' : 'opened';\n handleFolding(newState);\n },\n foldingState,\n });\n }\n return;\n }\n\n const actionMap: Partial<Record<HeaderAction, () => void>> = {\n [HeaderAction.NewChat]: handleNewChat,\n [HeaderAction.History]: handleHistoryToggle,\n [HeaderAction.Close]: handleClose,\n };\n\n const handler = actionMap[action];\n if (handler) {\n actions.push({\n id: action,\n type: 'base',\n onClick: handler,\n });\n }\n });\n\n return actions;\n }, [baseActions, handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState]);\n\n return {\n title,\n preview,\n icon,\n baseActions: baseActionsList,\n additionalActions,\n actionsPlacement,\n actionsOrder,\n actionSize,\n isMobile,\n actionIcons,\n titlePosition,\n withIcon,\n showTitle,\n className,\n historyButtonRef,\n qa,\n actionQa,\n actionTooltipTexts,\n menuItems,\n menuButtonTooltip,\n menuButtonIcon,\n menuButtonQa,\n menuItemQa,\n showSheetTitle,\n };\n}\n"]}
1
+ {"version":3,"file":"useHeader.js","sourceRoot":"../../../../../src","sources":["components/organisms/Header/useHeader.ts"],"names":[],"mappings":";;AAgBA,8BA2IC;AA3JD,iCAAqC;AAErC,6CAA4C;AAI5C,sCAA4E;AAU5E,SAAgB,SAAS,CAAC,KAAkB;IA0BxC,MAAM,EACF,IAAI,EACJ,KAAK,EACL,OAAO,EACP,WAAW,GAAG,EAAE,EAChB,eAAe,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,YAAY,GAAG,QAAQ,EAC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AC/B,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,aAAa;gBACrC,CAAC,oBAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB;gBAC3C,CAAC,oBAAY,CAAC,KAAK,CAAC,EAAE,WAAW;aACpC,CAAC;YAEF,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,IAAI,CAAC;oBACT,EAAE,EAAE,MAAM;oBACV,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,eAAe;oBACzB,OAAO,EAAE,OAAO;iBACnB,CAAC,CAAC;YACP,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACnB,CAAC,EAAE;QACC,WAAW;QACX,eAAe;QACf,UAAU;QACV,aAAa;QACb,mBAAmB;QACnB,WAAW;QACX,aAAa;QACb,YAAY;KACf,CAAC,CAAC;IAEH,OAAO;QACH,KAAK;QACL,OAAO;QACP,IAAI;QACJ,WAAW,EAAE,eAAe;QAC5B,iBAAiB;QACjB,gBAAgB;QAChB,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,WAAW;QACX,aAAa;QACb,QAAQ;QACR,SAAS;QACT,SAAS;QACT,gBAAgB;QAChB,EAAE;QACF,QAAQ;QACR,kBAAkB;QAClB,SAAS;QACT,iBAAiB;QACjB,cAAc;QACd,YAAY;QACZ,UAAU;QACV,cAAc;KACjB,CAAC;AACN,CAAC","sourcesContent":["import React, {useMemo} from 'react';\n\nimport {useMobile} from '@gravity-ui/uikit';\n\nimport type {Action} from '../../../types/common';\n\nimport {HeaderAction, type HeaderMenuItem, type HeaderProps} from './types';\n\nexport type ActionItem = {\n id: string;\n type: 'base' | 'additional';\n disabled?: boolean;\n onClick?: () => void;\n foldingState?: 'collapsed' | 'opened';\n};\n\nexport function useHeader(props: HeaderProps): {\n title: string | undefined;\n preview: React.ReactNode | undefined;\n icon: React.ReactNode | undefined;\n baseActions: ActionItem[];\n additionalActions: Action[];\n actionsPlacement: NonNullable<HeaderProps['actionsPlacement']>;\n actionsOrder: NonNullable<HeaderProps['actionsOrder']>;\n actionSize: NonNullable<HeaderProps['actionSize']>;\n isMobile: boolean;\n actionIcons?: HeaderProps['actionIcons'];\n titlePosition: 'left' | 'center';\n withIcon: boolean;\n showTitle: boolean;\n className?: string;\n historyButtonRef?: React.RefObject<HTMLElement>;\n qa?: string;\n actionQa?: HeaderProps['actionQa'];\n actionTooltipTexts?: HeaderProps['actionTooltipTexts'];\n menuItems: HeaderMenuItem[];\n menuButtonTooltip?: string;\n menuButtonIcon?: React.ReactNode;\n menuButtonQa?: string;\n menuItemQa?: HeaderProps['menuItemQa'];\n showSheetTitle: boolean;\n} {\n const {\n icon,\n title,\n preview,\n baseActions = [],\n actionsDisabled,\n handleBack,\n handleNewChat,\n handleHistoryToggle,\n handleClose,\n handleFolding,\n foldingState = 'opened',\n additionalActions = [],\n actionsPlacement = {},\n actionsOrder = {},\n actionSize: actionSizeProp,\n actionIcons,\n menuItems = [],\n menuButtonTooltip,\n menuButtonIcon,\n menuButtonQa,\n menuItemQa,\n showSheetTitle = true,\n titlePosition = 'left',\n withIcon = true,\n showTitle = true,\n className,\n historyButtonRef,\n qa,\n actionQa,\n actionTooltipTexts,\n } = props;\n\n const isMobile = useMobile();\n const actionSize = actionSizeProp ?? (isMobile ? 'xl' : 'm');\n\n // Build base actions\n const baseActionsList = useMemo(() => {\n const actions: ActionItem[] = [];\n\n baseActions.forEach((action) => {\n if (action === HeaderAction.Folding) {\n if (handleFolding) {\n actions.push({\n id: action,\n type: 'base',\n disabled: actionsDisabled,\n onClick: () => {\n const newState = foldingState === 'opened' ? 'collapsed' : 'opened';\n handleFolding(newState);\n },\n foldingState,\n });\n }\n return;\n }\n\n const actionMap: Partial<Record<HeaderAction, () => void>> = {\n [HeaderAction.Back]: handleBack,\n [HeaderAction.NewChat]: handleNewChat,\n [HeaderAction.History]: handleHistoryToggle,\n [HeaderAction.Close]: handleClose,\n };\n\n const handler = actionMap[action];\n if (handler) {\n actions.push({\n id: action,\n type: 'base',\n disabled: actionsDisabled,\n onClick: handler,\n });\n }\n });\n\n return actions;\n }, [\n baseActions,\n actionsDisabled,\n handleBack,\n handleNewChat,\n handleHistoryToggle,\n handleClose,\n handleFolding,\n foldingState,\n ]);\n\n return {\n title,\n preview,\n icon,\n baseActions: baseActionsList,\n additionalActions,\n actionsPlacement,\n actionsOrder,\n actionSize,\n isMobile,\n actionIcons,\n titlePosition,\n withIcon,\n showTitle,\n className,\n historyButtonRef,\n qa,\n actionQa,\n actionTooltipTexts,\n menuItems,\n menuButtonTooltip,\n menuButtonIcon,\n menuButtonQa,\n menuItemQa,\n showSheetTitle,\n };\n}\n"]}
@@ -9,6 +9,11 @@
9
9
  flex: 1;
10
10
  align-self: stretch;
11
11
  }
12
+ .g-aikit-message-list__screen-anchor {
13
+ display: flex;
14
+ flex-direction: column;
15
+ min-width: 0;
16
+ }
12
17
  .g-aikit-message-list__messages {
13
18
  display: flex;
14
19
  flex-direction: column;
@@ -39,7 +39,7 @@ function PlainMessageList({ messages, scrollMode = 'internal', messageRendererRe
39
39
  // Preserve scroll position when older messages are loaded
40
40
  (0, hooks_1.useScrollPreservation)(containerRef, messages.length);
41
41
  const isNotCompleted = isSubmitted || isStreaming;
42
- return ((0, jsx_runtime_1.jsxs)("div", { ref: scrollMode === 'internal' ? containerRef : undefined, style: scrollMode === 'external' ? { overflow: 'visible', flex: 'none' } : undefined, className: b(null, className), "data-qa": qa !== null && qa !== void 0 ? qa : MessageListQa.Root, children: [hasPreviousMessages && ((0, jsx_runtime_1.jsx)(IntersectionContainer_1.IntersectionContainer, { onIntersect: onLoadPreviousMessages, className: b('load-trigger'), children: (0, jsx_runtime_1.jsx)(Loader_1.Loader, { view: "loading" }) })), (0, jsx_runtime_1.jsx)("div", { className: b('messages'), "data-qa": qa ? `${qa}-messages` : MessageListQa.Messages, children: messages.map((message, index) => ((0, jsx_runtime_1.jsx)(MessageItem_1.MessageItem, { message: message, suppressActions: index === messages.length - 1 && isNotCompleted, showActionsOnHover: showActionsOnHover &&
43
- !(0, usePopup_1.isActionPopupOpenForMessage)(popupState, message.id), messageRendererRegistry: messageRendererRegistry, thinkingMessageView: thinkingMessageView, transformOptions: transformOptions, shouldParseIncompleteMarkdown: shouldParseIncompleteMarkdown, mermaidOptions: mermaidOptions, openMarkdownLinksInNewTab: openMarkdownLinksInNewTab, mdxOptions: mdxProps === null || mdxProps === void 0 ? void 0 : mdxProps.mdxOptions, getMarkdownExtraProps: mdxProps === null || mdxProps === void 0 ? void 0 : mdxProps.getMarkdownExtraProps, getMdxContext: mdxProps === null || mdxProps === void 0 ? void 0 : mdxProps.getMdxContext, showTimestamp: showTimestamp, showAvatar: showAvatar, userActions: userActions, assistantActions: assistantActions, renderAssistantFooter: renderAssistantFooter, userExtraInfo: UserExtraInfo, assistantExtraInfo: AssistantExtraInfo, onActionPopup: handleActionPopup }, message.id || `message-${index}`))) }), (0, jsx_runtime_1.jsx)(MessageListFooter_1.MessageListFooter, { showLoader: showLoader, status: status, errorMessage: errorMessage, loaderMessage: loaderMessage, withLoaderShimmer: withLoaderShimmer, onRetry: onRetry, ratingBlockProps: ratingBlockProps, actionPopupProps: actionPopupProps, qa: qa, showActionPopup: showActionPopup, popupState: popupState, onPopupOpenChange: handlePopupOpenChange }), footerContent !== undefined && footerContent !== null && ((0, jsx_runtime_1.jsx)("div", { className: b('footer-content'), children: footerContent }))] }));
42
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: scrollMode === 'internal' ? containerRef : undefined, style: scrollMode === 'external' ? { overflow: 'visible', flex: 'none' } : undefined, className: b(null, className), "data-qa": qa !== null && qa !== void 0 ? qa : MessageListQa.Root, children: [hasPreviousMessages && ((0, jsx_runtime_1.jsx)(IntersectionContainer_1.IntersectionContainer, { onIntersect: onLoadPreviousMessages, className: b('load-trigger'), children: (0, jsx_runtime_1.jsx)(Loader_1.Loader, { view: "loading" }) })), (0, jsx_runtime_1.jsx)("div", { className: b('messages'), "data-qa": qa ? `${qa}-messages` : MessageListQa.Messages, children: messages.map((message, index) => ((0, jsx_runtime_1.jsx)("div", { "data-message-id": message.id, className: b('screen-anchor'), children: (0, jsx_runtime_1.jsx)(MessageItem_1.MessageItem, { message: message, suppressActions: index === messages.length - 1 && isNotCompleted, showActionsOnHover: showActionsOnHover &&
43
+ !(0, usePopup_1.isActionPopupOpenForMessage)(popupState, message.id), messageRendererRegistry: messageRendererRegistry, thinkingMessageView: thinkingMessageView, transformOptions: transformOptions, shouldParseIncompleteMarkdown: shouldParseIncompleteMarkdown, mermaidOptions: mermaidOptions, openMarkdownLinksInNewTab: openMarkdownLinksInNewTab, mdxOptions: mdxProps === null || mdxProps === void 0 ? void 0 : mdxProps.mdxOptions, getMarkdownExtraProps: mdxProps === null || mdxProps === void 0 ? void 0 : mdxProps.getMarkdownExtraProps, getMdxContext: mdxProps === null || mdxProps === void 0 ? void 0 : mdxProps.getMdxContext, showTimestamp: showTimestamp, showAvatar: showAvatar, userActions: userActions, assistantActions: assistantActions, renderAssistantFooter: renderAssistantFooter, userExtraInfo: UserExtraInfo, assistantExtraInfo: AssistantExtraInfo, onActionPopup: handleActionPopup }) }, message.id || `message-${index}`))) }), (0, jsx_runtime_1.jsx)(MessageListFooter_1.MessageListFooter, { showLoader: showLoader, status: status, errorMessage: errorMessage, loaderMessage: loaderMessage, withLoaderShimmer: withLoaderShimmer, onRetry: onRetry, ratingBlockProps: ratingBlockProps, actionPopupProps: actionPopupProps, qa: qa, showActionPopup: showActionPopup, popupState: popupState, onPopupOpenChange: handlePopupOpenChange }), footerContent !== undefined && footerContent !== null && ((0, jsx_runtime_1.jsx)("div", { className: b('footer-content'), children: footerContent }))] }));
44
44
  }
45
45
  //# sourceMappingURL=MessageList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.js","sourceRoot":"../../../../../src","sources":["components/organisms/MessageList/MessageList.tsx"],"names":[],"mappings":";;;AA6HA,kCASC;;A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,gBAAgB,CAAC,YAAG,aAAa,GAAO,CAC7D,IACC,CACT,CAAC;AACN,CAAC","sourcesContent":["import type {HTMLAttributes, ReactNode} from 'react';\n\nimport type {OptionsType} from '@diplodoc/transform/lib/typings';\nimport type {PopupPlacement} from '@gravity-ui/uikit';\n\nimport {useScrollPreservation, useSmartScroll} from '../../../hooks';\nimport type {MarkdownRendererMdxOptions, MermaidOptions} from '../../../markdown/types';\nimport {ChatStatus} from '../../../types';\nimport type {\n DefaultMessageAction,\n MessageExtraInfoComponent,\n TAssistantMessage,\n TChatMessage,\n TMessageContent,\n TMessageMetadata,\n TUserMessage,\n} from '../../../types/messages';\nimport {block} from '../../../utils/cn';\nimport {type MessageRendererRegistry} from '../../../utils/messageTypeRegistry';\nimport {AlertProps} from '../../atoms/Alert';\nimport {IntersectionContainer} from '../../atoms/IntersectionContainer';\nimport {Loader} from '../../atoms/Loader';\nimport {type RatingBlockProps} from '../../molecules/RatingBlock/RatingBlock';\n\nimport {MessageItem} from './MessageItem';\nimport {VirtualizedMessageList} from './MessageList.virtualized';\nimport {MessageListFooter} from './MessageListFooter';\nimport {isActionPopupOpenForMessage, usePopup} from './usePopup';\n\nimport './MessageList.scss';\n\nconst b = block('message-list');\n\nexport enum MessageListQa {\n Root = 'message-list',\n Messages = 'message-list-messages',\n}\n\n/** Configuration for action popup behavior */\nexport interface MessageListActionPopupConfig {\n /** Override title for all popups (overrides action-specific title) */\n title?: string;\n /** Override subtitle for all popups (overrides action-specific subtitle) */\n subtitle?: string;\n /** Override placement for all popups (overrides action-specific placement) */\n placement?: PopupPlacement;\n /** Additional CSS class for popup */\n className?: string;\n /** QA/test identifier for popup */\n qa?: string;\n}\n\n/**\n * Grouped MDX/markdown rendering props exposed as a single object on `MessageList` and\n * `ChatContainer`. They are destructured back into individual props before being handed to\n * the low-level `MessageItem` renderer.\n */\nexport type MdxProps<TContent extends TMessageContent = never> = {\n /** Options for rendering MDX (`@diplodoc/mdx-extension`) in the default message renderers */\n mdxOptions?: MarkdownRendererMdxOptions;\n /**\n * Resolves the extra props forwarded to the root container `div` of each rendered\n * markdown block. Called with the concrete message so handlers (e.g. `onClick`) can\n * identify the message they belong to.\n */\n getMarkdownExtraProps?: (\n message: TChatMessage<TContent, TMessageMetadata>,\n ) => HTMLAttributes<HTMLDivElement> | undefined;\n /**\n * Resolves the per-message value exposed to MDX components (via `useMdxContext`).\n * Called with the concrete message so embedded MDX components can read data\n * unique to the message they belong to.\n */\n getMdxContext?: (\n message: TChatMessage<TContent, TMessageMetadata>,\n ) => Record<string, unknown> | undefined;\n};\n\nexport type MessageListProps<TContent extends TMessageContent = never> = {\n messages: TChatMessage<TContent, TMessageMetadata>[];\n /** Render message-local content before assistant actions and timestamp. */\n renderAssistantFooter?: (message: TAssistantMessage<TContent, TMessageMetadata>) => ReactNode;\n /** Delegate scrolling to a surrounding layout such as ChatContentV2. */\n scrollMode?: 'internal' | 'external';\n status?: ChatStatus;\n errorMessage?: AlertProps;\n loaderMessage?: string;\n withLoaderShimmer?: boolean;\n onRetry?: () => void;\n messageRendererRegistry?: MessageRendererRegistry;\n thinkingMessageView?: 'default' | 'grouped';\n transformOptions?: OptionsType;\n shouldParseIncompleteMarkdown?: boolean;\n mermaidOptions?: MermaidOptions;\n openMarkdownLinksInNewTab?: boolean;\n /** Grouped MDX/markdown rendering props (`mdxOptions`, `getMarkdownExtraProps`, `getMdxContext`). */\n mdxProps?: MdxProps<TContent>;\n showActionsOnHover?: boolean;\n showTimestamp?: boolean;\n showAvatar?: boolean;\n userActions?: DefaultMessageAction<TUserMessage<TMessageMetadata>>[];\n assistantActions?: DefaultMessageAction<TAssistantMessage<TContent, TMessageMetadata>>[];\n /** Component rendered alongside action buttons for each user message. Receives message as prop. */\n userExtraInfo?: MessageExtraInfoComponent<TUserMessage<TMessageMetadata>>;\n /** Component rendered alongside action buttons for each assistant message. Receives message as prop. */\n assistantExtraInfo?: MessageExtraInfoComponent<TAssistantMessage<TContent, TMessageMetadata>>;\n /** Array of chat statuses that should display the loader */\n loaderStatuses?: ChatStatus[];\n className?: string;\n qa?: string;\n hasPreviousMessages?: boolean;\n onLoadPreviousMessages?: () => void;\n /** Rating block configuration (for CSAT or other feedback use cases) - renders after messages list */\n ratingBlockProps?: RatingBlockProps;\n /** Action popup configuration - applies to all action popups */\n actionPopupProps?: MessageListActionPopupConfig;\n /**\n * Enable windowed rendering via react-window for very large histories.\n * Off by default to preserve the existing rendering/scroll behavior.\n */\n virtualized?: boolean;\n /** Last scrollable row rendered after all messages. */\n footerContent?: React.ReactNode;\n};\n\nexport function MessageList<TContent extends TMessageContent = never>(\n props: MessageListProps<TContent>,\n) {\n // Opt-in virtualized path - keeps the proven non-virtualized rendering untouched below.\n if (props.virtualized) {\n return <VirtualizedMessageList<TContent> {...props} />;\n }\n\n return <PlainMessageList<TContent> {...props} />;\n}\n\nfunction PlainMessageList<TContent extends TMessageContent = never>({\n messages,\n scrollMode = 'internal',\n messageRendererRegistry,\n thinkingMessageView,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n showActionsOnHover,\n showTimestamp,\n showAvatar,\n userActions,\n assistantActions,\n renderAssistantFooter,\n userExtraInfo: UserExtraInfo,\n assistantExtraInfo: AssistantExtraInfo,\n loaderStatuses = ['submitted', 'streaming_loading'],\n className,\n qa,\n status,\n errorMessage,\n loaderMessage,\n withLoaderShimmer,\n onRetry,\n hasPreviousMessages = false,\n onLoadPreviousMessages,\n ratingBlockProps,\n actionPopupProps,\n footerContent,\n}: MessageListProps<TContent>) {\n const isStreaming = status === 'streaming' || status === 'streaming_loading';\n const isSubmitted = status === 'submitted';\n const showLoader = status && loaderStatuses.includes(status);\n\n // Use popup hook for managing popup state\n const {popupState, handleActionPopup, handlePopupOpenChange, showActionPopup} = usePopup<\n TContent,\n TMessageMetadata\n >();\n\n const {containerRef} = useSmartScroll<HTMLDivElement>({\n isStreaming: isStreaming || isSubmitted,\n messagesCount: messages.length,\n status,\n });\n\n // Preserve scroll position when older messages are loaded\n useScrollPreservation(containerRef, messages.length);\n\n const isNotCompleted = isSubmitted || isStreaming;\n\n return (\n <div\n ref={scrollMode === 'internal' ? containerRef : undefined}\n style={scrollMode === 'external' ? {overflow: 'visible', flex: 'none'} : undefined}\n className={b(null, className)}\n data-qa={qa ?? MessageListQa.Root}\n >\n {hasPreviousMessages && (\n <IntersectionContainer\n onIntersect={onLoadPreviousMessages}\n className={b('load-trigger')}\n >\n <Loader view=\"loading\" />\n </IntersectionContainer>\n )}\n <div className={b('messages')} data-qa={qa ? `${qa}-messages` : MessageListQa.Messages}>\n {messages.map((message, index) => (\n <MessageItem<TContent>\n key={message.id || `message-${index}`}\n message={message}\n suppressActions={index === messages.length - 1 && isNotCompleted}\n showActionsOnHover={\n showActionsOnHover &&\n !isActionPopupOpenForMessage(popupState, message.id)\n }\n messageRendererRegistry={messageRendererRegistry}\n thinkingMessageView={thinkingMessageView}\n transformOptions={transformOptions}\n shouldParseIncompleteMarkdown={shouldParseIncompleteMarkdown}\n mermaidOptions={mermaidOptions}\n openMarkdownLinksInNewTab={openMarkdownLinksInNewTab}\n mdxOptions={mdxProps?.mdxOptions}\n getMarkdownExtraProps={mdxProps?.getMarkdownExtraProps}\n getMdxContext={mdxProps?.getMdxContext}\n showTimestamp={showTimestamp}\n showAvatar={showAvatar}\n userActions={userActions}\n assistantActions={assistantActions}\n renderAssistantFooter={renderAssistantFooter}\n userExtraInfo={UserExtraInfo}\n assistantExtraInfo={AssistantExtraInfo}\n onActionPopup={handleActionPopup}\n />\n ))}\n </div>\n <MessageListFooter\n showLoader={showLoader}\n status={status}\n errorMessage={errorMessage}\n loaderMessage={loaderMessage}\n withLoaderShimmer={withLoaderShimmer}\n onRetry={onRetry}\n ratingBlockProps={ratingBlockProps}\n actionPopupProps={actionPopupProps}\n qa={qa}\n showActionPopup={showActionPopup}\n popupState={popupState}\n onPopupOpenChange={handlePopupOpenChange}\n />\n {footerContent !== undefined && footerContent !== null && (\n <div className={b('footer-content')}>{footerContent}</div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"MessageList.js","sourceRoot":"../../../../../src","sources":["components/organisms/MessageList/MessageList.tsx"],"names":[],"mappings":";;;AA6HA,kCASC;;AAjID,mDAAqE;AAYrE,6CAAwC;AAGxC,sFAAwE;AACxE,wDAA0C;AAG1C,kDAA0C;AAC1C,0EAAiE;AACjE,8DAAsD;AACtD,4CAAiE;AAEjE,6BAA4B;AAE5B,MAAM,CAAC,GAAG,IAAA,UAAK,EAAC,cAAc,CAAC,CAAC;AAEhC,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,sCAAqB,CAAA;IACrB,mDAAkC,CAAA;AACtC,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAyFD,SAAgB,WAAW,CACvB,KAAiC;IAEjC,wFAAwF;IACxF,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACpB,OAAO,uBAAC,gDAAsB,oBAAe,KAAK,EAAI,CAAC;IAC3D,CAAC;IAED,OAAO,uBAAC,gBAAgB,oBAAe,KAAK,EAAI,CAAC;AACrD,CAAC;AAED,SAAS,gBAAgB,CAA2C,EAChE,QAAQ,EACR,UAAU,GAAG,UAAU,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,cAAc,EACd,yBAAyB,EACzB,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,EACnD,SAAS,EACT,EAAE,EACF,MAAM,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,mBAAmB,GAAG,KAAK,EAC3B,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACY;IACzB,MAAM,WAAW,GAAG,M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,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,EAAE,EAAE,EAAE,EACN,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,qBAAqB,GAC1C,EACD,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAAI,IAAI,CACtD,gCAAK,SAAS,EAAE,CAAC,CAAC,gBAAgB,CAAC,YAAG,aAAa,GAAO,CAC7D,IACC,CACT,CAAC;AACN,CAAC","sourcesContent":["import type {HTMLAttributes, ReactNode} from 'react';\n\nimport type {OptionsType} from '@diplodoc/transform/lib/typings';\nimport type {PopupPlacement} from '@gravity-ui/uikit';\n\nimport {useScrollPreservation, useSmartScroll} from '../../../hooks';\nimport type {MarkdownRendererMdxOptions, MermaidOptions} from '../../../markdown/types';\nimport {ChatStatus} from '../../../types';\nimport type {\n DefaultMessageAction,\n MessageExtraInfoComponent,\n TAssistantMessage,\n TChatMessage,\n TMessageContent,\n TMessageMetadata,\n TUserMessage,\n} from '../../../types/messages';\nimport {block} from '../../../utils/cn';\nimport {type MessageRendererRegistry} from '../../../utils/messageTypeRegistry';\nimport {AlertProps} from '../../atoms/Alert';\nimport {IntersectionContainer} from '../../atoms/IntersectionContainer';\nimport {Loader} from '../../atoms/Loader';\nimport {type RatingBlockProps} from '../../molecules/RatingBlock/RatingBlock';\n\nimport {MessageItem} from './MessageItem';\nimport {VirtualizedMessageList} from './MessageList.virtualized';\nimport {MessageListFooter} from './MessageListFooter';\nimport {isActionPopupOpenForMessage, usePopup} from './usePopup';\n\nimport './MessageList.scss';\n\nconst b = block('message-list');\n\nexport enum MessageListQa {\n Root = 'message-list',\n Messages = 'message-list-messages',\n}\n\n/** Configuration for action popup behavior */\nexport interface MessageListActionPopupConfig {\n /** Override title for all popups (overrides action-specific title) */\n title?: string;\n /** Override subtitle for all popups (overrides action-specific subtitle) */\n subtitle?: string;\n /** Override placement for all popups (overrides action-specific placement) */\n placement?: PopupPlacement;\n /** Additional CSS class for popup */\n className?: string;\n /** QA/test identifier for popup */\n qa?: string;\n}\n\n/**\n * Grouped MDX/markdown rendering props exposed as a single object on `MessageList` and\n * `ChatContainer`. They are destructured back into individual props before being handed to\n * the low-level `MessageItem` renderer.\n */\nexport type MdxProps<TContent extends TMessageContent = never> = {\n /** Options for rendering MDX (`@diplodoc/mdx-extension`) in the default message renderers */\n mdxOptions?: MarkdownRendererMdxOptions;\n /**\n * Resolves the extra props forwarded to the root container `div` of each rendered\n * markdown block. Called with the concrete message so handlers (e.g. `onClick`) can\n * identify the message they belong to.\n */\n getMarkdownExtraProps?: (\n message: TChatMessage<TContent, TMessageMetadata>,\n ) => HTMLAttributes<HTMLDivElement> | undefined;\n /**\n * Resolves the per-message value exposed to MDX components (via `useMdxContext`).\n * Called with the concrete message so embedded MDX components can read data\n * unique to the message they belong to.\n */\n getMdxContext?: (\n message: TChatMessage<TContent, TMessageMetadata>,\n ) => Record<string, unknown> | undefined;\n};\n\nexport type MessageListProps<TContent extends TMessageContent = never> = {\n messages: TChatMessage<TContent, TMessageMetadata>[];\n /** Render message-local content before assistant actions and timestamp. */\n renderAssistantFooter?: (message: TAssistantMessage<TContent, TMessageMetadata>) => ReactNode;\n /** Delegate scrolling to a surrounding layout such as ChatContentV2. */\n scrollMode?: 'internal' | 'external';\n status?: ChatStatus;\n errorMessage?: AlertProps;\n loaderMessage?: string;\n withLoaderShimmer?: boolean;\n onRetry?: () => void;\n messageRendererRegistry?: MessageRendererRegistry;\n thinkingMessageView?: 'default' | 'grouped';\n transformOptions?: OptionsType;\n shouldParseIncompleteMarkdown?: boolean;\n mermaidOptions?: MermaidOptions;\n openMarkdownLinksInNewTab?: boolean;\n /** Grouped MDX/markdown rendering props (`mdxOptions`, `getMarkdownExtraProps`, `getMdxContext`). */\n mdxProps?: MdxProps<TContent>;\n showActionsOnHover?: boolean;\n showTimestamp?: boolean;\n showAvatar?: boolean;\n userActions?: DefaultMessageAction<TUserMessage<TMessageMetadata>>[];\n assistantActions?: DefaultMessageAction<TAssistantMessage<TContent, TMessageMetadata>>[];\n /** Component rendered alongside action buttons for each user message. Receives message as prop. */\n userExtraInfo?: MessageExtraInfoComponent<TUserMessage<TMessageMetadata>>;\n /** Component rendered alongside action buttons for each assistant message. Receives message as prop. */\n assistantExtraInfo?: MessageExtraInfoComponent<TAssistantMessage<TContent, TMessageMetadata>>;\n /** Array of chat statuses that should display the loader */\n loaderStatuses?: ChatStatus[];\n className?: string;\n qa?: string;\n hasPreviousMessages?: boolean;\n onLoadPreviousMessages?: () => void;\n /** Rating block configuration (for CSAT or other feedback use cases) - renders after messages list */\n ratingBlockProps?: RatingBlockProps;\n /** Action popup configuration - applies to all action popups */\n actionPopupProps?: MessageListActionPopupConfig;\n /**\n * Enable windowed rendering via react-window for very large histories.\n * Off by default to preserve the existing rendering/scroll behavior.\n */\n virtualized?: boolean;\n /** Last scrollable row rendered after all messages. */\n footerContent?: React.ReactNode;\n};\n\nexport function MessageList<TContent extends TMessageContent = never>(\n props: MessageListProps<TContent>,\n) {\n // Opt-in virtualized path - keeps the proven non-virtualized rendering untouched below.\n if (props.virtualized) {\n return <VirtualizedMessageList<TContent> {...props} />;\n }\n\n return <PlainMessageList<TContent> {...props} />;\n}\n\nfunction PlainMessageList<TContent extends TMessageContent = never>({\n messages,\n scrollMode = 'internal',\n messageRendererRegistry,\n thinkingMessageView,\n transformOptions,\n shouldParseIncompleteMarkdown,\n mermaidOptions,\n openMarkdownLinksInNewTab,\n mdxProps,\n showActionsOnHover,\n showTimestamp,\n showAvatar,\n userActions,\n assistantActions,\n renderAssistantFooter,\n userExtraInfo: UserExtraInfo,\n assistantExtraInfo: AssistantExtraInfo,\n loaderStatuses = ['submitted', 'streaming_loading'],\n className,\n qa,\n status,\n errorMessage,\n loaderMessage,\n withLoaderShimmer,\n onRetry,\n hasPreviousMessages = false,\n onLoadPreviousMessages,\n ratingBlockProps,\n actionPopupProps,\n footerContent,\n}: MessageListProps<TContent>) {\n const isStreaming = status === 'streaming' || status === 'streaming_loading';\n const isSubmitted = status === 'submitted';\n const showLoader = status && loaderStatuses.includes(status);\n\n // Use popup hook for managing popup state\n const {popupState, handleActionPopup, handlePopupOpenChange, showActionPopup} = usePopup<\n TContent,\n TMessageMetadata\n >();\n\n const {containerRef} = useSmartScroll<HTMLDivElement>({\n isStreaming: isStreaming || isSubmitted,\n messagesCount: messages.length,\n status,\n });\n\n // Preserve scroll position when older messages are loaded\n useScrollPreservation(containerRef, messages.length);\n\n const isNotCompleted = isSubmitted || isStreaming;\n\n return (\n <div\n ref={scrollMode === 'internal' ? containerRef : undefined}\n style={scrollMode === 'external' ? {overflow: 'visible', flex: 'none'} : undefined}\n className={b(null, className)}\n data-qa={qa ?? MessageListQa.Root}\n >\n {hasPreviousMessages && (\n <IntersectionContainer\n onIntersect={onLoadPreviousMessages}\n className={b('load-trigger')}\n >\n <Loader view=\"loading\" />\n </IntersectionContainer>\n )}\n <div className={b('messages')} data-qa={qa ? `${qa}-messages` : MessageListQa.Messages}>\n {messages.map((message, index) => (\n <div\n key={message.id || `message-${index}`}\n data-message-id={message.id}\n className={b('screen-anchor')}\n >\n <MessageItem<TContent>\n message={message}\n suppressActions={index === messages.length - 1 && isNotCompleted}\n showActionsOnHover={\n showActionsOnHover &&\n !isActionPopupOpenForMessage(popupState, message.id)\n }\n messageRendererRegistry={messageRendererRegistry}\n thinkingMessageView={thinkingMessageView}\n transformOptions={transformOptions}\n shouldParseIncompleteMarkdown={shouldParseIncompleteMarkdown}\n mermaidOptions={mermaidOptions}\n openMarkdownLinksInNewTab={openMarkdownLinksInNewTab}\n mdxOptions={mdxProps?.mdxOptions}\n getMarkdownExtraProps={mdxProps?.getMarkdownExtraProps}\n getMdxContext={mdxProps?.getMdxContext}\n showTimestamp={showTimestamp}\n showAvatar={showAvatar}\n userActions={userActions}\n assistantActions={assistantActions}\n renderAssistantFooter={renderAssistantFooter}\n userExtraInfo={UserExtraInfo}\n assistantExtraInfo={AssistantExtraInfo}\n onActionPopup={handleActionPopup}\n />\n </div>\n ))}\n </div>\n <MessageListFooter\n showLoader={showLoader}\n status={status}\n errorMessage={errorMessage}\n loaderMessage={loaderMessage}\n withLoaderShimmer={withLoaderShimmer}\n onRetry={onRetry}\n ratingBlockProps={ratingBlockProps}\n actionPopupProps={actionPopupProps}\n qa={qa}\n showActionPopup={showActionPopup}\n popupState={popupState}\n onPopupOpenChange={handlePopupOpenChange}\n />\n {footerContent !== undefined && footerContent !== null && (\n <div className={b('footer-content')}>{footerContent}</div>\n )}\n </div>\n );\n}\n"]}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePopup = usePopup;
4
4
  exports.isActionPopupOpenForMessage = isActionPopupOpenForMessage;
5
5
  const react_1 = require("react");
6
+ const ChatViewActivity_1 = require("../../../hooks/ChatViewActivity.js");
6
7
  const INITIAL_POPUP_STATE = {
7
8
  open: false,
8
9
  messageId: null,
@@ -21,7 +22,13 @@ const INITIAL_POPUP_STATE = {
21
22
  * @returns Popup state, open/close handlers, and whether the action popup should render.
22
23
  */
23
24
  function usePopup() {
25
+ const { active } = (0, ChatViewActivity_1.useChatViewActivity)();
24
26
  const [popupState, setPopupState] = (0, react_1.useState)(INITIAL_POPUP_STATE);
27
+ (0, react_1.useEffect)(() => {
28
+ if (!active) {
29
+ setPopupState(INITIAL_POPUP_STATE);
30
+ }
31
+ }, [active]);
25
32
  // Mirror the latest popup state so the stable (deps: []) handler can read it without
26
33
  // re-creating itself on every popup change (it is passed to memoized message items).
27
34
  const popupStateRef = (0, react_1.useRef)(popupState);
@@ -72,7 +79,10 @@ function usePopup() {
72
79
  setPopupState(INITIAL_POPUP_STATE);
73
80
  }
74
81
  }, []);
75
- const showActionPopup = popupState.open && popupState.content !== null && popupState.anchorElement !== null;
82
+ const showActionPopup = active &&
83
+ popupState.open &&
84
+ popupState.content !== null &&
85
+ popupState.anchorElement !== null;
76
86
  return {
77
87
  popupState,
78
88
  handleActionPopup,
@@ -1 +1 @@
1
- {"version":3,"file":"usePopup.js","sourceRoot":"../../../../../src","sources":["components/organisms/MessageList/usePopup.ts"],"names":[],"mappings":";;AAsCA,4BAwFC;AAGD,kEAKC;AAtID,iCAAoD;AASpD,MAAM,mBAAmB,GAAG;IACxB,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,IAAI;CACZ,CAAC;AAaX;;;;;;GAMG;AACH,SAAgB,QAAQ;IACpB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAa,mBAAmB,CAAC,CAAC;IAE9E,qFAAqF;IACrF,qFAAqF;IACrF,MAAM,aAAa,GAAG,IAAA,cAAM,EAAC,UAAU,CAAC,CAAC;IACzC,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC;IAEnC,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EACjC,CACI,OAAiD,EACjD,MAA+B,EAC/B,aAA0B,EAC5B,EAAE;QACA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC;QACrC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC;QAE7C,uFAAuF;QACvF,sDAAsD;QACtD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;QACtC,IACI,OAAO,CAAC,IAAI;YACZ,OAAO,CAAC,SAAS,KAAK,SAAS;YAC/B,OAAO,CAAC,UAAU,KAAK,UAAU,EACnC,CAAC;YACC,aAAa,CAAC,mBAAmB,CAAC,CAAC;YACnC,OAAO;QACX,CAAC;QAED,MAAM,OAAO,GAAuB;YAChC,UAAU,EAAE,CAAC,UAA2B,EAAE,EAAE;gBACxC,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eAAe;KAClB,CAAC;AACN,CAAC;AAED,yEAAyE;AACzE,SAAgB,2BAA2B,CACvC,UAAsB,EACtB,SAA6B;IAE7B,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,SAAS,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;AACvF,CAAC","sourcesContent":["import {useCallback, useRef, useState} from 'react';\n\nimport type {\n ActionPopupContext,\n BaseMessageActionConfig,\n TChatMessage,\n TMessageContent,\n} from '../../../types/messages';\n\nconst INITIAL_POPUP_STATE = {\n open: false,\n messageId: null,\n actionType: null,\n anchorElement: null,\n content: null,\n title: undefined,\n subtitle: undefined,\n actionConfig: null,\n} as const;\n\nexport interface PopupState {\n open: boolean;\n messageId: string | null;\n actionType: string | null;\n anchorElement: HTMLElement | null;\n content: React.ReactNode | null;\n title: string | undefined;\n subtitle: string | undefined;\n actionConfig: BaseMessageActionConfig | null;\n}\n\n/**\n * Hook for managing action popup state in MessageList.\n * Handles opening, closing, and dynamic content/title updates for popups\n * triggered by message action buttons.\n *\n * @returns Popup state, open/close handlers, and whether the action popup should render.\n */\nexport function usePopup<TContent extends TMessageContent, TMessageMetadata>() {\n const [popupState, setPopupState] = useState<PopupState>(INITIAL_POPUP_STATE);\n\n // Mirror the latest popup state so the stable (deps: []) handler can read it without\n // re-creating itself on every popup change (it is passed to memoized message items).\n const popupStateRef = useRef(popupState);\n popupStateRef.current = popupState;\n\n const handleActionPopup = useCallback(\n (\n message: TChatMessage<TContent, TMessageMetadata>,\n action: BaseMessageActionConfig,\n anchorElement: HTMLElement,\n ) => {\n if (!action.popup) {\n return;\n }\n\n const messageId = message.id || null;\n const actionType = action.actionType || null;\n\n // Toggle off: clicking the same action that already opened the popup (e.g. un-pressing\n // dislike) closes the popup instead of re-opening it.\n const current = popupStateRef.current;\n if (\n current.open &&\n current.messageId === messageId &&\n current.actionType === actionType\n ) {\n setPopupState(INITIAL_POPUP_STATE);\n return;\n }\n\n const context: ActionPopupContext = {\n setContent: (newContent: React.ReactNode) => {\n setPopupState((prev) => ({\n ...prev,\n content: newContent,\n }));\n },\n setTitle: (newTitle: string | undefined) => {\n setPopupState((prev) => ({\n ...prev,\n title: newTitle,\n }));\n },\n setSubtitle: (newSubtitle: string | undefined) => {\n setPopupState((prev) => ({\n ...prev,\n subtitle: newSubtitle,\n }));\n },\n closePopup: () => {\n setPopupState(INITIAL_POPUP_STATE);\n },\n };\n\n const content = action.popup.getContent(message, context);\n\n setPopupState({\n open: true,\n messageId,\n actionType,\n anchorElement,\n content,\n title: action.popup.title,\n subtitle: action.popup.subtitle,\n actionConfig: action,\n });\n },\n [],\n );\n\n const handlePopupOpenChange = useCallback((open: boolean) => {\n if (!open) {\n setPopupState(INITIAL_POPUP_STATE);\n }\n }, []);\n\n const showActionPopup =\n popupState.open && popupState.content !== null && popupState.anchorElement !== null;\n\n return {\n popupState,\n handleActionPopup,\n handlePopupOpenChange,\n showActionPopup,\n };\n}\n\n/** Whether an action popup is open and anchored to the given message. */\nexport function isActionPopupOpenForMessage(\n popupState: PopupState,\n messageId: string | undefined,\n): boolean {\n return Boolean(popupState.open && messageId && popupState.messageId === messageId);\n}\n"]}
1
+ {"version":3,"file":"usePopup.js","sourceRoot":"../../../../../src","sources":["components/organisms/MessageList/usePopup.ts"],"names":[],"mappings":";;AAuCA,4BAkGC;AAGD,kEAKC;AAjJD,iCAA+D;AAE/D,yEAAoE;AAQpE,MAAM,mBAAmB,GAAG;IACxB,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,IAAI;CACZ,CAAC;AAaX;;;;;;GAMG;AACH,SAAgB,QAAQ;IACpB,MAAM,EAAC,MAAM,EAAC,GAAG,IAAA,sCAAmB,GAAE,CAAC;IACvC,MAAM,CAAC,UAAU,EAA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react';\n\nimport {useChatViewActivity} from '../../../hooks/ChatViewActivity';\nimport type {\n ActionPopupContext,\n BaseMessageActionConfig,\n TChatMessage,\n TMessageContent,\n} from '../../../types/messages';\n\nconst INITIAL_POPUP_STATE = {\n open: false,\n messageId: null,\n actionType: null,\n anchorElement: null,\n content: null,\n title: undefined,\n subtitle: undefined,\n actionConfig: null,\n} as const;\n\nexport interface PopupState {\n open: boolean;\n messageId: string | null;\n actionType: string | null;\n anchorElement: HTMLElement | null;\n content: React.ReactNode | null;\n title: string | undefined;\n subtitle: string | undefined;\n actionConfig: BaseMessageActionConfig | null;\n}\n\n/**\n * Hook for managing action popup state in MessageList.\n * Handles opening, closing, and dynamic content/title updates for popups\n * triggered by message action buttons.\n *\n * @returns Popup state, open/close handlers, and whether the action popup should render.\n */\nexport function usePopup<TContent extends TMessageContent, TMessageMetadata>() {\n const {active} = useChatViewActivity();\n const [popupState, setPopupState] = useState<PopupState>(INITIAL_POPUP_STATE);\n\n useEffect(() => {\n if (!active) {\n setPopupState(INITIAL_POPUP_STATE);\n }\n }, [active]);\n\n // Mirror the latest popup state so the stable (deps: []) handler can read it without\n // re-creating itself on every popup change (it is passed to memoized message items).\n const popupStateRef = useRef(popupState);\n popupStateRef.current = popupState;\n\n const handleActionPopup = useCallback(\n (\n message: TChatMessage<TContent, TMessageMetadata>,\n action: BaseMessageActionConfig,\n anchorElement: HTMLElement,\n ) => {\n if (!action.popup) {\n return;\n }\n\n const messageId = message.id || null;\n const actionType = action.actionType || null;\n\n // Toggle off: clicking the same action that already opened the popup (e.g. un-pressing\n // dislike) closes the popup instead of re-opening it.\n const current = popupStateRef.current;\n if (\n current.open &&\n current.messageId === messageId &&\n current.actionType === actionType\n ) {\n setPopupState(INITIAL_POPUP_STATE);\n return;\n }\n\n const context: ActionPopupContext = {\n setContent: (newContent: React.ReactNode) => {\n setPopupState((prev) => ({\n ...prev,\n content: newContent,\n }));\n },\n setTitle: (newTitle: string | undefined) => {\n setPopupState((prev) => ({\n ...prev,\n title: newTitle,\n }));\n },\n setSubtitle: (newSubtitle: string | undefined) => {\n setPopupState((prev) => ({\n ...prev,\n subtitle: newSubtitle,\n }));\n },\n closePopup: () => {\n setPopupState(INITIAL_POPUP_STATE);\n },\n };\n\n const content = action.popup.getContent(message, context);\n\n setPopupState({\n open: true,\n messageId,\n actionType,\n anchorElement,\n content,\n title: action.popup.title,\n subtitle: action.popup.subtitle,\n actionConfig: action,\n });\n },\n [],\n );\n\n const handlePopupOpenChange = useCallback((open: boolean) => {\n if (!open) {\n setPopupState(INITIAL_POPUP_STATE);\n }\n }, []);\n\n const showActionPopup =\n active &&\n popupState.open &&\n popupState.content !== null &&\n popupState.anchorElement !== null;\n\n return {\n popupState,\n handleActionPopup,\n handlePopupOpenChange,\n showActionPopup,\n };\n}\n\n/** Whether an action popup is open and anchored to the given message. */\nexport function isActionPopupOpenForMessage(\n popupState: PopupState,\n messageId: string | undefined,\n): boolean {\n return Boolean(popupState.open && messageId && popupState.messageId === messageId);\n}\n"]}