@patternfly/chatbot 6.5.0-prerelease.2 → 6.5.0-prerelease.4

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 (40) hide show
  1. package/dist/cjs/AttachMenu/AttachMenu.d.ts +7 -1
  2. package/dist/cjs/AttachMenu/AttachMenu.js +2 -2
  3. package/dist/cjs/ChatbotFooter/ChatbotFooter.d.ts +5 -2
  4. package/dist/cjs/ChatbotFooter/ChatbotFooter.js +2 -2
  5. package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +5 -1
  6. package/dist/cjs/Message/Message.d.ts +1 -0
  7. package/dist/cjs/Message/Message.js +4 -1
  8. package/dist/cjs/MessageBar/MessageBar.d.ts +9 -1
  9. package/dist/cjs/MessageBar/MessageBar.js +3 -3
  10. package/dist/cjs/MessageBar/MessageBar.test.js +37 -0
  11. package/dist/cjs/__mocks__/rehype-highlight.d.ts +2 -0
  12. package/dist/cjs/__mocks__/rehype-highlight.js +4 -0
  13. package/dist/css/main.css +6 -0
  14. package/dist/css/main.css.map +1 -1
  15. package/dist/esm/AttachMenu/AttachMenu.d.ts +7 -1
  16. package/dist/esm/AttachMenu/AttachMenu.js +2 -2
  17. package/dist/esm/ChatbotFooter/ChatbotFooter.d.ts +5 -2
  18. package/dist/esm/ChatbotFooter/ChatbotFooter.js +2 -2
  19. package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +5 -1
  20. package/dist/esm/Message/Message.d.ts +1 -0
  21. package/dist/esm/Message/Message.js +4 -1
  22. package/dist/esm/MessageBar/MessageBar.d.ts +9 -1
  23. package/dist/esm/MessageBar/MessageBar.js +3 -3
  24. package/dist/esm/MessageBar/MessageBar.test.js +37 -0
  25. package/dist/esm/__mocks__/rehype-highlight.d.ts +2 -0
  26. package/dist/esm/__mocks__/rehype-highlight.js +2 -0
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +2 -1
  29. package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +12 -4
  30. package/patternfly-docs/content/extensions/chatbot/examples/demos/WhiteEmbeddedChatbot.tsx +437 -0
  31. package/patternfly-docs/patternfly-docs.config.js +1 -0
  32. package/src/AttachMenu/AttachMenu.tsx +16 -3
  33. package/src/ChatbotFooter/ChatbotFooter.scss +4 -0
  34. package/src/ChatbotFooter/ChatbotFooter.test.tsx +10 -1
  35. package/src/ChatbotFooter/ChatbotFooter.tsx +10 -3
  36. package/src/Message/Message.tsx +4 -1
  37. package/src/MessageBar/MessageBar.scss +4 -0
  38. package/src/MessageBar/MessageBar.test.tsx +62 -1
  39. package/src/MessageBar/MessageBar.tsx +24 -2
  40. package/src/__mocks__/rehype-highlight.ts +3 -0
@@ -1,5 +1,11 @@
1
1
  import '@testing-library/jest-dom';
2
- import { DropdownGroup, DropdownItem, DropdownList } from '@patternfly/react-core';
2
+ import {
3
+ DropdownGroup,
4
+ DropdownItem,
5
+ DropdownList,
6
+ MenuSearchInputProps,
7
+ MenuSearchProps
8
+ } from '@patternfly/react-core';
3
9
  import { BellIcon, CalendarAltIcon, ClipboardIcon, CodeIcon } from '@patternfly/react-icons';
4
10
  import { render, screen } from '@testing-library/react';
5
11
  import userEvent from '@testing-library/user-event';
@@ -218,6 +224,57 @@ describe('Message bar', () => {
218
224
  await userEvent.click(attachButton);
219
225
  expect(attachToggleClickSpy).toHaveBeenCalledTimes(1);
220
226
  });
227
+ it('can pass searchInputProps to search input in AttachMenu', () => {
228
+ render(
229
+ <MessageBar
230
+ onSendMessage={jest.fn}
231
+ value="test"
232
+ attachMenuProps={{
233
+ isAttachMenuOpen: true,
234
+ setIsAttachMenuOpen: jest.fn(),
235
+ onAttachMenuToggleClick: jest.fn(),
236
+ onAttachMenuInputChange: jest.fn(),
237
+ attachMenuItems: ATTACH_MENU_ITEMS,
238
+ searchInputProps: { isDisabled: true }
239
+ }}
240
+ />
241
+ );
242
+ expect(screen.getByRole('textbox', { name: /Filter menu items/i })).toBeDisabled();
243
+ });
244
+ it('can pass menuSearchProps to search input in AttachMenu', () => {
245
+ render(
246
+ <MessageBar
247
+ onSendMessage={jest.fn}
248
+ value="test"
249
+ attachMenuProps={{
250
+ isAttachMenuOpen: true,
251
+ setIsAttachMenuOpen: jest.fn(),
252
+ onAttachMenuToggleClick: jest.fn(),
253
+ onAttachMenuInputChange: jest.fn(),
254
+ attachMenuItems: ATTACH_MENU_ITEMS,
255
+ menuSearchProps: { 'data-testid': 'menu-search' } as MenuSearchProps
256
+ }}
257
+ />
258
+ );
259
+ expect(screen.getByTestId('menu-search')).toBeTruthy();
260
+ });
261
+ it('can pass menuSearchInputProps to search input in AttachMenu', () => {
262
+ render(
263
+ <MessageBar
264
+ onSendMessage={jest.fn}
265
+ value="test"
266
+ attachMenuProps={{
267
+ isAttachMenuOpen: true,
268
+ setIsAttachMenuOpen: jest.fn(),
269
+ onAttachMenuToggleClick: jest.fn(),
270
+ onAttachMenuInputChange: jest.fn(),
271
+ attachMenuItems: ATTACH_MENU_ITEMS,
272
+ menuSearchInputProps: { 'data-testid': 'menu-search-input' } as MenuSearchInputProps
273
+ }}
274
+ />
275
+ );
276
+ expect(screen.getByTestId('menu-search-input')).toBeTruthy();
277
+ });
221
278
  it('can hide attach button', () => {
222
279
  render(<MessageBar onSendMessage={jest.fn} hasAttachButton={false} />);
223
280
  expect(screen.queryByRole('button', { name: 'Attach' })).toBeFalsy();
@@ -387,4 +444,8 @@ describe('Message bar', () => {
387
444
  ref.current?.focus();
388
445
  expect(document.activeElement).toBe(screen.getByRole('textbox'));
389
446
  });
447
+ it('should handle isPrimary', () => {
448
+ const { container } = render(<MessageBar isPrimary onSendMessage={jest.fn} />);
449
+ expect(container.querySelector('.pf-m-primary')).toBeTruthy();
450
+ });
390
451
  });
@@ -1,7 +1,15 @@
1
1
  import type { ChangeEvent, FunctionComponent, KeyboardEvent as ReactKeyboardEvent, Ref } from 'react';
2
2
  import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { Accept, DropEvent, DropzoneOptions, FileError, FileRejection } from 'react-dropzone';
4
- import { ButtonProps, TextArea, TextAreaProps, TooltipProps } from '@patternfly/react-core';
4
+ import {
5
+ ButtonProps,
6
+ MenuSearchInputProps,
7
+ MenuSearchProps,
8
+ SearchInputProps,
9
+ TextArea,
10
+ TextAreaProps,
11
+ TooltipProps
12
+ } from '@patternfly/react-core';
5
13
 
6
14
  // Import Chatbot components
7
15
  import SendButton from './SendButton';
@@ -30,6 +38,12 @@ export interface MessageBarWithAttachMenuProps {
30
38
  onAttachMenuOnOpenChangeKeys?: string[];
31
39
  /** Callback to change the open state of the menu. Triggered by clicking outside of the menu. */
32
40
  onAttachMenuOpenChange?: (isOpen: boolean) => void;
41
+ /** Additional props passed to MenuSearch component in attach menu */
42
+ menuSearchProps?: Omit<MenuSearchProps, 'ref'>;
43
+ /** Additional props passed to MenuSearchInput component in attach menu */
44
+ menuSearchInputProps?: Omit<MenuSearchInputProps, 'ref'>;
45
+ /** Additional props passed to SearchInput component in attach menu */
46
+ searchInputProps?: SearchInputProps;
33
47
  }
34
48
 
35
49
  export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
@@ -104,6 +118,8 @@ export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
104
118
  isCompact?: boolean;
105
119
  /** Ref applied to message bar textarea, for use with focus or other custom behaviors */
106
120
  innerRef?: React.Ref<HTMLTextAreaElement>;
121
+ /** Sets background color to primary */
122
+ isPrimary?: boolean;
107
123
  }
108
124
 
109
125
  export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
@@ -134,6 +150,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
134
150
  validator,
135
151
  dropzoneProps,
136
152
  innerRef,
153
+ isPrimary,
137
154
  ...props
138
155
  }: MessageBarProps) => {
139
156
  // Text Input
@@ -449,11 +466,16 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
449
466
  {...(attachMenuProps && { handleTextInputChange: attachMenuProps.onAttachMenuInputChange })}
450
467
  popperProps={{ direction: 'up', distance: 8 }}
451
468
  searchInputPlaceholder={attachMenuProps?.attachMenuInputPlaceholder}
469
+ {...attachMenuProps}
452
470
  />
453
471
  );
454
472
  }
455
473
 
456
- return <div className={`pf-chatbot__message-bar ${className ?? ''}`}>{messageBarContents}</div>;
474
+ return (
475
+ <div className={`pf-chatbot__message-bar ${isPrimary ? 'pf-m-primary' : ''} ${className ?? ''}`}>
476
+ {messageBarContents}
477
+ </div>
478
+ );
457
479
  };
458
480
 
459
481
  const MessageBar = forwardRef((props: MessageBarProps, ref: Ref<HTMLTextAreaElement>) => (
@@ -0,0 +1,3 @@
1
+ const rehypeHighlight = () => (tree) => tree;
2
+
3
+ export default rehypeHighlight;