@wallarm-org/design-system 3.2.0 → 3.3.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.
- package/dist/components/AnimatedBackground/blur/BlurBackground.d.ts +6 -0
- package/dist/components/AnimatedBackground/blur/BlurBackground.js +176 -76
- package/dist/components/AnimatedBackground/blur/index.d.ts +1 -1
- package/dist/components/AnimatedBackground/index.d.ts +1 -1
- package/dist/components/ApprovalCard/ApprovalCard.d.ts +13 -0
- package/dist/components/ApprovalCard/ApprovalCard.js +249 -0
- package/dist/components/ApprovalCard/ApprovalCardActions.d.ts +6 -0
- package/dist/components/ApprovalCard/ApprovalCardActions.js +50 -0
- package/dist/components/ApprovalCard/ApprovalCardContent.d.ts +6 -0
- package/dist/components/ApprovalCard/ApprovalCardContent.js +50 -0
- package/dist/components/ApprovalCard/classes.d.ts +10 -0
- package/dist/components/ApprovalCard/classes.js +26 -0
- package/dist/components/ApprovalCard/index.d.ts +3 -0
- package/dist/components/ApprovalCard/index.js +3 -0
- package/dist/components/AssistantMessage/AssistantMessage.d.ts +12 -0
- package/dist/components/AssistantMessage/AssistantMessage.js +66 -0
- package/dist/components/AssistantMessage/AssistantMessageContent.d.ts +10 -0
- package/dist/components/AssistantMessage/AssistantMessageContent.js +50 -0
- package/dist/components/AssistantMessage/AssistantMessageError.d.ts +13 -0
- package/dist/components/AssistantMessage/AssistantMessageError.js +93 -0
- package/dist/components/AssistantMessage/AssistantMessageLoader.d.ts +13 -0
- package/dist/components/AssistantMessage/AssistantMessageLoader.js +88 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdown.d.ts +71 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdown.js +278 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownCodeBlock.d.ts +17 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownCodeBlock.js +94 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownInlineCode.d.ts +10 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownInlineCode.js +59 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownLink.d.ts +14 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownLink.js +65 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownTable.d.ts +7 -0
- package/dist/components/AssistantMessage/AssistantMessageMarkdownTable.js +70 -0
- package/dist/components/AssistantMessage/classes.d.ts +38 -0
- package/dist/components/AssistantMessage/classes.js +46 -0
- package/dist/components/AssistantMessage/index.d.ts +9 -0
- package/dist/components/AssistantMessage/index.js +9 -0
- package/dist/components/AssistantMessage/lib/markdown.d.ts +20 -0
- package/dist/components/AssistantMessage/lib/markdown.js +51 -0
- package/dist/components/ChainOfThought/ChainOfThought.d.ts +10 -0
- package/dist/components/ChainOfThought/ChainOfThought.js +66 -0
- package/dist/components/ChainOfThought/ChainOfThoughtStep.d.ts +31 -0
- package/dist/components/ChainOfThought/ChainOfThoughtStep.js +312 -0
- package/dist/components/ChainOfThought/classes.d.ts +20 -0
- package/dist/components/ChainOfThought/classes.js +84 -0
- package/dist/components/ChainOfThought/index.d.ts +2 -0
- package/dist/components/ChainOfThought/index.js +2 -0
- package/dist/components/Chat/Chat.d.ts +12 -0
- package/dist/components/Chat/Chat.js +90 -0
- package/dist/components/Chat/ChatBody.d.ts +12 -0
- package/dist/components/Chat/ChatBody.js +52 -0
- package/dist/components/Chat/ChatFooter.d.ts +7 -0
- package/dist/components/Chat/ChatFooter.js +50 -0
- package/dist/components/Chat/ChatGreeting.d.ts +8 -0
- package/dist/components/Chat/ChatGreeting.js +94 -0
- package/dist/components/Chat/ChatHeader.d.ts +6 -0
- package/dist/components/Chat/ChatHeader.js +50 -0
- package/dist/components/Chat/ChatHeaderActions.d.ts +7 -0
- package/dist/components/Chat/ChatHeaderActions.js +50 -0
- package/dist/components/Chat/ChatHeaderTitle.d.ts +12 -0
- package/dist/components/Chat/ChatHeaderTitle.js +99 -0
- package/dist/components/Chat/ChatSuggestion.d.ts +7 -0
- package/dist/components/Chat/ChatSuggestion.js +56 -0
- package/dist/components/Chat/ChatSuggestions.d.ts +14 -0
- package/dist/components/Chat/ChatSuggestions.js +111 -0
- package/dist/components/Chat/ChatSuggestionsContext.d.ts +7 -0
- package/dist/components/Chat/ChatSuggestionsContext.js +7 -0
- package/dist/components/Chat/ChatTrigger.d.ts +13 -0
- package/dist/components/Chat/ChatTrigger.js +101 -0
- package/dist/components/Chat/classes.d.ts +17 -0
- package/dist/components/Chat/classes.js +44 -0
- package/dist/components/Chat/index.d.ts +10 -0
- package/dist/components/Chat/index.js +10 -0
- package/dist/components/ChatInput/ChatInput.d.ts +30 -0
- package/dist/components/ChatInput/ChatInput.js +230 -0
- package/dist/components/ChatInput/ChatInputContext.d.ts +11 -0
- package/dist/components/ChatInput/ChatInputContext.js +8 -0
- package/dist/components/ChatInput/ChatInputSubmit.d.ts +10 -0
- package/dist/components/ChatInput/ChatInputSubmit.js +175 -0
- package/dist/components/ChatInput/ChatInputTextarea.d.ts +6 -0
- package/dist/components/ChatInput/ChatInputTextarea.js +155 -0
- package/dist/components/ChatInput/classes.d.ts +9 -0
- package/dist/components/ChatInput/classes.js +22 -0
- package/dist/components/ChatInput/index.d.ts +3 -0
- package/dist/components/ChatInput/index.js +3 -0
- package/dist/components/ChatPermissions/ChatPermissions.d.ts +12 -0
- package/dist/components/ChatPermissions/ChatPermissions.js +66 -0
- package/dist/components/ChatPermissions/ChatPermissionsContent.d.ts +7 -0
- package/dist/components/ChatPermissions/ChatPermissionsContent.js +73 -0
- package/dist/components/ChatPermissions/ChatPermissionsContext.d.ts +7 -0
- package/dist/components/ChatPermissions/ChatPermissionsContext.js +8 -0
- package/dist/components/ChatPermissions/ChatPermissionsItem.d.ts +17 -0
- package/dist/components/ChatPermissions/ChatPermissionsItem.js +115 -0
- package/dist/components/ChatPermissions/ChatPermissionsTrigger.d.ts +6 -0
- package/dist/components/ChatPermissions/ChatPermissionsTrigger.js +110 -0
- package/dist/components/ChatPermissions/classes.d.ts +3 -0
- package/dist/components/ChatPermissions/classes.js +5 -0
- package/dist/components/ChatPermissions/index.d.ts +4 -0
- package/dist/components/ChatPermissions/index.js +4 -0
- package/dist/components/Conversation/Conversation.d.ts +19 -0
- package/dist/components/Conversation/Conversation.js +102 -0
- package/dist/components/Conversation/ConversationContent.d.ts +11 -0
- package/dist/components/Conversation/ConversationContent.js +103 -0
- package/dist/components/Conversation/ConversationContext.d.ts +14 -0
- package/dist/components/Conversation/ConversationContext.js +8 -0
- package/dist/components/Conversation/ConversationEmptyState.d.ts +15 -0
- package/dist/components/Conversation/ConversationEmptyState.js +70 -0
- package/dist/components/Conversation/ConversationScrollButton.d.ts +13 -0
- package/dist/components/Conversation/ConversationScrollButton.js +138 -0
- package/dist/components/Conversation/classes.d.ts +13 -0
- package/dist/components/Conversation/classes.js +8 -0
- package/dist/components/Conversation/index.d.ts +4 -0
- package/dist/components/Conversation/index.js +4 -0
- package/dist/components/Conversation/useStickToBottom.d.ts +9 -0
- package/dist/components/Conversation/useStickToBottom.js +203 -0
- package/dist/components/MessageActions/MessageAction.d.ts +18 -0
- package/dist/components/MessageActions/MessageAction.js +109 -0
- package/dist/components/MessageActions/MessageActions.d.ts +12 -0
- package/dist/components/MessageActions/MessageActions.js +74 -0
- package/dist/components/MessageActions/MessageTimestamp.d.ts +7 -0
- package/dist/components/MessageActions/MessageTimestamp.js +50 -0
- package/dist/components/MessageActions/classes.d.ts +5 -0
- package/dist/components/MessageActions/classes.js +15 -0
- package/dist/components/MessageActions/index.d.ts +3 -0
- package/dist/components/MessageActions/index.js +3 -0
- package/dist/components/Popover/PopoverContent.d.ts +2 -1
- package/dist/components/Popover/PopoverContent.js +42 -39
- package/dist/components/UserMessage/UserMessage.d.ts +10 -0
- package/dist/components/UserMessage/UserMessage.js +66 -0
- package/dist/components/UserMessage/UserMessageBubble.d.ts +16 -0
- package/dist/components/UserMessage/UserMessageBubble.js +175 -0
- package/dist/components/UserMessage/UserMessageContext.d.ts +9 -0
- package/dist/components/UserMessage/UserMessageContext.js +4 -0
- package/dist/components/UserMessage/UserMessageShowMore.d.ts +15 -0
- package/dist/components/UserMessage/UserMessageShowMore.js +87 -0
- package/dist/components/UserMessage/classes.d.ts +11 -0
- package/dist/components/UserMessage/classes.js +32 -0
- package/dist/components/UserMessage/index.d.ts +3 -0
- package/dist/components/UserMessage/index.js +3 -0
- package/dist/components/WallyAssistant/WallyAssistant.d.ts +56 -0
- package/dist/components/WallyAssistant/WallyAssistant.js +541 -0
- package/dist/components/WallyAssistant/index.d.ts +10 -0
- package/dist/components/WallyAssistant/index.js +8 -0
- package/dist/components/WallyAssistant/model/deriveChatState.d.ts +33 -0
- package/dist/components/WallyAssistant/model/deriveChatState.js +54 -0
- package/dist/components/WallyAssistant/model/labels.d.ts +43 -0
- package/dist/components/WallyAssistant/model/labels.js +33 -0
- package/dist/components/WallyAssistant/model/model.d.ts +184 -0
- package/dist/components/WallyAssistant/model/model.js +0 -0
- package/dist/components/WallyAssistant/views/ApprovalCardView.d.ts +20 -0
- package/dist/components/WallyAssistant/views/ApprovalCardView.js +274 -0
- package/dist/components/WallyAssistant/views/ChainOfThoughtView.d.ts +18 -0
- package/dist/components/WallyAssistant/views/ChainOfThoughtView.js +301 -0
- package/dist/components/WallyAssistant/views/ChatMessageView.d.ts +15 -0
- package/dist/components/WallyAssistant/views/ChatMessageView.js +372 -0
- package/dist/components/WallyAssistant/views/ChatPartView.d.ts +16 -0
- package/dist/components/WallyAssistant/views/ChatPartView.js +171 -0
- package/dist/components/WallyAssistant/views/ChatViewContext.d.ts +98 -0
- package/dist/components/WallyAssistant/views/ChatViewContext.js +44 -0
- package/dist/components/WallyAssistant/views/ChatViewProvider.d.ts +18 -0
- package/dist/components/WallyAssistant/views/ChatViewProvider.js +96 -0
- package/dist/components/WallyAssistant/views/stepIcons.d.ts +8 -0
- package/dist/components/WallyAssistant/views/stepIcons.js +47 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/metadata/components.json +30786 -15960
- package/dist/theme/components/animated-background.css +6 -1
- package/dist/theme/index.css +1 -0
- package/dist/theme/utilities/shimmer-text.css +27 -0
- package/package.json +3 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
const messageActionsVariants = cva('flex h-30 items-center gap-4', {
|
|
3
|
+
variants: {
|
|
4
|
+
visible: {
|
|
5
|
+
false: 'opacity-0 transition-opacity motion-reduce:transition-none focus-within:opacity-100 group-hover/message:opacity-100 group-focus-within/message:opacity-100 [@media(hover:none)]:opacity-100',
|
|
6
|
+
true: 'opacity-100'
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
defaultVariants: {
|
|
10
|
+
visible: false
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const messageActionVariants = cva('text-icon-secondary aria-pressed:bg-states-primary-active');
|
|
14
|
+
const messageTimestampVariants = cva("whitespace-nowrap font-mono text-xs leading-sm text-text-secondary [font-feature-settings:'liga'_0]");
|
|
15
|
+
export { messageActionVariants, messageActionsVariants, messageTimestampVariants };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type FC, type HTMLAttributes, type ReactNode } from 'react';
|
|
1
|
+
import { type FC, type HTMLAttributes, type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { type TestableProps } from '../../utils/testId.js';
|
|
3
3
|
import type { PopoverSizeDimension } from './types.js';
|
|
4
4
|
export interface PopoverContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'style'>, TestableProps {
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
5
6
|
children: ReactNode;
|
|
6
7
|
minHeight?: PopoverSizeDimension;
|
|
7
8
|
maxHeight?: PopoverSizeDimension;
|
|
@@ -7,35 +7,38 @@ import { useLayerZIndexRef } from "../../utils/syncLayerZIndex.js";
|
|
|
7
7
|
import { useTestId } from "../../utils/testId.js";
|
|
8
8
|
import { POPOVER_MAX_HEIGHT, POPOVER_MAX_WIDTH, POPOVER_MIN_WIDTH } from "./constants.js";
|
|
9
9
|
const PopoverContent = (t0)=>{
|
|
10
|
-
const $ = c(
|
|
10
|
+
const $ = c(27);
|
|
11
11
|
let children;
|
|
12
12
|
let className;
|
|
13
13
|
let minHeight;
|
|
14
|
+
let ref;
|
|
14
15
|
let rest;
|
|
15
16
|
let t1;
|
|
16
17
|
let t2;
|
|
17
18
|
let t3;
|
|
18
19
|
let testIdProp;
|
|
19
20
|
if ($[0] !== t0) {
|
|
20
|
-
({ children, minHeight, maxHeight: t1, minWidth: t2, maxWidth: t3, className, "data-testid": testIdProp, ...rest } = t0);
|
|
21
|
+
({ ref, children, minHeight, maxHeight: t1, minWidth: t2, maxWidth: t3, className, "data-testid": testIdProp, ...rest } = t0);
|
|
21
22
|
$[0] = t0;
|
|
22
23
|
$[1] = children;
|
|
23
24
|
$[2] = className;
|
|
24
25
|
$[3] = minHeight;
|
|
25
|
-
$[4] =
|
|
26
|
-
$[5] =
|
|
27
|
-
$[6] =
|
|
28
|
-
$[7] =
|
|
29
|
-
$[8] =
|
|
26
|
+
$[4] = ref;
|
|
27
|
+
$[5] = rest;
|
|
28
|
+
$[6] = t1;
|
|
29
|
+
$[7] = t2;
|
|
30
|
+
$[8] = t3;
|
|
31
|
+
$[9] = testIdProp;
|
|
30
32
|
} else {
|
|
31
33
|
children = $[1];
|
|
32
34
|
className = $[2];
|
|
33
35
|
minHeight = $[3];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
ref = $[4];
|
|
37
|
+
rest = $[5];
|
|
38
|
+
t1 = $[6];
|
|
39
|
+
t2 = $[7];
|
|
40
|
+
t3 = $[8];
|
|
41
|
+
testIdProp = $[9];
|
|
39
42
|
}
|
|
40
43
|
const maxHeight = void 0 === t1 ? POPOVER_MAX_HEIGHT : t1;
|
|
41
44
|
const minWidth = void 0 === t2 ? POPOVER_MIN_WIDTH : t2;
|
|
@@ -43,43 +46,43 @@ const PopoverContent = (t0)=>{
|
|
|
43
46
|
const testId = useTestId("content", testIdProp);
|
|
44
47
|
const { getContentProps } = usePopoverContext();
|
|
45
48
|
let t4;
|
|
46
|
-
if ($[
|
|
49
|
+
if ($[10] !== getContentProps) {
|
|
47
50
|
t4 = getContentProps();
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
} else t4 = $[
|
|
51
|
+
$[10] = getContentProps;
|
|
52
|
+
$[11] = t4;
|
|
53
|
+
} else t4 = $[11];
|
|
51
54
|
const { id } = t4;
|
|
52
|
-
const contentRef = useLayerZIndexRef();
|
|
55
|
+
const contentRef = useLayerZIndexRef(ref);
|
|
53
56
|
let t5;
|
|
54
|
-
if ($[
|
|
57
|
+
if ($[12] !== maxHeight || $[13] !== maxWidth || $[14] !== minHeight || $[15] !== minWidth) {
|
|
55
58
|
t5 = {
|
|
56
59
|
"--popover-min-height": minHeight,
|
|
57
60
|
"--popover-max-height": maxHeight,
|
|
58
61
|
"--popover-min-width": minWidth,
|
|
59
62
|
"--popover-max-width": maxWidth
|
|
60
63
|
};
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
66
|
-
} else t5 = $[
|
|
64
|
+
$[12] = maxHeight;
|
|
65
|
+
$[13] = maxWidth;
|
|
66
|
+
$[14] = minHeight;
|
|
67
|
+
$[15] = minWidth;
|
|
68
|
+
$[16] = t5;
|
|
69
|
+
} else t5 = $[16];
|
|
67
70
|
const style = t5;
|
|
68
71
|
let t6;
|
|
69
|
-
if ($[
|
|
72
|
+
if ($[17] !== className) {
|
|
70
73
|
t6 = cn("flex flex-col overflow-auto", "min-w-(--popover-min-width)", "max-w-[clamp(var(--popover-min-width),var(--available-width),var(--popover-max-width))]", "min-h-(--popover-min-height)", "max-h-[clamp(var(--popover-min-height,0px),var(--available-height),var(--popover-max-height))]", "p-12 bg-bg-surface-2 rounded-12 border border-border-primary-light shadow-md text-text-primary", "z-[calc(var(--drawer-positioner-z-index)+(var(--layer-index,0)*var(--drawer-level-ratio)))]", "overscroll-contain", "animate-in fade-in-0 zoom-in-95 origin-[--radix-tooltip-content-transform-origin]", "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", "data-[side=bottom]:slide-in-from-top-2", "data-[side=left]:slide-in-from-right-2", "data-[side=right]:slide-in-from-left-2", "data-[side=top]:slide-in-from-bottom-2", className);
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
} else t6 = $[
|
|
74
|
+
$[17] = className;
|
|
75
|
+
$[18] = t6;
|
|
76
|
+
} else t6 = $[18];
|
|
74
77
|
let t7;
|
|
75
|
-
if ($[
|
|
78
|
+
if ($[19] !== children || $[20] !== contentRef || $[21] !== id || $[22] !== rest || $[23] !== style || $[24] !== t6 || $[25] !== testId) {
|
|
76
79
|
t7 = /*#__PURE__*/ jsx(Portal, {
|
|
77
80
|
children: /*#__PURE__*/ jsx(Popover.Positioner, {
|
|
78
81
|
children: /*#__PURE__*/ jsx(Popover.Content, {
|
|
82
|
+
"data-slot": "popover-content",
|
|
79
83
|
...rest,
|
|
80
84
|
ref: contentRef,
|
|
81
85
|
id: id,
|
|
82
|
-
"data-slot": "popover-content",
|
|
83
86
|
"data-testid": testId,
|
|
84
87
|
style: style,
|
|
85
88
|
className: t6,
|
|
@@ -87,15 +90,15 @@ const PopoverContent = (t0)=>{
|
|
|
87
90
|
})
|
|
88
91
|
})
|
|
89
92
|
});
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
} else t7 = $[
|
|
93
|
+
$[19] = children;
|
|
94
|
+
$[20] = contentRef;
|
|
95
|
+
$[21] = id;
|
|
96
|
+
$[22] = rest;
|
|
97
|
+
$[23] = style;
|
|
98
|
+
$[24] = t6;
|
|
99
|
+
$[25] = testId;
|
|
100
|
+
$[26] = t7;
|
|
101
|
+
} else t7 = $[26];
|
|
99
102
|
return t7;
|
|
100
103
|
};
|
|
101
104
|
PopoverContent.displayName = "PopoverContent";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId.js';
|
|
3
|
+
export interface UserMessageProps extends HTMLAttributes<HTMLElement>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLElement>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A message the user sent: an `<article>` named "You" that right-aligns its bubble and an
|
|
8
|
+
* optional `MessageActions` row. Inside a cascade its test id is `<base>--user-message`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const UserMessage: FC<UserMessageProps>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { TestIdProvider, useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { userMessageVariants } from "./classes.js";
|
|
6
|
+
const UserMessage = (t0)=>{
|
|
7
|
+
const $ = c(17);
|
|
8
|
+
let children;
|
|
9
|
+
let className;
|
|
10
|
+
let props;
|
|
11
|
+
let ref;
|
|
12
|
+
let testIdProp;
|
|
13
|
+
if ($[0] !== t0) {
|
|
14
|
+
({ ref, className, children, "data-testid": testIdProp, ...props } = t0);
|
|
15
|
+
$[0] = t0;
|
|
16
|
+
$[1] = children;
|
|
17
|
+
$[2] = className;
|
|
18
|
+
$[3] = props;
|
|
19
|
+
$[4] = ref;
|
|
20
|
+
$[5] = testIdProp;
|
|
21
|
+
} else {
|
|
22
|
+
children = $[1];
|
|
23
|
+
className = $[2];
|
|
24
|
+
props = $[3];
|
|
25
|
+
ref = $[4];
|
|
26
|
+
testIdProp = $[5];
|
|
27
|
+
}
|
|
28
|
+
const testId = useTestId("user-message", testIdProp);
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[6] !== className) {
|
|
31
|
+
t1 = cn(userMessageVariants(), className);
|
|
32
|
+
$[6] = className;
|
|
33
|
+
$[7] = t1;
|
|
34
|
+
} else t1 = $[7];
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[8] !== children || $[9] !== testId) {
|
|
37
|
+
t2 = /*#__PURE__*/ jsx(TestIdProvider, {
|
|
38
|
+
value: testId,
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
$[8] = children;
|
|
42
|
+
$[9] = testId;
|
|
43
|
+
$[10] = t2;
|
|
44
|
+
} else t2 = $[10];
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[11] !== props || $[12] !== ref || $[13] !== t1 || $[14] !== t2 || $[15] !== testId) {
|
|
47
|
+
t3 = /*#__PURE__*/ jsx("article", {
|
|
48
|
+
"aria-label": "You",
|
|
49
|
+
...props,
|
|
50
|
+
ref: ref,
|
|
51
|
+
"data-slot": "user-message",
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
className: t1,
|
|
54
|
+
children: t2
|
|
55
|
+
});
|
|
56
|
+
$[11] = props;
|
|
57
|
+
$[12] = ref;
|
|
58
|
+
$[13] = t1;
|
|
59
|
+
$[14] = t2;
|
|
60
|
+
$[15] = testId;
|
|
61
|
+
$[16] = t3;
|
|
62
|
+
} else t3 = $[16];
|
|
63
|
+
return t3;
|
|
64
|
+
};
|
|
65
|
+
UserMessage.displayName = "UserMessage";
|
|
66
|
+
export { UserMessage };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type FC, type HTMLAttributes, type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId.js';
|
|
3
|
+
export interface UserMessageBubbleProps extends HTMLAttributes<HTMLDivElement>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLDivElement>;
|
|
5
|
+
/**
|
|
6
|
+
* The Show more / Show less toggle, rendered when the text overflows 11 lines.
|
|
7
|
+
* Defaults to `<UserMessageShowMore />`; pass your own instance to add `data-*`
|
|
8
|
+
* (the analytics seam) or custom labels; `null` or `false` renders no toggle.
|
|
9
|
+
*/
|
|
10
|
+
showMore?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The message bubble. Text keeps its whitespace and is clamped to 11 lines; when it
|
|
14
|
+
* overflows, a fade strip with the toggle appears at the bottom.
|
|
15
|
+
*/
|
|
16
|
+
export declare const UserMessageBubble: FC<UserMessageBubbleProps>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
import { useTestId } from "../../utils/testId.js";
|
|
6
|
+
import { userMessageBubbleVariants, userMessageFadeVariants, userMessageTextVariants } from "./classes.js";
|
|
7
|
+
import { UserMessageBubbleContext } from "./UserMessageContext.js";
|
|
8
|
+
import { UserMessageShowMore } from "./UserMessageShowMore.js";
|
|
9
|
+
const UserMessageBubble = (t0)=>{
|
|
10
|
+
const $ = c(43);
|
|
11
|
+
let children;
|
|
12
|
+
let className;
|
|
13
|
+
let props;
|
|
14
|
+
let ref;
|
|
15
|
+
let showMoreProp;
|
|
16
|
+
let testIdProp;
|
|
17
|
+
if ($[0] !== t0) {
|
|
18
|
+
({ ref, className, children, showMore: showMoreProp, "data-testid": testIdProp, ...props } = t0);
|
|
19
|
+
$[0] = t0;
|
|
20
|
+
$[1] = children;
|
|
21
|
+
$[2] = className;
|
|
22
|
+
$[3] = props;
|
|
23
|
+
$[4] = ref;
|
|
24
|
+
$[5] = showMoreProp;
|
|
25
|
+
$[6] = testIdProp;
|
|
26
|
+
} else {
|
|
27
|
+
children = $[1];
|
|
28
|
+
className = $[2];
|
|
29
|
+
props = $[3];
|
|
30
|
+
ref = $[4];
|
|
31
|
+
showMoreProp = $[5];
|
|
32
|
+
testIdProp = $[6];
|
|
33
|
+
}
|
|
34
|
+
let t1;
|
|
35
|
+
if ($[7] !== showMoreProp) {
|
|
36
|
+
t1 = void 0 === showMoreProp ? /*#__PURE__*/ jsx(UserMessageShowMore, {}) : showMoreProp;
|
|
37
|
+
$[7] = showMoreProp;
|
|
38
|
+
$[8] = t1;
|
|
39
|
+
} else t1 = $[8];
|
|
40
|
+
const showMore = t1;
|
|
41
|
+
const testId = useTestId("bubble", testIdProp);
|
|
42
|
+
const textTestId = useTestId("text");
|
|
43
|
+
const contentId = useId();
|
|
44
|
+
const textRef = useRef(null);
|
|
45
|
+
const [expanded, setExpanded] = useState(false);
|
|
46
|
+
const [overflowing, setOverflowing] = useState(false);
|
|
47
|
+
let t2;
|
|
48
|
+
if ($[9] !== expanded) {
|
|
49
|
+
t2 = ()=>{
|
|
50
|
+
const el = textRef.current;
|
|
51
|
+
if (!el || expanded) return;
|
|
52
|
+
const measure = ()=>setOverflowing(el.scrollHeight > el.clientHeight);
|
|
53
|
+
measure();
|
|
54
|
+
const observer = new ResizeObserver(measure);
|
|
55
|
+
observer.observe(el);
|
|
56
|
+
return ()=>observer.disconnect();
|
|
57
|
+
};
|
|
58
|
+
$[9] = expanded;
|
|
59
|
+
$[10] = t2;
|
|
60
|
+
} else t2 = $[10];
|
|
61
|
+
let t3;
|
|
62
|
+
if ($[11] !== children || $[12] !== expanded) {
|
|
63
|
+
t3 = [
|
|
64
|
+
expanded,
|
|
65
|
+
children
|
|
66
|
+
];
|
|
67
|
+
$[11] = children;
|
|
68
|
+
$[12] = expanded;
|
|
69
|
+
$[13] = t3;
|
|
70
|
+
} else t3 = $[13];
|
|
71
|
+
useLayoutEffect(t2, t3);
|
|
72
|
+
let t4;
|
|
73
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
74
|
+
t4 = ()=>setExpanded(_temp);
|
|
75
|
+
$[14] = t4;
|
|
76
|
+
} else t4 = $[14];
|
|
77
|
+
const toggle = t4;
|
|
78
|
+
let t5;
|
|
79
|
+
if ($[15] !== className || $[16] !== overflowing || $[17] !== showMore) {
|
|
80
|
+
t5 = cn(userMessageBubbleVariants({
|
|
81
|
+
withToggle: overflowing && null != showMore && false !== showMore
|
|
82
|
+
}), className);
|
|
83
|
+
$[15] = className;
|
|
84
|
+
$[16] = overflowing;
|
|
85
|
+
$[17] = showMore;
|
|
86
|
+
$[18] = t5;
|
|
87
|
+
} else t5 = $[18];
|
|
88
|
+
let t6;
|
|
89
|
+
if ($[19] !== contentId || $[20] !== expanded) {
|
|
90
|
+
t6 = {
|
|
91
|
+
contentId,
|
|
92
|
+
expanded,
|
|
93
|
+
toggle
|
|
94
|
+
};
|
|
95
|
+
$[19] = contentId;
|
|
96
|
+
$[20] = expanded;
|
|
97
|
+
$[21] = t6;
|
|
98
|
+
} else t6 = $[21];
|
|
99
|
+
const t7 = !expanded;
|
|
100
|
+
let t8;
|
|
101
|
+
if ($[22] !== t7) {
|
|
102
|
+
t8 = userMessageTextVariants({
|
|
103
|
+
clamped: t7
|
|
104
|
+
});
|
|
105
|
+
$[22] = t7;
|
|
106
|
+
$[23] = t8;
|
|
107
|
+
} else t8 = $[23];
|
|
108
|
+
let t9;
|
|
109
|
+
if ($[24] !== children || $[25] !== contentId || $[26] !== t8 || $[27] !== textTestId) {
|
|
110
|
+
t9 = /*#__PURE__*/ jsx("div", {
|
|
111
|
+
ref: textRef,
|
|
112
|
+
id: contentId,
|
|
113
|
+
"data-slot": "user-message-text",
|
|
114
|
+
"data-testid": textTestId,
|
|
115
|
+
className: t8,
|
|
116
|
+
children: children
|
|
117
|
+
});
|
|
118
|
+
$[24] = children;
|
|
119
|
+
$[25] = contentId;
|
|
120
|
+
$[26] = t8;
|
|
121
|
+
$[27] = textTestId;
|
|
122
|
+
$[28] = t9;
|
|
123
|
+
} else t9 = $[28];
|
|
124
|
+
let t10;
|
|
125
|
+
if ($[29] !== expanded || $[30] !== overflowing || $[31] !== showMore) {
|
|
126
|
+
t10 = overflowing && /*#__PURE__*/ jsx("div", {
|
|
127
|
+
"data-slot": "user-message-fade",
|
|
128
|
+
className: userMessageFadeVariants({
|
|
129
|
+
expanded
|
|
130
|
+
}),
|
|
131
|
+
children: showMore
|
|
132
|
+
});
|
|
133
|
+
$[29] = expanded;
|
|
134
|
+
$[30] = overflowing;
|
|
135
|
+
$[31] = showMore;
|
|
136
|
+
$[32] = t10;
|
|
137
|
+
} else t10 = $[32];
|
|
138
|
+
let t11;
|
|
139
|
+
if ($[33] !== t10 || $[34] !== t6 || $[35] !== t9) {
|
|
140
|
+
t11 = /*#__PURE__*/ jsxs(UserMessageBubbleContext.Provider, {
|
|
141
|
+
value: t6,
|
|
142
|
+
children: [
|
|
143
|
+
t9,
|
|
144
|
+
t10
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
$[33] = t10;
|
|
148
|
+
$[34] = t6;
|
|
149
|
+
$[35] = t9;
|
|
150
|
+
$[36] = t11;
|
|
151
|
+
} else t11 = $[36];
|
|
152
|
+
let t12;
|
|
153
|
+
if ($[37] !== props || $[38] !== ref || $[39] !== t11 || $[40] !== t5 || $[41] !== testId) {
|
|
154
|
+
t12 = /*#__PURE__*/ jsx("div", {
|
|
155
|
+
...props,
|
|
156
|
+
ref: ref,
|
|
157
|
+
"data-slot": "user-message-bubble",
|
|
158
|
+
"data-testid": testId,
|
|
159
|
+
className: t5,
|
|
160
|
+
children: t11
|
|
161
|
+
});
|
|
162
|
+
$[37] = props;
|
|
163
|
+
$[38] = ref;
|
|
164
|
+
$[39] = t11;
|
|
165
|
+
$[40] = t5;
|
|
166
|
+
$[41] = testId;
|
|
167
|
+
$[42] = t12;
|
|
168
|
+
} else t12 = $[42];
|
|
169
|
+
return t12;
|
|
170
|
+
};
|
|
171
|
+
UserMessageBubble.displayName = "UserMessageBubble";
|
|
172
|
+
function _temp(value) {
|
|
173
|
+
return !value;
|
|
174
|
+
}
|
|
175
|
+
export { UserMessageBubble };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface UserMessageBubbleContextValue {
|
|
2
|
+
/** `id` of the text element, for the toggle's `aria-controls`. */
|
|
3
|
+
contentId: string;
|
|
4
|
+
expanded: boolean;
|
|
5
|
+
toggle: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const UserMessageBubbleContext: import("react").Context<UserMessageBubbleContextValue | null>;
|
|
8
|
+
export declare const useUserMessageBubbleContext: () => UserMessageBubbleContextValue | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, FC, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId.js';
|
|
3
|
+
export interface UserMessageShowMoreProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'children'>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLButtonElement>;
|
|
5
|
+
/** Label while the text is clamped. */
|
|
6
|
+
showMoreLabel?: ReactNode;
|
|
7
|
+
/** Label while the text is expanded. */
|
|
8
|
+
showLessLabel?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Toggles the bubble's clamp. Rendered by `UserMessageBubble` by default; pass your own
|
|
12
|
+
* instance through its `showMore` prop. Renders nothing outside a bubble. The consumer
|
|
13
|
+
* `onClick` runs first; `event.preventDefault()` cancels the toggle.
|
|
14
|
+
*/
|
|
15
|
+
export declare const UserMessageShowMore: FC<UserMessageShowMoreProps>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { useTestId } from "../../utils/testId.js";
|
|
5
|
+
import { userMessageShowMoreVariants } from "./classes.js";
|
|
6
|
+
import { useUserMessageBubbleContext } from "./UserMessageContext.js";
|
|
7
|
+
const UserMessageShowMore = (t0)=>{
|
|
8
|
+
const $ = c(22);
|
|
9
|
+
let className;
|
|
10
|
+
let onClick;
|
|
11
|
+
let props;
|
|
12
|
+
let ref;
|
|
13
|
+
let t1;
|
|
14
|
+
let t2;
|
|
15
|
+
let testIdProp;
|
|
16
|
+
if ($[0] !== t0) {
|
|
17
|
+
({ ref, className, onClick, showMoreLabel: t1, showLessLabel: t2, "data-testid": testIdProp, ...props } = t0);
|
|
18
|
+
$[0] = t0;
|
|
19
|
+
$[1] = className;
|
|
20
|
+
$[2] = onClick;
|
|
21
|
+
$[3] = props;
|
|
22
|
+
$[4] = ref;
|
|
23
|
+
$[5] = t1;
|
|
24
|
+
$[6] = t2;
|
|
25
|
+
$[7] = testIdProp;
|
|
26
|
+
} else {
|
|
27
|
+
className = $[1];
|
|
28
|
+
onClick = $[2];
|
|
29
|
+
props = $[3];
|
|
30
|
+
ref = $[4];
|
|
31
|
+
t1 = $[5];
|
|
32
|
+
t2 = $[6];
|
|
33
|
+
testIdProp = $[7];
|
|
34
|
+
}
|
|
35
|
+
const showMoreLabel = void 0 === t1 ? "Show more" : t1;
|
|
36
|
+
const showLessLabel = void 0 === t2 ? "Show less" : t2;
|
|
37
|
+
const testId = useTestId("show-more", testIdProp);
|
|
38
|
+
const context = useUserMessageBubbleContext();
|
|
39
|
+
if (!context) return null;
|
|
40
|
+
let t3;
|
|
41
|
+
if ($[8] !== context || $[9] !== onClick) {
|
|
42
|
+
t3 = (event)=>{
|
|
43
|
+
onClick?.(event);
|
|
44
|
+
if (!event.defaultPrevented) context.toggle();
|
|
45
|
+
};
|
|
46
|
+
$[8] = context;
|
|
47
|
+
$[9] = onClick;
|
|
48
|
+
$[10] = t3;
|
|
49
|
+
} else t3 = $[10];
|
|
50
|
+
const handleClick = t3;
|
|
51
|
+
const t4 = context.expanded;
|
|
52
|
+
const t5 = context.contentId;
|
|
53
|
+
let t6;
|
|
54
|
+
if ($[11] !== className) {
|
|
55
|
+
t6 = cn(userMessageShowMoreVariants(), className);
|
|
56
|
+
$[11] = className;
|
|
57
|
+
$[12] = t6;
|
|
58
|
+
} else t6 = $[12];
|
|
59
|
+
const t7 = context.expanded ? showLessLabel : showMoreLabel;
|
|
60
|
+
let t8;
|
|
61
|
+
if ($[13] !== context.contentId || $[14] !== context.expanded || $[15] !== handleClick || $[16] !== props || $[17] !== ref || $[18] !== t6 || $[19] !== t7 || $[20] !== testId) {
|
|
62
|
+
t8 = /*#__PURE__*/ jsx("button", {
|
|
63
|
+
...props,
|
|
64
|
+
ref: ref,
|
|
65
|
+
"aria-expanded": t4,
|
|
66
|
+
"aria-controls": t5,
|
|
67
|
+
type: "button",
|
|
68
|
+
"data-slot": "user-message-show-more",
|
|
69
|
+
"data-testid": testId,
|
|
70
|
+
className: t6,
|
|
71
|
+
onClick: handleClick,
|
|
72
|
+
children: t7
|
|
73
|
+
});
|
|
74
|
+
$[13] = context.contentId;
|
|
75
|
+
$[14] = context.expanded;
|
|
76
|
+
$[15] = handleClick;
|
|
77
|
+
$[16] = props;
|
|
78
|
+
$[17] = ref;
|
|
79
|
+
$[18] = t6;
|
|
80
|
+
$[19] = t7;
|
|
81
|
+
$[20] = testId;
|
|
82
|
+
$[21] = t8;
|
|
83
|
+
} else t8 = $[21];
|
|
84
|
+
return t8;
|
|
85
|
+
};
|
|
86
|
+
UserMessageShowMore.displayName = "UserMessageShowMore";
|
|
87
|
+
export { UserMessageShowMore };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const userMessageVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const userMessageBubbleVariants: (props?: ({
|
|
3
|
+
withToggle?: boolean | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
+
export declare const userMessageTextVariants: (props?: ({
|
|
6
|
+
clamped?: boolean | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
export declare const userMessageFadeVariants: (props?: ({
|
|
9
|
+
expanded?: boolean | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
+
export declare const userMessageShowMoreVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
const userMessageVariants = cva('group/message flex flex-col items-end pr-16');
|
|
3
|
+
const userMessageBubbleVariants = cva('relative max-w-375 rounded-16 bg-bg-light-brand px-16 text-sm text-text-primary', {
|
|
4
|
+
variants: {
|
|
5
|
+
withToggle: {
|
|
6
|
+
true: 'pt-12 pb-28',
|
|
7
|
+
false: 'py-12'
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
withToggle: false
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const userMessageTextVariants = cva('whitespace-pre-wrap break-words outline-none', {
|
|
15
|
+
variants: {
|
|
16
|
+
clamped: {
|
|
17
|
+
true: 'max-h-220 overflow-hidden'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const userMessageFadeVariants = cva('pointer-events-none absolute inset-x-0 bottom-0 h-36 rounded-b-16', {
|
|
22
|
+
variants: {
|
|
23
|
+
expanded: {
|
|
24
|
+
false: 'bg-linear-to-t from-bg-light-brand from-60% to-transparent'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
expanded: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const userMessageShowMoreVariants = cva('pointer-events-auto absolute top-8 left-16 cursor-pointer rounded-4 text-xs text-text-secondary outline-none transition-colors hover:text-text-primary focus-visible:ring-3 focus-visible:ring-focus-primary');
|
|
32
|
+
export { userMessageBubbleVariants, userMessageFadeVariants, userMessageShowMoreVariants, userMessageTextVariants, userMessageVariants };
|