@sybilion/uilib 1.4.34 → 1.4.36

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.
@@ -19,7 +19,7 @@ function ChatMessage({ role, text, inProgress, userTextFileAttachments, onQuickR
19
19
  const isAssistant = role === MessageRole.ASSISTANT;
20
20
  const isSystem = role === MessageRole.SYSTEM;
21
21
  const assistantDisplayText = useMemo(() => (isAssistant ? stripJsonDashboardFences(text) : text), [isAssistant, text]);
22
- return (jsx("div", { className: cn(S.root, S[`role-${role}`], className), children: isSystem ? (jsx("div", { className: cn(S.text, textClassName), children: inProgress ? (jsx(TextShimmer, { as: "span", children: text })) : renderSystemMessage && message ? (renderSystemMessage(message)) : (text) })) : isAssistant ? (jsx(AgentMessageContent, { text: assistantDisplayText, textClassName: textClassName, onQuickReply: onQuickReply, suppressedQuickReplyKeys: suppressedQuickReplyKeys, quickReplyDisabled: quickReplyDisabled, quickReplyHidden: quickReplyHidden, isLastMessage: isLastMessage, scriptContinue: scriptContinue, onScriptContinue: onScriptContinue, renderMessageChart: renderMessageChart })) : (jsxs("div", { className: S.userColumn, children: [jsx("div", { className: cn(S.text, textClassName && S.textCustom, textClassName), children: jsx(InteractiveContent, { text: text }) }), fileAttachments.map(attachment => (jsx(UserTextFileAttachmentBubble, { attachment: attachment }, `${attachment.displayName}:${attachment.filename}`)))] })) }));
22
+ return (jsx("div", { className: cn(S.root, S[`role-${role}`], className), children: isSystem ? (jsx("div", { className: cn(S.text, textClassName), children: inProgress ? (jsx(TextShimmer, { as: "span", children: text })) : renderSystemMessage && message ? (renderSystemMessage(message)) : (text) })) : isAssistant ? (jsx(AgentMessageContent, { text: assistantDisplayText, textClassName: textClassName, onQuickReply: onQuickReply, suppressedQuickReplyKeys: suppressedQuickReplyKeys, quickReplyDisabled: quickReplyDisabled, quickReplyHidden: quickReplyHidden, isLastMessage: isLastMessage, scriptContinue: scriptContinue, onScriptContinue: onScriptContinue, renderMessageChart: renderMessageChart })) : (jsxs("div", { className: S.userColumn, children: [text.trim() && (jsx("div", { className: cn(S.text, textClassName && S.textCustom, textClassName), children: jsx(InteractiveContent, { text: text }) })), fileAttachments.map(attachment => (jsx(UserTextFileAttachmentBubble, { attachment: attachment }, `${attachment.displayName}:${attachment.filename}`)))] })) }));
23
23
  }
24
24
 
25
25
  export { ChatMessage };
@@ -35,8 +35,13 @@ function ChatSelector({ id, size = 'sm', variant = 'clear', wrapperClassName, cl
35
35
  }
36
36
  if (chat.messages.length > 0) {
37
37
  const firstMessage = chat.messages[0];
38
- return (firstMessage.text.slice(0, 30) +
39
- (firstMessage.text.length > 30 ? '...' : ''));
38
+ const text = firstMessage.text.trim();
39
+ const attachmentName = firstMessage.userTextFileAttachments?.[0]?.displayName?.trim() ?? '';
40
+ // Attachment-only sends keep text empty — title from filename instead.
41
+ const label = text || attachmentName;
42
+ if (label) {
43
+ return label.slice(0, 30) + (label.length > 30 ? '...' : '');
44
+ }
40
45
  }
41
46
  return 'New chat';
42
47
  };
@@ -55,10 +55,10 @@ function buildChatSendMessagePayload(displayText, attachments) {
55
55
  return trimmed;
56
56
  }
57
57
  const userTextFileAttachments = attachments.map(dropItemToUserAttachment);
58
- const resolvedDisplayText = trimmed.length > 0 ? trimmed : userTextFileAttachments[0].displayName;
59
58
  return {
60
- apiMessage: buildApiMessage(resolvedDisplayText, attachments),
61
- displayText: resolvedDisplayText,
59
+ apiMessage: buildApiMessage(trimmed, attachments),
60
+ // Keep empty when send is attachment-only — filename shows on the card, not as a text bubble.
61
+ displayText: trimmed,
62
62
  userTextFileAttachments,
63
63
  };
64
64
  }
@@ -1,15 +1,15 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import cn from 'classnames';
3
3
  import { useState } from 'react';
4
- import { CaretUpIcon, CaretDownIcon } from '@phosphor-icons/react';
4
+ import { CaretUpIcon } from '@phosphor-icons/react';
5
5
  import S from './Foldable.styl.js';
6
6
 
7
- function Foldable({ header, content, contentClassName, defaultUnfolded = false, }) {
7
+ function Foldable({ header, content, contentClassName, defaultUnfolded = false, variant = 'default', }) {
8
8
  const [isUnfolded, setIsUnfolded] = useState(defaultUnfolded);
9
9
  const toggleFold = () => {
10
10
  setIsUnfolded(prev => !prev);
11
11
  };
12
- return (jsxs("div", { className: cn(S.root, isUnfolded && S.unfolded), children: [jsxs("div", { className: S.header, onClick: toggleFold, children: [jsx("div", { className: S.headerContent, children: header }), jsx("div", { className: S.toggle, children: isUnfolded ? (jsx(CaretUpIcon, { size: 20, className: S.icon })) : (jsx(CaretDownIcon, { size: 20, className: S.icon })) })] }), isUnfolded && (jsx("div", { className: cn(S.content, contentClassName), children: content }))] }));
12
+ return (jsxs("div", { className: cn(S.root, isUnfolded && S.unfolded, variant === 'clear' && S.clear), children: [jsxs("div", { className: S.header, onClick: toggleFold, "aria-expanded": isUnfolded, children: [jsx("div", { className: S.headerContent, children: header }), jsx("div", { className: S.toggle, children: jsx(CaretUpIcon, { size: 20, className: S.icon }) })] }), jsx("div", { className: cn(S.content, !isUnfolded && S.contentHidden, contentClassName), children: content })] }));
13
13
  }
14
14
 
15
15
  export { Foldable };
@@ -1,7 +1,7 @@
1
1
  import styleInject from 'style-inject';
2
2
 
3
- var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.Foldable_root__a-aH-{background-color:var(--background);border:1px solid var(--border);border-radius:var(--p-3);display:flex;flex-direction:column;overflow:hidden}.Foldable_root__a-aH-+.Foldable_root__a-aH-{margin-top:var(--p-1)}.Foldable_header__nagB6{align-items:center;cursor:pointer;display:flex;justify-content:space-between;padding:var(--p-2);transition:background-color .2s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.Foldable_header__nagB6:hover,.Foldable_unfolded__9vrPw .Foldable_header__nagB6{background-color:var(--page-color-alpha-800)}.Foldable_headerContent__elQXO{align-items:center;display:flex;flex:1}.Foldable_toggle__9Mjwd{align-items:center;display:flex;margin-left:var(--p-2)}.Foldable_icon__NkmVx{color:var(--text-color-secondary);transition:transform .2s ease}.Foldable_content__OqJ-R{display:flex;flex-direction:column;gap:var(--p-3);padding:0 var(--p-4) var(--p-4) var(--p-4)}.Foldable_unfolded__9vrPw .Foldable_content__OqJ-R{background-color:var(--page-color-alpha-800)}";
4
- var S = {"root":"Foldable_root__a-aH-","header":"Foldable_header__nagB6","unfolded":"Foldable_unfolded__9vrPw","headerContent":"Foldable_headerContent__elQXO","toggle":"Foldable_toggle__9Mjwd","icon":"Foldable_icon__NkmVx","content":"Foldable_content__OqJ-R"};
3
+ var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.Foldable_root__a-aH-{background-color:var(--background);border:1px solid var(--border);border-radius:var(--p-3);display:flex;flex-direction:column;overflow:hidden}.Foldable_root__a-aH-+.Foldable_root__a-aH-{margin-top:var(--p-1)}.Foldable_header__nagB6{align-items:center;cursor:pointer;display:flex;justify-content:space-between;padding:var(--p-2);transition:background-color .2s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.Foldable_header__nagB6:hover,.Foldable_unfolded__9vrPw .Foldable_header__nagB6{background-color:var(--page-color-alpha-800)}.Foldable_headerContent__elQXO{align-items:center;display:flex;flex:1}.Foldable_toggle__9Mjwd{align-items:center;display:flex;margin-left:var(--p-2);opacity:.3;transition:.1s ease-out}.Foldable_root__a-aH-:hover .Foldable_toggle__9Mjwd{opacity:1}.Foldable_icon__NkmVx{color:var(--text-color-secondary);transition:transform .1s ease}.Foldable_unfolded__9vrPw .Foldable_icon__NkmVx{transform:rotate(180deg)}.Foldable_content__OqJ-R{display:flex;flex-direction:column;gap:var(--p-3);padding:0 var(--p-2) var(--p-2) var(--p-2)}.Foldable_unfolded__9vrPw .Foldable_content__OqJ-R{background-color:var(--page-color-alpha-800)}.Foldable_content__OqJ-R.Foldable_contentHidden__7XNpW,.Foldable_root__a-aH-.Foldable_clear__wqaQd .Foldable_content__OqJ-R.Foldable_contentHidden__7XNpW{display:none}.Foldable_root__a-aH-.Foldable_clear__wqaQd{background-color:transparent;border:none;border-radius:0;overflow:visible}.Foldable_root__a-aH-.Foldable_clear__wqaQd+.Foldable_root__a-aH-.Foldable_clear__wqaQd{margin-top:0}.Foldable_root__a-aH-.Foldable_clear__wqaQd .Foldable_header__nagB6{background-color:transparent;padding:0}.Foldable_root__a-aH-.Foldable_clear__wqaQd .Foldable_header__nagB6:hover,.Foldable_root__a-aH-.Foldable_clear__wqaQd.Foldable_unfolded__9vrPw .Foldable_header__nagB6{background-color:transparent}.Foldable_root__a-aH-.Foldable_clear__wqaQd .Foldable_content__OqJ-R{background-color:transparent;padding:8px 0 0}.Foldable_root__a-aH-.Foldable_clear__wqaQd.Foldable_unfolded__9vrPw .Foldable_content__OqJ-R{background-color:transparent}";
4
+ var S = {"root":"Foldable_root__a-aH-","header":"Foldable_header__nagB6","unfolded":"Foldable_unfolded__9vrPw","headerContent":"Foldable_headerContent__elQXO","toggle":"Foldable_toggle__9Mjwd","icon":"Foldable_icon__NkmVx","content":"Foldable_content__OqJ-R","contentHidden":"Foldable_contentHidden__7XNpW","clear":"Foldable_clear__wqaQd"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { S as default };
@@ -1,2 +1,2 @@
1
1
  import type { FoldableProps } from './Foldable.types';
2
- export declare function Foldable({ header, content, contentClassName, defaultUnfolded, }: FoldableProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Foldable({ header, content, contentClassName, defaultUnfolded, variant, }: FoldableProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,9 @@
1
+ export type FoldableVariant = 'default' | 'clear';
1
2
  export interface FoldableProps {
2
3
  header: React.ReactNode;
3
4
  content: React.ReactNode;
4
5
  contentClassName?: string;
5
6
  defaultUnfolded?: boolean;
7
+ /** `clear` strips the card chrome (border, fill). Default keeps the framed panel. */
8
+ variant?: FoldableVariant;
6
9
  }
@@ -1,2 +1,2 @@
1
1
  export { Foldable } from './Foldable';
2
- export type { FoldableProps } from './Foldable.types';
2
+ export type { FoldableProps, FoldableVariant } from './Foldable.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.4.34",
3
+ "version": "1.4.36",
4
4
  "description": "Sybilion Design System — React UI components (Webpack + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -66,11 +66,17 @@ export function ChatMessage({
66
66
  />
67
67
  ) : (
68
68
  <div className={S.userColumn}>
69
- <div
70
- className={cn(S.text, textClassName && S.textCustom, textClassName)}
71
- >
72
- <InteractiveContent text={text} />
73
- </div>
69
+ {text.trim() && (
70
+ <div
71
+ className={cn(
72
+ S.text,
73
+ textClassName && S.textCustom,
74
+ textClassName,
75
+ )}
76
+ >
77
+ <InteractiveContent text={text} />
78
+ </div>
79
+ )}
74
80
  {fileAttachments.map(attachment => (
75
81
  <UserTextFileAttachmentBubble
76
82
  key={`${attachment.displayName}:${attachment.filename}`}
@@ -68,10 +68,14 @@ export function ChatSelector({
68
68
  }
69
69
  if (chat.messages.length > 0) {
70
70
  const firstMessage = chat.messages[0];
71
- return (
72
- firstMessage.text.slice(0, 30) +
73
- (firstMessage.text.length > 30 ? '...' : '')
74
- );
71
+ const text = firstMessage.text.trim();
72
+ const attachmentName =
73
+ firstMessage.userTextFileAttachments?.[0]?.displayName?.trim() ?? '';
74
+ // Attachment-only sends keep text empty — title from filename instead.
75
+ const label = text || attachmentName;
76
+ if (label) {
77
+ return label.slice(0, 30) + (label.length > 30 ? '...' : '');
78
+ }
75
79
  }
76
80
  return 'New chat';
77
81
  };
@@ -38,15 +38,16 @@ describe('buildChatSendMessagePayload', () => {
38
38
  expect(result.userTextFileAttachments?.[0].filename).toMatch(/\.csv$/i);
39
39
  });
40
40
 
41
- it('uses first file name as displayText when message is empty', () => {
41
+ it('keeps displayText empty when message is empty (attachment-only)', () => {
42
42
  const result = buildChatSendMessagePayload('', [
43
43
  makeDropItem('report.pdf', 'pdf text', 'pdf'),
44
44
  ]);
45
45
  if (typeof result === 'string') {
46
46
  throw new Error('expected payload object');
47
47
  }
48
- expect(result.displayText).toBe('report.pdf');
49
- expect(result.apiMessage).toBe('report.pdf\n\npdf text');
48
+ expect(result.displayText).toBe('');
49
+ expect(result.apiMessage).toBe('pdf text');
50
+ expect(result.userTextFileAttachments?.[0].displayName).toBe('report.pdf');
50
51
  expect(result.userTextFileAttachments?.[0].filename).toMatch(/\.pdf$/i);
51
52
  });
52
53
 
@@ -64,12 +64,11 @@ export function buildChatSendMessagePayload(
64
64
  }
65
65
 
66
66
  const userTextFileAttachments = attachments.map(dropItemToUserAttachment);
67
- const resolvedDisplayText =
68
- trimmed.length > 0 ? trimmed : userTextFileAttachments[0].displayName;
69
67
 
70
68
  return {
71
- apiMessage: buildApiMessage(resolvedDisplayText, attachments),
72
- displayText: resolvedDisplayText,
69
+ apiMessage: buildApiMessage(trimmed, attachments),
70
+ // Keep empty when send is attachment-only — filename shows on the card, not as a text bubble.
71
+ displayText: trimmed,
73
72
  userTextFileAttachments,
74
73
  };
75
74
  }
@@ -1,4 +1,4 @@
1
- Foldable is a collapsible section with a clickable header that shows or hides its content. Pass the header and content as props, and use defaultUnfolded to open the section initially.
1
+ Foldable is a collapsible section with a clickable header that shows or hides its content. Pass the header and content as props, and use defaultUnfolded to open the section initially. `variant="clear"` strips the bordered card fill; the default keeps it.
2
2
 
3
3
  ## When to use
4
4
 
@@ -33,16 +33,55 @@
33
33
  display flex
34
34
  align-items center
35
35
  margin-left var(--p-2)
36
+ opacity 0.3
37
+ transition 0.1s ease-out
38
+
39
+ .root:hover &
40
+ opacity 1
36
41
 
37
42
  .icon
38
43
  color var(--text-color-secondary)
39
- transition transform 0.2s ease
44
+ transition transform 0.1s ease
45
+
46
+ .unfolded &
47
+ transform rotate(180deg)
40
48
 
41
49
  .content
42
- padding 0 var(--p-4) var(--p-4) var(--p-4)
50
+ padding 0 var(--p-2) var(--p-2) var(--p-2)
43
51
  display flex
44
52
  flex-direction column
45
53
  gap var(--p-3)
46
54
 
47
55
  .unfolded &
48
56
  background-color var(--page-color-alpha-800)
57
+
58
+ .content.contentHidden
59
+ .root.clear .content.contentHidden
60
+ display none
61
+
62
+ // No card chrome: used inside surfaces that already have a panel (e.g. a drawer).
63
+ .root.clear
64
+ border none
65
+ border-radius 0
66
+ background-color transparent
67
+ overflow visible
68
+
69
+ & + &
70
+ margin-top 0
71
+
72
+ .header
73
+ padding 0
74
+ background-color transparent
75
+
76
+ &:hover
77
+ background-color transparent
78
+
79
+ &.unfolded .header
80
+ background-color transparent
81
+
82
+ .content
83
+ padding 8px 0 0
84
+ background-color transparent
85
+
86
+ &.unfolded .content
87
+ background-color transparent
@@ -1,7 +1,9 @@
1
1
  // This file is automatically generated.
2
2
  // Please do not change this file!
3
3
  interface CssExports {
4
+ 'clear': string;
4
5
  'content': string;
6
+ 'contentHidden': string;
5
7
  'header': string;
6
8
  'headerContent': string;
7
9
  'icon': string;
@@ -11,6 +11,7 @@ export function Foldable({
11
11
  content,
12
12
  contentClassName,
13
13
  defaultUnfolded = false,
14
+ variant = 'default',
14
15
  }: FoldableProps) {
15
16
  const [isUnfolded, setIsUnfolded] = useState(defaultUnfolded);
16
17
 
@@ -19,20 +20,28 @@ export function Foldable({
19
20
  };
20
21
 
21
22
  return (
22
- <div className={cn(S.root, isUnfolded && S.unfolded)}>
23
- <div className={S.header} onClick={toggleFold}>
23
+ <div
24
+ className={cn(
25
+ S.root,
26
+ isUnfolded && S.unfolded,
27
+ variant === 'clear' && S.clear,
28
+ )}
29
+ >
30
+ <div className={S.header} onClick={toggleFold} aria-expanded={isUnfolded}>
24
31
  <div className={S.headerContent}>{header}</div>
25
32
  <div className={S.toggle}>
26
- {isUnfolded ? (
27
- <CaretUpIcon size={20} className={S.icon} />
28
- ) : (
29
- <CaretDownIcon size={20} className={S.icon} />
30
- )}
33
+ <CaretUpIcon size={20} className={S.icon} />
31
34
  </div>
32
35
  </div>
33
- {isUnfolded && (
34
- <div className={cn(S.content, contentClassName)}>{content}</div>
35
- )}
36
+ <div
37
+ className={cn(
38
+ S.content,
39
+ !isUnfolded && S.contentHidden,
40
+ contentClassName,
41
+ )}
42
+ >
43
+ {content}
44
+ </div>
36
45
  </div>
37
46
  );
38
47
  }
@@ -1,6 +1,10 @@
1
+ export type FoldableVariant = 'default' | 'clear';
2
+
1
3
  export interface FoldableProps {
2
4
  header: React.ReactNode;
3
5
  content: React.ReactNode;
4
6
  contentClassName?: string;
5
7
  defaultUnfolded?: boolean;
8
+ /** `clear` strips the card chrome (border, fill). Default keeps the framed panel. */
9
+ variant?: FoldableVariant;
6
10
  }
@@ -1,2 +1,2 @@
1
1
  export { Foldable } from './Foldable';
2
- export type { FoldableProps } from './Foldable.types';
2
+ export type { FoldableProps, FoldableVariant } from './Foldable.types';
@@ -16,12 +16,18 @@ export default function FoldablePage() {
16
16
  actions={<DocsHeaderActions />}
17
17
  />
18
18
  <DocsGuidance source={FoldableGuidance} />
19
- <PageContentSection>
19
+ <PageContentSection style={{ width: '300px' }}>
20
20
  <Foldable
21
21
  header={<span>Click to expand</span>}
22
22
  content={<p style={{ margin: 0 }}>Hidden content inside.</p>}
23
23
  defaultUnfolded
24
24
  />
25
+ <br />
26
+ <Foldable
27
+ header={<span>Clear variant</span>}
28
+ content={<p style={{ margin: 0 }}>Hidden content inside.</p>}
29
+ variant="clear"
30
+ />
25
31
  </PageContentSection>
26
32
  </>
27
33
  );