@buerokratt-ria/common-gui-components 0.0.56 → 0.0.58

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All changes to this project will be documented in this file.
4
4
 
5
5
  ## Template [MajorVersion.MediterraneanVersion.MinorVersion] - DD-MM-YYYY
6
6
 
7
+ ## [0.0.58] - 25.05.2026
8
+
9
+ - Properly render mcq selected button
10
+
11
+ ## [0.0.57] - 14.05.2026
12
+
13
+ - Added authenticated person to chosen columns list
14
+
7
15
  ## [0.0.56] - 13.05.2026
8
16
 
9
17
  - Fixed file downloads to run inside an iframe to avoid parent app navigation and beforeunload logout handling for cross-origin signed URLs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -9,10 +9,21 @@
9
9
  gap: 24px;
10
10
  }
11
11
 
12
+ .history-page-wrapper {
13
+ display: flex;
14
+ flex-direction: column;
15
+ height: 100%;
16
+ min-height: 0;
17
+ overflow: hidden;
18
+ }
19
+
20
+
12
21
  .card-drawer-container {
13
22
  display: flex;
14
23
  width: 100%;
15
- height: 100vh;
24
+ flex: 1;
25
+ min-height: 0;
26
+ overflow: hidden;
16
27
  box-sizing: border-box;
17
28
  }
18
29
 
@@ -57,7 +68,7 @@
57
68
 
58
69
  .drawer-container {
59
70
  flex: 1;
60
- height: 100%;
71
+ min-height: 0;
61
72
  overflow-y: auto;
62
73
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
63
74
  border: 1px solid get-color(black-coral-2);
@@ -87,6 +98,11 @@
87
98
  }
88
99
 
89
100
  .history-content {
101
+ display: flex;
102
+ flex-direction: column;
103
+ flex: 1;
104
+ min-height: 0;
105
+
90
106
  &--loading {
91
107
  opacity: 0.5;
92
108
  pointer-events: none;
@@ -371,6 +371,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
371
371
  {label: t('chat.history.startTime'), value: 'created'},
372
372
  {label: t('chat.history.endTime'), value: 'ended'},
373
373
  {label: t('chat.history.csaName'), value: 'customerSupportFullName'},
374
+ {label: t('chat.history.authenticatedPerson'), value: 'authenticatedPerson'},
374
375
  {label: t('chat.history.comment'), value: 'comment'},
375
376
  {label: t('chat.history.rating'), value: 'feedbackRating'},
376
377
  {label: t('chat.history.feedback'), value: 'feedbackText'},
@@ -1098,7 +1099,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
1098
1099
  if (!filteredEndedChatsList) return <>Loading... {{filteredEndedChatsList}} something is wrong </>;
1099
1100
 
1100
1101
  return (
1101
- <>
1102
+ <div className="history-page-wrapper">
1102
1103
  <div className="header-container">
1103
1104
  {displayTitle && (
1104
1105
  <h1>{t('chat.history.title')}{totalCount === null ? '' : ` (${totalCount.toLocaleString('et-EE')})`}</h1>
@@ -1254,7 +1255,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
1254
1255
  <ClearFiltersButton style={{ marginLeft: 'auto' }} onClick={onClearFilersClick} />
1255
1256
  </Track>
1256
1257
  )}
1257
- <div className="card-drawer-container" style={{height: '100%', overflow: 'auto'}}>
1258
+ <div className="card-drawer-container">
1258
1259
  <div className="card-wrapper">
1259
1260
  <Card>
1260
1261
  <DataTable
@@ -1495,7 +1496,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
1495
1496
  <p>{t('global.removeValidation')}</p>
1496
1497
  </Dialog>
1497
1498
  )}
1498
- </>
1499
+ </div>
1499
1500
  );
1500
1501
 
1501
1502
  function getUserName() {
@@ -1,6 +1,6 @@
1
1
  import React, { FC, useMemo } from "react";
2
2
  import { format } from "date-fns";
3
- import { Message } from "../../types/message";
3
+ import { Message, MessageButton } from "../../types/message";
4
4
  import Markdownify from "../Chat/Markdownify";
5
5
  import { parseButtons, parseOptions } from "../../utils/parse-utils";
6
6
  import ButtonMessage from "../ButtonMessage";
@@ -12,14 +12,25 @@ type ChatMessageProps = {
12
12
  message: Message;
13
13
  onMessageClick?: (message: Message) => void;
14
14
  toastContext: ToastContextType | null;
15
+ previousButtons?: MessageButton[];
15
16
  };
16
17
 
17
- const ChatMessage: FC<ChatMessageProps> = ({ message, onMessageClick, toastContext }) => {
18
+ const isButtonPayload = (content: string) =>
19
+ content.startsWith("#service,") || content.startsWith("#common_service,");
20
+
21
+ const ChatMessage: FC<ChatMessageProps> = ({ message, onMessageClick, toastContext, previousButtons }) => {
18
22
  const buttons = useMemo(() => parseButtons(message), [message.buttons]);
19
23
  const options = useMemo(() => parseOptions(message), [message.options]);
20
24
  const { t } = useTranslation();
21
25
  const toast = toastContext;
22
26
 
27
+ const selectedButton = useMemo(() => {
28
+ const content = message.content ?? "";
29
+ if (!isButtonPayload(content)) return null;
30
+ const match = previousButtons?.find((b) => b.payload === content);
31
+ return match ?? { title: content, payload: content };
32
+ }, [message.content, previousButtons]);
33
+
23
34
  const handleContextMenu = (event: React.MouseEvent<HTMLButtonElement>) => {
24
35
  event.preventDefault();
25
36
  const content = message.content ?? "";
@@ -44,13 +55,17 @@ const ChatMessage: FC<ChatMessageProps> = ({ message, onMessageClick, toastConte
44
55
  return (
45
56
  <>
46
57
  <div className="historical-chat__message">
47
- <button
48
- className="historical-chat__message-text"
49
- onClick={onMessageClick ? () => onMessageClick(message) : undefined}
50
- onContextMenu={handleContextMenu}
51
- >
52
- <Markdownify message={message.content ?? ""} sanitizeLinks={message.authorRole === "end-user"} />
53
- </button>
58
+ {selectedButton ? (
59
+ <ButtonMessage buttons={[selectedButton]} />
60
+ ) : (
61
+ <button
62
+ className="historical-chat__message-text"
63
+ onClick={onMessageClick ? () => onMessageClick(message) : undefined}
64
+ onContextMenu={handleContextMenu}
65
+ >
66
+ <Markdownify message={message.content ?? ""} sanitizeLinks={message.authorRole === "end-user"} />
67
+ </button>
68
+ )}
54
69
  <time dateTime={message.created} className="historical-chat__message-date">
55
70
  {format(new Date(message.created ?? ""), "HH:mm:ss")}
56
71
  </time>
@@ -13,6 +13,8 @@ import { apiDev } from "../../services/api";
13
13
  import ChatEvent from "../../ui-components/ChatEvent";
14
14
  import { ToastContextType } from "../../context";
15
15
  import { AUTHOR_ROLES } from "../../utils/constants";
16
+ import { parseButtons } from "../../utils/parse-utils";
17
+ import { MessageButton } from "../../types/message";
16
18
 
17
19
  type ChatProps = {
18
20
  chat: ChatType;
@@ -57,7 +59,7 @@ const HistoricalChat: FC<ChatProps> = ({
57
59
  onMessageClick,
58
60
  }) => {
59
61
  const { t } = useTranslation();
60
- const chatRef = useRef<HTMLDivElement>(null);
62
+ const groupWrapperRef = useRef<HTMLDivElement>(null);
61
63
  const [messageGroups, setMessageGroups] = useState<GroupedMessage[]>([]);
62
64
  const [editingComment, setEditingComment] = useState<string | null>(null);
63
65
  const [messagesList, setMessagesList] = useState<Message[]>([]);
@@ -184,14 +186,22 @@ const HistoricalChat: FC<ChatProps> = ({
184
186
  }, [messagesList, endUserFullName]);
185
187
 
186
188
  useEffect(() => {
187
- if (!chatRef.current || !messageGroups) return;
188
- chatRef.current.scrollIntoView({ block: "end", inline: "end" });
189
+ if (!groupWrapperRef.current || !messageGroups) return;
190
+ groupWrapperRef.current.scrollTop = groupWrapperRef.current.scrollHeight;
189
191
  }, [messageGroups]);
190
192
 
191
193
  const isEvent = (group: GroupedMessage) => {
192
194
  return (group.type === "event" || group.name.trim() === "" || group.messages.some((message) => message.event && message.event !== CHAT_EVENTS.GREETING));
193
195
  };
194
196
 
197
+ const getPreviousButtons = (messageId: string | undefined): MessageButton[] => {
198
+ const idx = messagesList.findIndex((m) => m.id === messageId);
199
+ for (let i = idx - 1; i >= 0; i--) {
200
+ if (messagesList[i].buttons) return parseButtons(messagesList[i]);
201
+ }
202
+ return [];
203
+ };
204
+
195
205
  const eventGroup = (group: GroupedMessage) => {
196
206
  return group.messages.map((message) => {
197
207
  if (message.event) {
@@ -232,6 +242,7 @@ const HistoricalChat: FC<ChatProps> = ({
232
242
  message={message}
233
243
  key={`${message.id ?? ""}`}
234
244
  toastContext={toastContext}
245
+ previousButtons={getPreviousButtons(message.id)}
235
246
  onMessageClick={(message) => {
236
247
  onMessageClick?.(message);
237
248
  }}
@@ -247,7 +258,7 @@ const HistoricalChat: FC<ChatProps> = ({
247
258
  <div className="historical-chat">
248
259
  <div className="historical-chat__body">
249
260
  {header_link && <div className={"header-link"}>{header_link}</div>}
250
- <div className="historical-chat__group-wrapper">
261
+ <div className="historical-chat__group-wrapper" ref={groupWrapperRef}>
251
262
  {messageGroups?.map((group, index) => (
252
263
  <div
253
264
  className={clsx(["historical-chat__group", `historical-chat__group--${group.type}`])}
@@ -282,6 +293,7 @@ const HistoricalChat: FC<ChatProps> = ({
282
293
  message={message}
283
294
  key={`${message.id ?? ""}-${i}`}
284
295
  toastContext={toastContext}
296
+ previousButtons={getPreviousButtons(message.id)}
285
297
  onMessageClick={(message) => {
286
298
  onMessageClick?.(message);
287
299
  }}
@@ -292,7 +304,6 @@ const HistoricalChat: FC<ChatProps> = ({
292
304
  )}
293
305
  </div>
294
306
  ))}
295
- <div id="anchor" ref={chatRef}></div>
296
307
  </div>
297
308
  {lastMessage && (
298
309
  <div className="historical-chat__toolbar">
@@ -350,7 +361,6 @@ const HistoricalChat: FC<ChatProps> = ({
350
361
  </div>
351
362
  )}
352
363
  </div>
353
- <div id="anchor" ref={chatRef}></div>
354
364
  </div>
355
365
  );
356
366
  };