@gravity-ui/aikit 0.1.2 → 0.2.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.
@@ -18,10 +18,14 @@ export type SuggestionsProps = {
18
18
  items: SuggestionsItem[];
19
19
  /** Callback function called when a suggestion is clicked */
20
20
  onClick: (content: string, id?: string) => void | Promise<void>;
21
+ /** Title to display above suggestions */
22
+ title?: string;
21
23
  /** Layout orientation: 'grid' for horizontal, 'list' for vertical */
22
24
  layout?: 'grid' | 'list';
23
25
  /** Text alignment inside buttons: 'left', 'center', or 'right' */
24
26
  textAlign?: 'left' | 'center' | 'right';
27
+ /** Enable text wrapping inside buttons instead of ellipsis */
28
+ wrapText?: boolean;
25
29
  /** Additional CSS class */
26
30
  className?: string;
27
31
  /** QA/test identifier */
@@ -13,7 +13,7 @@ const b = block('suggestions');
13
13
  * @returns React component
14
14
  */
15
15
  export function Suggestions(props) {
16
- const { items, onClick, layout = 'list', textAlign = 'left', className, qa } = props;
16
+ const { items, onClick, title, layout = 'list', textAlign = 'left', wrapText = false, className, qa, } = props;
17
17
  const handleClick = (item) => {
18
18
  onClick(item.title, item.id);
19
19
  };
@@ -21,7 +21,7 @@ export function Suggestions(props) {
21
21
  return (_jsx(ActionButton, { tooltipTitle: item.title, size: "m", view: item.view || 'outlined', onClick: () => handleClick(item), className: b('button', { layout }), width: "auto", children: _jsxs("div", { className: b('button-content', {
22
22
  layout,
23
23
  'text-align': item.icon ? undefined : textAlign,
24
- }), children: [item.icon === 'left' && (_jsx("div", { className: b('button-icon'), children: _jsx(Icon, { data: ChevronLeft, size: 16 }) })), _jsx(Text, { as: "div", className: b('button-text'), children: item.title }), item.icon === 'right' && (_jsx("div", { className: b('button-icon'), children: _jsx(Icon, { data: ChevronRight, size: 16 }) }))] }) }, item.id || index));
24
+ }), children: [item.icon === 'left' && (_jsx("div", { className: b('button-icon'), children: _jsx(Icon, { data: ChevronLeft, size: 16 }) })), _jsx(Text, { as: "div", className: b(wrapText ? 'button-text-wrap' : 'button-text'), children: item.title }), item.icon === 'right' && (_jsx("div", { className: b('button-icon'), children: _jsx(Icon, { data: ChevronRight, size: 16 }) }))] }) }, item.id || index));
25
25
  };
26
- return (_jsx("div", { className: b({ layout }, className), "data-qa": qa, children: items.map((item, index) => renderButton(item, index)) }));
26
+ return (_jsxs("div", { className: b('container', className), "data-qa": qa, children: [title && (_jsx("div", { className: b('title'), children: _jsx(Text, { variant: "body-1", color: "primary", children: title }) })), _jsx("div", { className: b({ layout }), children: items.map((item, index) => renderButton(item, index)) })] }));
27
27
  }
@@ -4,6 +4,16 @@
4
4
  $block: '.#{variables.$ns}suggestions';
5
5
 
6
6
  #{$block} {
7
+ &__container {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: var(--g-spacing-2);
11
+ }
12
+
13
+ &__title {
14
+ padding-bottom: 0;
15
+ }
16
+
7
17
  display: flex;
8
18
  align-items: flex-start;
9
19
  align-content: flex-start;
@@ -62,6 +72,13 @@ $block: '.#{variables.$ns}suggestions';
62
72
  min-width: 0;
63
73
  }
64
74
 
75
+ &__button-text-wrap {
76
+ word-break: break-word;
77
+ white-space: normal;
78
+ min-width: 0;
79
+ text-align: left;
80
+ }
81
+
65
82
  &__button-icon {
66
83
  width: 16px;
67
84
  height: 16px;
@@ -10,7 +10,7 @@ const b = block('prompt-input');
10
10
  */
11
11
  export function PromptInputWithSuggestions(props) {
12
12
  const { children, suggestionsProps = {}, className, qa } = props;
13
- const { showSuggestions = false, suggestions, onSuggestionClick, suggestionsLayout, suggestionsTextAlign = 'center', } = suggestionsProps;
13
+ const { showSuggestions = false, suggestions, suggestTitle, onSuggestionClick, suggestionsLayout, suggestionsTextAlign = 'center', } = suggestionsProps;
14
14
  const hasSuggestions = showSuggestions && suggestions && suggestions.length > 0;
15
- return (_jsxs("div", { className: b('suggestions-wrapper', className), "data-qa": qa, children: [hasSuggestions && (_jsx("div", { className: b('suggestions'), children: _jsx(Suggestions, { items: suggestions, onClick: onSuggestionClick || (() => { }), layout: suggestionsLayout, textAlign: suggestionsTextAlign }) })), children] }));
15
+ return (_jsxs("div", { className: b('suggestions-wrapper', className), "data-qa": qa, children: [hasSuggestions && (_jsx("div", { className: b('suggestions'), children: _jsx(Suggestions, { items: suggestions, onClick: onSuggestionClick || (() => { }), title: suggestTitle, layout: suggestionsLayout, textAlign: suggestionsTextAlign }) })), children] }));
16
16
  }
@@ -63,6 +63,8 @@ export type PromptInputSuggestionsConfig = {
63
63
  suggestions?: SuggestionsItem[];
64
64
  /** Show submit suggestions */
65
65
  showSuggestions?: boolean;
66
+ /** Title for the suggestions section */
67
+ suggestTitle?: string;
66
68
  /** Layout orientation for suggestions: 'grid' for horizontal, 'list' for vertical */
67
69
  suggestionsLayout?: SuggestionsProps['layout'];
68
70
  /** Text alignment inside suggestion buttons */
@@ -20,5 +20,5 @@ const b = block('thinking-message');
20
20
  export const ThinkingMessage = (props) => {
21
21
  const { className, qa, style, onCopyClick } = props, data = __rest(props, ["className", "qa", "style", "onCopyClick"]);
22
22
  const { isExpanded, toggleExpanded, buttonTitle, content, showLoader } = useThinkingMessage(Object.assign({}, data));
23
- return (_jsxs("div", { className: b(null, className), "data-qa": qa, style: style, children: [_jsxs("div", { className: b('buttons'), children: [_jsxs(Button, { size: "s", onClick: toggleExpanded, children: [buttonTitle, _jsx(Icon, { data: isExpanded ? ChevronUp : ChevronDown })] }), showLoader ? (_jsx(Loader, { view: "loading", size: "xs" })) : (onCopyClick && (_jsx(ActionButton, { size: "s", onClick: onCopyClick, children: _jsx(Icon, { data: Copy, size: 16 }) })))] }), isExpanded && (_jsx("div", { className: b('container'), children: content.map((item) => (_jsx(Text, { className: b('content'), children: item }, item))) }))] }));
23
+ return (_jsxs("div", { className: b(null, className), "data-qa": qa, style: style, children: [_jsxs("div", { className: b('buttons'), children: [_jsxs(Button, { size: "s", onClick: toggleExpanded, children: [buttonTitle, _jsx(Icon, { data: isExpanded ? ChevronUp : ChevronDown })] }), showLoader ? (_jsx(Loader, { view: "loading", size: "xs" })) : (onCopyClick && (_jsx(ActionButton, { size: "s", onClick: onCopyClick, children: _jsx(Icon, { data: Copy, size: 16 }) })))] }), isExpanded && (_jsx("div", { className: b('container'), children: content.map((item, index) => (_jsx(Text, { className: b('content'), children: item }, index))) }))] }));
24
24
  };
@@ -5,8 +5,8 @@
5
5
  flex-direction: column;
6
6
  height: 100%;
7
7
  width: 100%;
8
- background-color: var(--g-color-base-background);
9
8
  overflow: hidden;
9
+ background: var(--g-aikit-chat-container-background);
10
10
 
11
11
  &__header {
12
12
  display: flex;
@@ -15,6 +15,7 @@
15
15
  align-items: flex-start;
16
16
  gap: var(--g-spacing-2);
17
17
  align-self: stretch;
18
+ background: var(--g-aikit-chat-container-header-background);
18
19
  }
19
20
 
20
21
  &__content {
@@ -23,6 +24,7 @@
23
24
  flex-direction: column;
24
25
  align-items: flex-start;
25
26
  align-self: stretch;
27
+ background: var(--g-aikit-chat-container-content-background);
26
28
 
27
29
  padding: 0 var(--g-aikit-layout-base-padding-m) var(--g-spacing-4)
28
30
  var(--g-aikit-layout-base-padding-m);
@@ -37,5 +39,6 @@
37
39
  align-items: flex-start;
38
40
  gap: var(--g-spacing-1);
39
41
  align-self: stretch;
42
+ background: var(--g-aikit-chat-container-footer-background);
40
43
  }
41
44
  }
@@ -5,7 +5,7 @@
5
5
  flex-direction: column;
6
6
  height: 100%;
7
7
  width: 100%;
8
- background-color: var(--g-aikit-empty-container-background);
8
+ background: var(--g-aikit-empty-container-background);
9
9
 
10
10
  &__content {
11
11
  flex: 1;
@@ -60,4 +60,10 @@
60
60
  --g-aikit-chat-content-background: var(--g-color-base-background);
61
61
  --g-aikit-chat-content-padding: 0 var(--g-aikit-layout-base-padding-m) var(--g-spacing-4)
62
62
  var(--g-aikit-layout-base-padding-m);
63
+
64
+ /* === Chat Container === */
65
+ --g-aikit-chat-container-header-background: var(--g-color-base-background);
66
+ --g-aikit-chat-container-content-background: var(--g-color-base-background);
67
+ --g-aikit-chat-container-footer-background: var(--g-color-base-background);
68
+ --g-aikit-chat-container-background: var(--g-color-base-background);
63
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/aikit",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Gravity UI base kit for building ai assistant chats",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",