@patternfly/chatbot 6.4.0-prerelease.7 → 6.4.0-prerelease.8

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.
@@ -9,6 +9,8 @@ export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownPr
9
9
  label?: string;
10
10
  /** Callback for when user selects item. */
11
11
  onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
12
+ /** Id applied to dropdown menu toggle */
13
+ id?: string;
12
14
  }
13
15
  export declare const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConversationHistoryDropdownProps>;
14
16
  export default ChatbotConversationHistoryDropdown;
@@ -9,11 +9,11 @@ const react_1 = require("react");
9
9
  // Import PatternFly components
10
10
  const react_core_1 = require("@patternfly/react-core");
11
11
  const ellipsis_v_icon_1 = __importDefault(require("@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon"));
12
- const ChatbotConversationHistoryDropdown = ({ menuItems, menuClassName, onSelect, label }) => {
12
+ const ChatbotConversationHistoryDropdown = ({ menuItems, menuClassName, onSelect, label, id }) => {
13
13
  const [isOpen, setIsOpen] = (0, react_1.useState)(false);
14
14
  const toggle = (toggleRef) => ((0, jsx_runtime_1.jsx)(react_core_1.Tooltip, { className: "pf-chatbot__tooltip", content: label !== null && label !== void 0 ? label : 'Conversation options', position: "bottom",
15
15
  // prevents VO announcements of both aria label and tooltip
16
- aria: "none", children: (0, jsx_runtime_1.jsx)(react_core_1.MenuToggle, { className: "pf-chatbot__history-actions", variant: "plain", "aria-label": label !== null && label !== void 0 ? label : 'Conversation options', ref: toggleRef, isExpanded: isOpen, onClick: () => setIsOpen(!isOpen), children: (0, jsx_runtime_1.jsx)(ellipsis_v_icon_1.default, {}) }) }));
16
+ aria: "none", children: (0, jsx_runtime_1.jsx)(react_core_1.MenuToggle, { className: "pf-chatbot__history-actions", variant: "plain", "aria-label": label !== null && label !== void 0 ? label : 'Conversation options', ref: toggleRef, isExpanded: isOpen, onClick: () => setIsOpen(!isOpen), id: id, children: (0, jsx_runtime_1.jsx)(ellipsis_v_icon_1.default, {}) }) }));
17
17
  return ((0, jsx_runtime_1.jsx)(react_core_1.Dropdown, { className: `pf-chatbot__selections ${menuClassName !== null && menuClassName !== void 0 ? menuClassName : ''}`, isOpen: isOpen, onSelect: (props) => {
18
18
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(props);
19
19
  setIsOpen((prev) => !prev);
@@ -24,6 +24,8 @@ export interface Conversation {
24
24
  additionalProps?: ButtonProps;
25
25
  /** Additional props passed to conversation list item */
26
26
  listItemProps?: Omit<ListItemProps, 'children'>;
27
+ /** Custom dropdown ID to ensure uniqueness across demo instances */
28
+ dropdownId?: string;
27
29
  }
28
30
  export interface ChatbotConversationHistoryNavProps extends DrawerProps {
29
31
  /** Function called to toggle drawer */
@@ -32,7 +32,7 @@ const ChatbotConversationHistoryNav = (_a) => {
32
32
  };
33
33
  const getNavItem = (conversation) => {
34
34
  var _a;
35
- return ((0, jsx_runtime_1.jsx)(react_core_1.ListItem, Object.assign({ className: `pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}` }, conversation.listItemProps, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Button, Object.assign({ className: "pf-chatbot__conversation-history-item", variant: "link" }, conversation.additionalProps, (conversation.noIcon ? {} : { icon: (_a = conversation.icon) !== null && _a !== void 0 ? _a : (0, jsx_runtime_1.jsx)(react_icons_1.OutlinedCommentAltIcon, {}) }), { onClick: (event) => onSelectActiveItem === null || onSelectActiveItem === void 0 ? void 0 : onSelectActiveItem(event, conversation.id), children: conversation.text })), conversation.menuItems && ((0, jsx_runtime_1.jsx)(ChatbotConversationHistoryDropdown_1.default, { menuClassName: conversation.menuClassName, onSelect: conversation.onSelect, menuItems: conversation.menuItems, label: conversation.label }))] }) }), conversation.id));
35
+ return ((0, jsx_runtime_1.jsx)(react_core_1.ListItem, Object.assign({ className: `pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}` }, conversation.listItemProps, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Button, Object.assign({ className: "pf-chatbot__conversation-history-item", variant: "link" }, conversation.additionalProps, (conversation.noIcon ? {} : { icon: (_a = conversation.icon) !== null && _a !== void 0 ? _a : (0, jsx_runtime_1.jsx)(react_icons_1.OutlinedCommentAltIcon, {}) }), { onClick: (event) => onSelectActiveItem === null || onSelectActiveItem === void 0 ? void 0 : onSelectActiveItem(event, conversation.id), children: conversation.text })), conversation.menuItems && ((0, jsx_runtime_1.jsx)(ChatbotConversationHistoryDropdown_1.default, { menuClassName: conversation.menuClassName, onSelect: conversation.onSelect, menuItems: conversation.menuItems, label: conversation.label, id: conversation.dropdownId }))] }) }), conversation.id));
36
36
  };
37
37
  const buildConversations = () => {
38
38
  if (Array.isArray(conversations)) {
@@ -9,6 +9,8 @@ export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownPr
9
9
  label?: string;
10
10
  /** Callback for when user selects item. */
11
11
  onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
12
+ /** Id applied to dropdown menu toggle */
13
+ id?: string;
12
14
  }
13
15
  export declare const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConversationHistoryDropdownProps>;
14
16
  export default ChatbotConversationHistoryDropdown;
@@ -3,11 +3,11 @@ import { useState } from 'react';
3
3
  // Import PatternFly components
4
4
  import { Tooltip, MenuToggle, Dropdown } from '@patternfly/react-core';
5
5
  import EllipsisIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
6
- export const ChatbotConversationHistoryDropdown = ({ menuItems, menuClassName, onSelect, label }) => {
6
+ export const ChatbotConversationHistoryDropdown = ({ menuItems, menuClassName, onSelect, label, id }) => {
7
7
  const [isOpen, setIsOpen] = useState(false);
8
8
  const toggle = (toggleRef) => (_jsx(Tooltip, { className: "pf-chatbot__tooltip", content: label !== null && label !== void 0 ? label : 'Conversation options', position: "bottom",
9
9
  // prevents VO announcements of both aria label and tooltip
10
- aria: "none", children: _jsx(MenuToggle, { className: "pf-chatbot__history-actions", variant: "plain", "aria-label": label !== null && label !== void 0 ? label : 'Conversation options', ref: toggleRef, isExpanded: isOpen, onClick: () => setIsOpen(!isOpen), children: _jsx(EllipsisIcon, {}) }) }));
10
+ aria: "none", children: _jsx(MenuToggle, { className: "pf-chatbot__history-actions", variant: "plain", "aria-label": label !== null && label !== void 0 ? label : 'Conversation options', ref: toggleRef, isExpanded: isOpen, onClick: () => setIsOpen(!isOpen), id: id, children: _jsx(EllipsisIcon, {}) }) }));
11
11
  return (_jsx(Dropdown, { className: `pf-chatbot__selections ${menuClassName !== null && menuClassName !== void 0 ? menuClassName : ''}`, isOpen: isOpen, onSelect: (props) => {
12
12
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(props);
13
13
  setIsOpen((prev) => !prev);
@@ -24,6 +24,8 @@ export interface Conversation {
24
24
  additionalProps?: ButtonProps;
25
25
  /** Additional props passed to conversation list item */
26
26
  listItemProps?: Omit<ListItemProps, 'children'>;
27
+ /** Custom dropdown ID to ensure uniqueness across demo instances */
28
+ dropdownId?: string;
27
29
  }
28
30
  export interface ChatbotConversationHistoryNavProps extends DrawerProps {
29
31
  /** Function called to toggle drawer */
@@ -26,7 +26,7 @@ export const ChatbotConversationHistoryNav = (_a) => {
26
26
  };
27
27
  const getNavItem = (conversation) => {
28
28
  var _a;
29
- return (_jsx(ListItem, Object.assign({ className: `pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}` }, conversation.listItemProps, { children: _jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ className: "pf-chatbot__conversation-history-item", variant: "link" }, conversation.additionalProps, (conversation.noIcon ? {} : { icon: (_a = conversation.icon) !== null && _a !== void 0 ? _a : _jsx(OutlinedCommentAltIcon, {}) }), { onClick: (event) => onSelectActiveItem === null || onSelectActiveItem === void 0 ? void 0 : onSelectActiveItem(event, conversation.id), children: conversation.text })), conversation.menuItems && (_jsx(ConversationHistoryDropdown, { menuClassName: conversation.menuClassName, onSelect: conversation.onSelect, menuItems: conversation.menuItems, label: conversation.label }))] }) }), conversation.id));
29
+ return (_jsx(ListItem, Object.assign({ className: `pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}` }, conversation.listItemProps, { children: _jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ className: "pf-chatbot__conversation-history-item", variant: "link" }, conversation.additionalProps, (conversation.noIcon ? {} : { icon: (_a = conversation.icon) !== null && _a !== void 0 ? _a : _jsx(OutlinedCommentAltIcon, {}) }), { onClick: (event) => onSelectActiveItem === null || onSelectActiveItem === void 0 ? void 0 : onSelectActiveItem(event, conversation.id), children: conversation.text })), conversation.menuItems && (_jsx(ConversationHistoryDropdown, { menuClassName: conversation.menuClassName, onSelect: conversation.onSelect, menuItems: conversation.menuItems, label: conversation.label, id: conversation.dropdownId }))] }) }), conversation.id));
30
30
  };
31
31
  const buildConversations = () => {
32
32
  if (Array.isArray(conversations)) {
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@patternfly/chatbot",
3
- "version": "6.4.0-prerelease.7",
3
+ "version": "6.4.0-prerelease.8",
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",
7
7
  "scripts": {
8
- "build": "sass src/main.scss dist/css/main.css && npm run build:index && npm run build:js && npm run build:esm && npm run build:fed:packages",
8
+ "build": "npm run build:css && npm run build:index && npm run build:js && npm run build:esm && npm run build:fed:packages",
9
9
  "build:watch": "npm run build:js && npm run build:esm -- --watch && npm run build:fed:packages -- --watch",
10
10
  "build:esm": "tsc --build --verbose ./tsconfig.json",
11
11
  "build:fed:packages": "node generate-fed-package-json.js",
12
12
  "build:js": "tsc -p tsconfig.cjs.json",
13
13
  "build:index": "node generate-index.js",
14
+ "build:css": "sass src/main.scss dist/css/main.css",
15
+ "build:css:watch": "sass src/main.scss dist/css/main.css --watch",
14
16
  "clean": "rimraf dist",
15
17
  "docs:develop": "pf-docs-framework start",
16
18
  "docs:build": "pf-docs-framework build all --output public",
@@ -97,6 +97,14 @@ export const ChatbotHeaderPinDemo: FunctionComponent = () => {
97
97
  }
98
98
  return newPinned;
99
99
  });
100
+
101
+ // Focus the conversation input after pin/unpin action
102
+ setTimeout(() => {
103
+ const dropdown = document.getElementById(`pin-demo-${conversationId}-dropdown`);
104
+ if (dropdown) {
105
+ dropdown.focus();
106
+ }
107
+ }, 100);
100
108
  };
101
109
 
102
110
  const createMenuItems = (conversationId: string) => {
@@ -136,7 +144,8 @@ export const ChatbotHeaderPinDemo: FunctionComponent = () => {
136
144
  pinnedItems.push({
137
145
  ...conv,
138
146
  menuItems: createMenuItems(conv.id),
139
- icon: <ThumbtackIcon />
147
+ icon: <ThumbtackIcon />,
148
+ dropdownId: `pin-demo-${conv.id}-dropdown`
140
149
  });
141
150
  }
142
151
  });
@@ -153,7 +162,8 @@ export const ChatbotHeaderPinDemo: FunctionComponent = () => {
153
162
  .filter((conv) => !pinnedConversations.has(conv.id))
154
163
  .map((conv) => ({
155
164
  ...conv,
156
- menuItems: createMenuItems(conv.id)
165
+ menuItems: createMenuItems(conv.id),
166
+ dropdownId: `pin-demo-${conv.id}-dropdown`
157
167
  }));
158
168
 
159
169
  if (unpinnedConversations.length > 0) {
@@ -19,13 +19,16 @@ export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownPr
19
19
  label?: string;
20
20
  /** Callback for when user selects item. */
21
21
  onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
22
+ /** Id applied to dropdown menu toggle */
23
+ id?: string;
22
24
  }
23
25
 
24
26
  export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConversationHistoryDropdownProps> = ({
25
27
  menuItems,
26
28
  menuClassName,
27
29
  onSelect,
28
- label
30
+ label,
31
+ id
29
32
  }: ChatbotConversationHistoryDropdownProps) => {
30
33
  const [isOpen, setIsOpen] = useState(false);
31
34
 
@@ -44,6 +47,7 @@ export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConver
44
47
  ref={toggleRef}
45
48
  isExpanded={isOpen}
46
49
  onClick={() => setIsOpen(!isOpen)}
50
+ id={id}
47
51
  >
48
52
  <EllipsisIcon />
49
53
  </MenuToggle>
@@ -65,6 +65,8 @@ export interface Conversation {
65
65
  additionalProps?: ButtonProps;
66
66
  /** Additional props passed to conversation list item */
67
67
  listItemProps?: Omit<ListItemProps, 'children'>;
68
+ /** Custom dropdown ID to ensure uniqueness across demo instances */
69
+ dropdownId?: string;
68
70
  }
69
71
  export interface ChatbotConversationHistoryNavProps extends DrawerProps {
70
72
  /** Function called to toggle drawer */
@@ -202,6 +204,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
202
204
  onSelect={conversation.onSelect}
203
205
  menuItems={conversation.menuItems}
204
206
  label={conversation.label}
207
+ id={conversation.dropdownId}
205
208
  />
206
209
  )}
207
210
  </>