@patternfly/chatbot 2.2.0-prerelease.28 → 2.2.0-prerelease.29

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.
@@ -7,6 +7,7 @@ import QuickResponse from './QuickResponse/QuickResponse';
7
7
  import { UserFeedbackProps } from './UserFeedback/UserFeedback';
8
8
  import { UserFeedbackCompleteProps } from './UserFeedback/UserFeedbackComplete';
9
9
  import { TableProps } from '@patternfly/react-table';
10
+ import { PluggableList } from 'react-markdown/lib';
10
11
  export interface MessageAttachment {
11
12
  /** Name of file attached to the message */
12
13
  name: string;
@@ -97,6 +98,8 @@ export interface MessageProps extends Omit<React.HTMLProps<HTMLDivElement>, 'rol
97
98
  innerRef?: React.Ref<HTMLDivElement>;
98
99
  /** Props for table message. It is important to include a detailed aria-label that describes the purpose of the table. */
99
100
  tableProps?: Required<Pick<TableProps, 'aria-label'>> & TableProps;
101
+ /** Additional rehype plugins passed from the consumer */
102
+ additionalRehypePlugins?: PluggableList;
100
103
  }
101
104
  export declare const MessageBase: React.FunctionComponent<MessageProps>;
102
105
  declare const Message: React.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -44,7 +44,7 @@ const ThMessage_1 = __importDefault(require("./TableMessage/ThMessage"));
44
44
  const ImageMessage_1 = __importDefault(require("./ImageMessage/ImageMessage"));
45
45
  const rehype_unwrap_images_1 = __importDefault(require("rehype-unwrap-images"));
46
46
  const MessageBase = (_a) => {
47
- var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps"]);
47
+ var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps, additionalRehypePlugins = [] } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "additionalRehypePlugins"]);
48
48
  const { beforeMainContent, afterMainContent, endContent } = extraContent || {};
49
49
  let avatarClassName;
50
50
  if (avatarProps && 'className' in avatarProps) {
@@ -55,6 +55,7 @@ const MessageBase = (_a) => {
55
55
  // Keep timestamps consistent between Timestamp component and aria-label
56
56
  const date = new Date();
57
57
  const dateString = timestamp !== null && timestamp !== void 0 ? timestamp : `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
58
+ const rehypePlugins = [rehype_unwrap_images_1.default, ...(additionalRehypePlugins !== null && additionalRehypePlugins !== void 0 ? additionalRehypePlugins : [])];
58
59
  return (react_1.default.createElement("section", Object.assign({ "aria-label": `Message from ${role} - ${dateString}`, className: `pf-chatbot__message pf-chatbot__message--${role}`, "aria-live": isLiveRegion ? 'polite' : undefined, "aria-atomic": isLiveRegion ? false : undefined, ref: innerRef }, props),
59
60
  react_1.default.createElement(react_core_1.Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps)),
60
61
  react_1.default.createElement("div", { className: "pf-chatbot__message-contents" },
@@ -95,7 +96,7 @@ const MessageBase = (_a) => {
95
96
  },
96
97
  th: (props) => react_1.default.createElement(ThMessage_1.default, Object.assign({}, props)),
97
98
  img: (props) => react_1.default.createElement(ImageMessage_1.default, Object.assign({}, props))
98
- }, remarkPlugins: [remark_gfm_1.default], rehypePlugins: [rehype_unwrap_images_1.default] }, content),
99
+ }, remarkPlugins: [remark_gfm_1.default], rehypePlugins: rehypePlugins }, content),
99
100
  afterMainContent && react_1.default.createElement(react_1.default.Fragment, null, afterMainContent))),
100
101
  !isLoading && sources && react_1.default.createElement(SourcesCard_1.default, Object.assign({}, sources)),
101
102
  quickStarts && quickStarts.quickStart && (react_1.default.createElement(QuickStartTile_1.default, { quickStart: quickStarts.quickStart, onSelectQuickStart: quickStarts.onSelectQuickStart, minuteWord: quickStarts.minuteWord, minuteWordPlural: quickStarts.minuteWordPlural, prerequisiteWord: quickStarts.prerequisiteWord, prerequisiteWordPlural: quickStarts.prerequisiteWordPlural, quickStartButtonAriaLabel: quickStarts.quickStartButtonAriaLabel })),
@@ -7,6 +7,7 @@ import QuickResponse from './QuickResponse/QuickResponse';
7
7
  import { UserFeedbackProps } from './UserFeedback/UserFeedback';
8
8
  import { UserFeedbackCompleteProps } from './UserFeedback/UserFeedbackComplete';
9
9
  import { TableProps } from '@patternfly/react-table';
10
+ import { PluggableList } from 'react-markdown/lib';
10
11
  export interface MessageAttachment {
11
12
  /** Name of file attached to the message */
12
13
  name: string;
@@ -97,6 +98,8 @@ export interface MessageProps extends Omit<React.HTMLProps<HTMLDivElement>, 'rol
97
98
  innerRef?: React.Ref<HTMLDivElement>;
98
99
  /** Props for table message. It is important to include a detailed aria-label that describes the purpose of the table. */
99
100
  tableProps?: Required<Pick<TableProps, 'aria-label'>> & TableProps;
101
+ /** Additional rehype plugins passed from the consumer */
102
+ additionalRehypePlugins?: PluggableList;
100
103
  }
101
104
  export declare const MessageBase: React.FunctionComponent<MessageProps>;
102
105
  declare const Message: React.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -38,7 +38,7 @@ import ThMessage from './TableMessage/ThMessage';
38
38
  import ImageMessage from './ImageMessage/ImageMessage';
39
39
  import rehypeUnwrapImages from 'rehype-unwrap-images';
40
40
  export const MessageBase = (_a) => {
41
- var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps"]);
41
+ var { role, content, extraContent, name, avatar, timestamp, isLoading, actions, sources, botWord = 'AI', loadingWord = 'Loading message', codeBlockProps, quickResponses, quickResponseContainerProps = { numLabels: 5 }, attachments, hasRoundAvatar = true, avatarProps, quickStarts, userFeedbackForm, userFeedbackComplete, isLiveRegion = true, innerRef, tableProps, additionalRehypePlugins = [] } = _a, props = __rest(_a, ["role", "content", "extraContent", "name", "avatar", "timestamp", "isLoading", "actions", "sources", "botWord", "loadingWord", "codeBlockProps", "quickResponses", "quickResponseContainerProps", "attachments", "hasRoundAvatar", "avatarProps", "quickStarts", "userFeedbackForm", "userFeedbackComplete", "isLiveRegion", "innerRef", "tableProps", "additionalRehypePlugins"]);
42
42
  const { beforeMainContent, afterMainContent, endContent } = extraContent || {};
43
43
  let avatarClassName;
44
44
  if (avatarProps && 'className' in avatarProps) {
@@ -49,6 +49,7 @@ export const MessageBase = (_a) => {
49
49
  // Keep timestamps consistent between Timestamp component and aria-label
50
50
  const date = new Date();
51
51
  const dateString = timestamp !== null && timestamp !== void 0 ? timestamp : `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
52
+ const rehypePlugins = [rehypeUnwrapImages, ...(additionalRehypePlugins !== null && additionalRehypePlugins !== void 0 ? additionalRehypePlugins : [])];
52
53
  return (React.createElement("section", Object.assign({ "aria-label": `Message from ${role} - ${dateString}`, className: `pf-chatbot__message pf-chatbot__message--${role}`, "aria-live": isLiveRegion ? 'polite' : undefined, "aria-atomic": isLiveRegion ? false : undefined, ref: innerRef }, props),
53
54
  React.createElement(Avatar, Object.assign({ className: `pf-chatbot__message-avatar ${hasRoundAvatar ? 'pf-chatbot__message-avatar--round' : ''} ${avatarClassName ? avatarClassName : ''}`, src: avatar, alt: "" }, avatarProps)),
54
55
  React.createElement("div", { className: "pf-chatbot__message-contents" },
@@ -89,7 +90,7 @@ export const MessageBase = (_a) => {
89
90
  },
90
91
  th: (props) => React.createElement(ThMessage, Object.assign({}, props)),
91
92
  img: (props) => React.createElement(ImageMessage, Object.assign({}, props))
92
- }, remarkPlugins: [remarkGfm], rehypePlugins: [rehypeUnwrapImages] }, content),
93
+ }, remarkPlugins: [remarkGfm], rehypePlugins: rehypePlugins }, content),
93
94
  afterMainContent && React.createElement(React.Fragment, null, afterMainContent))),
94
95
  !isLoading && sources && React.createElement(SourcesCard, Object.assign({}, sources)),
95
96
  quickStarts && quickStarts.quickStart && (React.createElement(QuickStartTile, { quickStart: quickStarts.quickStart, onSelectQuickStart: quickStarts.onSelectQuickStart, minuteWord: quickStarts.minuteWord, minuteWordPlural: quickStarts.minuteWordPlural, prerequisiteWord: quickStarts.prerequisiteWord, prerequisiteWordPlural: quickStarts.prerequisiteWordPlural, quickStartButtonAriaLabel: quickStarts.quickStartButtonAriaLabel })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/chatbot",
3
- "version": "2.2.0-prerelease.28",
3
+ "version": "2.2.0-prerelease.29",
4
4
  "description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -38,6 +38,7 @@ import ThMessage from './TableMessage/ThMessage';
38
38
  import { TableProps } from '@patternfly/react-table';
39
39
  import ImageMessage from './ImageMessage/ImageMessage';
40
40
  import rehypeUnwrapImages from 'rehype-unwrap-images';
41
+ import { PluggableList } from 'react-markdown/lib';
41
42
 
42
43
  export interface MessageAttachment {
43
44
  /** Name of file attached to the message */
@@ -133,6 +134,8 @@ export interface MessageProps extends Omit<React.HTMLProps<HTMLDivElement>, 'rol
133
134
  innerRef?: React.Ref<HTMLDivElement>;
134
135
  /** Props for table message. It is important to include a detailed aria-label that describes the purpose of the table. */
135
136
  tableProps?: Required<Pick<TableProps, 'aria-label'>> & TableProps;
137
+ /** Additional rehype plugins passed from the consumer */
138
+ additionalRehypePlugins?: PluggableList;
136
139
  }
137
140
 
138
141
  export const MessageBase: React.FunctionComponent<MessageProps> = ({
@@ -159,6 +162,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
159
162
  isLiveRegion = true,
160
163
  innerRef,
161
164
  tableProps,
165
+ additionalRehypePlugins = [],
162
166
  ...props
163
167
  }: MessageProps) => {
164
168
  const { beforeMainContent, afterMainContent, endContent } = extraContent || {};
@@ -171,6 +175,9 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
171
175
  // Keep timestamps consistent between Timestamp component and aria-label
172
176
  const date = new Date();
173
177
  const dateString = timestamp ?? `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
178
+
179
+ const rehypePlugins = [rehypeUnwrapImages, ...(additionalRehypePlugins ?? [])];
180
+
174
181
  return (
175
182
  <section
176
183
  aria-label={`Message from ${role} - ${dateString}`}
@@ -240,7 +247,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
240
247
  img: (props) => <ImageMessage {...props} />
241
248
  }}
242
249
  remarkPlugins={[remarkGfm]}
243
- rehypePlugins={[rehypeUnwrapImages]}
250
+ rehypePlugins={rehypePlugins}
244
251
  >
245
252
  {content}
246
253
  </Markdown>