@patternfly/chatbot 6.8.0-prerelease.4 → 6.8.0-prerelease.6
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.
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +2 -5
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.js +1 -1
- package/dist/cjs/FileDropZone/FileDropZone.js +1 -1
- package/dist/cjs/ImagePreview/ImagePreview.js +1 -1
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +1 -2
- package/dist/cjs/Message/Message.test.js +1 -20
- package/dist/cjs/Message/QuickResponse/QuickResponse.js +1 -1
- package/dist/cjs/Message/QuickStarts/QuickStartTile.js +4 -6
- package/dist/cjs/MessageBar/AttachButton.js +2 -2
- package/dist/cjs/MessageBar/MessageBar.test.js +1 -1
- package/dist/cjs/MessageBar/MicrophoneButton.js +2 -4
- package/dist/cjs/MessageBox/JumpButton.js +2 -4
- package/dist/cjs/SourcesCardBase/SourcesCardBase.js +5 -5
- package/dist/css/main.css +0 -13
- package/dist/css/main.css.map +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +2 -2
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.js +2 -2
- package/dist/esm/FileDropZone/FileDropZone.js +2 -2
- package/dist/esm/ImagePreview/ImagePreview.js +2 -2
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +2 -3
- package/dist/esm/Message/Message.test.js +1 -20
- package/dist/esm/Message/QuickResponse/QuickResponse.js +2 -2
- package/dist/esm/Message/QuickStarts/QuickStartTile.js +4 -6
- package/dist/esm/MessageBar/AttachButton.js +2 -2
- package/dist/esm/MessageBar/MessageBar.test.js +2 -2
- package/dist/esm/MessageBar/MicrophoneButton.js +2 -4
- package/dist/esm/MessageBox/JumpButton.js +2 -4
- package/dist/esm/SourcesCardBase/SourcesCardBase.js +7 -7
- package/package.json +1 -5
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/explore-pipeline-quickstart.ts +0 -3
- package/patternfly-docs/content/extensions/chatbot/examples/demos/AttachmentDemos.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx +13 -7
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotDisplayMode.tsx +7 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotInDrawer.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedChatbot.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/demos/WhiteEmbeddedChatbot.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +2 -2
- package/src/FileDetailsLabel/FileDetailsLabel.tsx +2 -2
- package/src/FileDropZone/FileDropZone.tsx +2 -2
- package/src/ImagePreview/ImagePreview.tsx +6 -2
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +2 -3
- package/src/Message/Message.test.tsx +8 -5
- package/src/Message/QuickResponse/QuickResponse.tsx +2 -2
- package/src/Message/QuickStarts/QuickStartTile.tsx +9 -6
- package/src/MessageBar/AttachButton.tsx +2 -2
- package/src/MessageBar/MessageBar.test.tsx +6 -6
- package/src/MessageBar/MicrophoneButton.tsx +2 -7
- package/src/MessageBox/JumpButton.tsx +2 -6
- package/src/SourcesCard/SourcesCard.scss +0 -13
- package/src/SourcesCardBase/SourcesCardBase.tsx +7 -32
- package/src/index.ts +0 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachMenu.tsx +0 -149
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PaperclipIcon.svg +0 -10
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
-
import RocketIcon from '@patternfly/react-icons/dist/js/icons/rocket-icon';
|
|
3
|
-
import OutlinedBookmarkIcon from '@patternfly/react-icons/dist/js/icons/outlined-bookmark-icon';
|
|
4
2
|
import {
|
|
5
3
|
Card,
|
|
6
4
|
CardBody,
|
|
@@ -14,11 +12,11 @@ import {
|
|
|
14
12
|
Label,
|
|
15
13
|
pluralize
|
|
16
14
|
} from '@patternfly/react-core';
|
|
17
|
-
import OutlinedClockIcon from '@patternfly/react-icons/dist/js/icons/outlined-clock-icon';
|
|
18
15
|
import QuickStartTileHeader from './QuickStartTileHeader';
|
|
19
16
|
import QuickStartTileDescription from './QuickStartTileDescription';
|
|
20
17
|
import { QuickStart, QuickstartAction } from './types';
|
|
21
18
|
import FallbackImg from './FallbackImg';
|
|
19
|
+
import { RhUiBookmarkIcon, RhUiClockIcon, RhUiRocketFillIcon } from '@patternfly/react-icons';
|
|
22
20
|
|
|
23
21
|
export const camelize = (str: string) =>
|
|
24
22
|
str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
|
|
@@ -77,7 +75,12 @@ export const QuickStartTile: FC<QuickStartTileProps> = ({
|
|
|
77
75
|
} else {
|
|
78
76
|
quickStartIcon = (
|
|
79
77
|
<Icon size="2xl">
|
|
80
|
-
<FallbackImg
|
|
78
|
+
<FallbackImg
|
|
79
|
+
src={icon as string}
|
|
80
|
+
alt=""
|
|
81
|
+
className="pfext-catalog-item-icon__img"
|
|
82
|
+
fallback={<RhUiRocketFillIcon />}
|
|
83
|
+
/>
|
|
81
84
|
</Icon>
|
|
82
85
|
);
|
|
83
86
|
}
|
|
@@ -91,7 +94,7 @@ export const QuickStartTile: FC<QuickStartTileProps> = ({
|
|
|
91
94
|
onClick && onClick();
|
|
92
95
|
};
|
|
93
96
|
|
|
94
|
-
const ActionIcon = action?.icon ||
|
|
97
|
+
const ActionIcon = action?.icon || RhUiBookmarkIcon;
|
|
95
98
|
const additionalAction = action ? (
|
|
96
99
|
<Button
|
|
97
100
|
aria-label={action['aria-label']}
|
|
@@ -125,7 +128,7 @@ export const QuickStartTile: FC<QuickStartTileProps> = ({
|
|
|
125
128
|
<Flex spaceItems={{ default: 'spaceItemsSm' }}>
|
|
126
129
|
{type && <Label color={type.color}>{type.text}</Label>}
|
|
127
130
|
{durationMinutes && (
|
|
128
|
-
<Label variant="outline" data-test="duration" icon={<
|
|
131
|
+
<Label variant="outline" data-test="duration" icon={<RhUiClockIcon />}>
|
|
129
132
|
{pluralize(durationMinutes, minuteWord, minuteWordPlural)}
|
|
130
133
|
</Label>
|
|
131
134
|
)}
|
|
@@ -8,7 +8,7 @@ import { forwardRef } from 'react';
|
|
|
8
8
|
// Import PatternFly components
|
|
9
9
|
import { Button, ButtonProps, Icon, Tooltip, TooltipProps } from '@patternfly/react-core';
|
|
10
10
|
import { Accept, DropEvent, DropzoneOptions, FileError, FileRejection, useDropzone } from 'react-dropzone';
|
|
11
|
-
import {
|
|
11
|
+
import { RhUiPaperClipIcon } from '@patternfly/react-icons';
|
|
12
12
|
|
|
13
13
|
export interface AttachButtonProps extends ButtonProps {
|
|
14
14
|
/** Callback for when button is clicked */
|
|
@@ -74,7 +74,7 @@ const AttachButtonBase: FunctionComponent<AttachButtonProps> = ({
|
|
|
74
74
|
onAttachRejected,
|
|
75
75
|
validator,
|
|
76
76
|
dropzoneProps,
|
|
77
|
-
icon = <
|
|
77
|
+
icon = <RhUiPaperClipIcon />,
|
|
78
78
|
...props
|
|
79
79
|
}: AttachButtonProps) => {
|
|
80
80
|
const { open, getInputProps } = useDropzone({
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
MenuSearchInputProps,
|
|
7
7
|
MenuSearchProps
|
|
8
8
|
} from '@patternfly/react-core';
|
|
9
|
-
import {
|
|
9
|
+
import { RhUiAttentionBellIcon, RhUiCalendarIcon, RhUiClipboardIcon, RhUiCodeIcon } from '@patternfly/react-icons';
|
|
10
10
|
import { render, screen } from '@testing-library/react';
|
|
11
11
|
import userEvent from '@testing-library/user-event';
|
|
12
12
|
import { createRef } from 'react';
|
|
@@ -43,19 +43,19 @@ const ATTACH_MENU_ITEMS = [
|
|
|
43
43
|
</DropdownList>,
|
|
44
44
|
<DropdownGroup key="group2">
|
|
45
45
|
<DropdownList>
|
|
46
|
-
<DropdownItem value="Alerts" id="1" icon={<
|
|
46
|
+
<DropdownItem value="Alerts" id="1" icon={<RhUiAttentionBellIcon />}>
|
|
47
47
|
Alerts
|
|
48
48
|
</DropdownItem>
|
|
49
|
-
<DropdownItem value="Events" id="2" icon={<
|
|
49
|
+
<DropdownItem value="Events" id="2" icon={<RhUiCalendarIcon />}>
|
|
50
50
|
Events
|
|
51
51
|
</DropdownItem>
|
|
52
|
-
<DropdownItem value="Logs" id="3" icon={<
|
|
52
|
+
<DropdownItem value="Logs" id="3" icon={<RhUiClipboardIcon />}>
|
|
53
53
|
Logs
|
|
54
54
|
</DropdownItem>
|
|
55
|
-
<DropdownItem value="YAML - Status" id="4" icon={<
|
|
55
|
+
<DropdownItem value="YAML - Status" id="4" icon={<RhUiCodeIcon />}>
|
|
56
56
|
YAML - Status
|
|
57
57
|
</DropdownItem>
|
|
58
|
-
<DropdownItem value="YAML - All contents" id="5" icon={<
|
|
58
|
+
<DropdownItem value="YAML - All contents" id="5" icon={<RhUiCodeIcon />}>
|
|
59
59
|
YAML - All contents
|
|
60
60
|
</DropdownItem>
|
|
61
61
|
</DropdownList>
|
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
// Chatbot Footer - Message Bar - Microphone
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import type { FunctionComponent } from 'react';
|
|
5
|
-
|
|
6
5
|
import { useState, useCallback, useEffect } from 'react';
|
|
7
|
-
|
|
8
|
-
// Import PatternFly components
|
|
9
6
|
import { Button, ButtonProps, Tooltip, TooltipProps, Icon } from '@patternfly/react-core';
|
|
10
|
-
|
|
11
|
-
// Import FontAwesome icons
|
|
12
|
-
import { MicrophoneIcon } from '@patternfly/react-icons/dist/esm/icons/microphone-icon';
|
|
7
|
+
import { RhUiMicrophoneFillIcon } from '@patternfly/react-icons';
|
|
13
8
|
|
|
14
9
|
export interface MicrophoneButtonProps extends ButtonProps {
|
|
15
10
|
/** Boolean check if the browser is listening to speech or not */
|
|
@@ -112,7 +107,7 @@ export const MicrophoneButton: FunctionComponent<MicrophoneButtonProps> = ({
|
|
|
112
107
|
onClick={isListening ? stopListening : startListening}
|
|
113
108
|
icon={
|
|
114
109
|
<Icon iconSize={isCompact ? 'lg' : 'xl'} isInline>
|
|
115
|
-
<
|
|
110
|
+
<RhUiMicrophoneFillIcon />
|
|
116
111
|
</Icon>
|
|
117
112
|
}
|
|
118
113
|
size={isCompact ? 'sm' : undefined}
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
// Chatbot Main - Messages - Jump to Top
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import type { FunctionComponent } from 'react';
|
|
5
|
-
|
|
6
|
-
// Import PatternFly components
|
|
7
5
|
import { Button, Tooltip, Icon, TooltipProps, ButtonProps } from '@patternfly/react-core';
|
|
8
|
-
|
|
9
|
-
import { ArrowUpIcon } from '@patternfly/react-icons/dist/esm/icons/arrow-up-icon';
|
|
10
|
-
import { ArrowDownIcon } from '@patternfly/react-icons/dist/esm/icons/arrow-down-icon';
|
|
6
|
+
import { RhMicronsArrowDownIcon, RhMicronsArrowUpIcon } from '@patternfly/react-icons';
|
|
11
7
|
|
|
12
8
|
export interface JumpButtonProps {
|
|
13
9
|
/** Position of the Jump Button(top/bottom) */
|
|
@@ -44,7 +40,7 @@ const JumpButton: FunctionComponent<JumpButtonProps> = ({
|
|
|
44
40
|
{...jumpButtonProps}
|
|
45
41
|
>
|
|
46
42
|
<Icon iconSize="lg" isInline>
|
|
47
|
-
{position === 'top' ? <
|
|
43
|
+
{position === 'top' ? <RhMicronsArrowUpIcon /> : <RhMicronsArrowDownIcon />}
|
|
48
44
|
</Icon>
|
|
49
45
|
</Button>
|
|
50
46
|
</Tooltip>
|
|
@@ -79,25 +79,12 @@
|
|
|
79
79
|
justify-content: space-between;
|
|
80
80
|
flex: 1;
|
|
81
81
|
|
|
82
|
-
.pf-v6-c-button {
|
|
83
|
-
border-radius: var(--pf-t--global--border--radius--pill);
|
|
84
|
-
padding: var(--pf-t--global--spacer--sm);
|
|
85
|
-
width: 2.31rem;
|
|
86
|
-
height: 2.31rem;
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: center;
|
|
90
|
-
}
|
|
91
82
|
button:disabled,
|
|
92
83
|
button[disabled] {
|
|
93
84
|
.pf-v6-c-icon__content {
|
|
94
85
|
color: var(--pf-t--global--icon--color--disabled);
|
|
95
86
|
}
|
|
96
87
|
}
|
|
97
|
-
.pf-v6-c-button__text {
|
|
98
|
-
display: flex;
|
|
99
|
-
align-items: center;
|
|
100
|
-
}
|
|
101
88
|
// Interactive states
|
|
102
89
|
.pf-v6-c-button:hover,
|
|
103
90
|
.pf-v6-c-button:focus {
|
|
@@ -23,11 +23,10 @@ import {
|
|
|
23
23
|
CardTitleProps,
|
|
24
24
|
ExpandableSection,
|
|
25
25
|
ExpandableSectionVariant,
|
|
26
|
-
Icon,
|
|
27
26
|
Truncate,
|
|
28
27
|
TruncateProps
|
|
29
28
|
} from '@patternfly/react-core';
|
|
30
|
-
import {
|
|
29
|
+
import { RhMicronsCaretLeftIcon, RhMicronsCaretRightIcon, RhMicronsExternalLinkIcon } from '@patternfly/react-icons';
|
|
31
30
|
|
|
32
31
|
export interface SourcesCardBaseProps extends CardProps {
|
|
33
32
|
/** Additional classes for the pagination navigation container. */
|
|
@@ -139,7 +138,7 @@ const SourcesCardBase: FunctionComponent<SourcesCardBaseProps> = ({
|
|
|
139
138
|
component="a"
|
|
140
139
|
variant={ButtonVariant.link}
|
|
141
140
|
href={source.link}
|
|
142
|
-
icon={source.isExternal ? <
|
|
141
|
+
icon={source.isExternal ? <RhMicronsExternalLinkIcon /> : undefined}
|
|
143
142
|
iconPosition="end"
|
|
144
143
|
isInline
|
|
145
144
|
rel={source.isExternal ? 'noreferrer' : undefined}
|
|
@@ -202,7 +201,7 @@ const SourcesCardBase: FunctionComponent<SourcesCardBaseProps> = ({
|
|
|
202
201
|
component="a"
|
|
203
202
|
variant={ButtonVariant.link}
|
|
204
203
|
href={sources[page - 1].link}
|
|
205
|
-
icon={sources[page - 1].isExternal ? <
|
|
204
|
+
icon={sources[page - 1].isExternal ? <RhMicronsExternalLinkIcon /> : undefined}
|
|
206
205
|
iconPosition="end"
|
|
207
206
|
isInline
|
|
208
207
|
rel={sources[page - 1].isExternal ? 'noreferrer' : undefined}
|
|
@@ -254,6 +253,7 @@ const SourcesCardBase: FunctionComponent<SourcesCardBaseProps> = ({
|
|
|
254
253
|
>
|
|
255
254
|
<Button
|
|
256
255
|
variant={ButtonVariant.plain}
|
|
256
|
+
isCircle
|
|
257
257
|
isDisabled={isDisabled || page === 1}
|
|
258
258
|
data-action="previous"
|
|
259
259
|
onClick={(event) => {
|
|
@@ -263,26 +263,14 @@ const SourcesCardBase: FunctionComponent<SourcesCardBaseProps> = ({
|
|
|
263
263
|
}}
|
|
264
264
|
aria-label={toPreviousPageAriaLabel}
|
|
265
265
|
>
|
|
266
|
-
<
|
|
267
|
-
{/* these are inline because the viewBox that works in a round icon is different than the PatternFly default */}
|
|
268
|
-
<svg
|
|
269
|
-
className="pf-v6-svg"
|
|
270
|
-
viewBox="0 0 280 500"
|
|
271
|
-
fill="currentColor"
|
|
272
|
-
aria-hidden="true"
|
|
273
|
-
role="img"
|
|
274
|
-
width="1em"
|
|
275
|
-
height="1em"
|
|
276
|
-
>
|
|
277
|
-
<path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"></path>
|
|
278
|
-
</svg>
|
|
279
|
-
</Icon>
|
|
266
|
+
<RhMicronsCaretLeftIcon />
|
|
280
267
|
</Button>
|
|
281
268
|
<span aria-hidden="true">
|
|
282
269
|
{page}/{sources.length}
|
|
283
270
|
</span>
|
|
284
271
|
<Button
|
|
285
272
|
variant={ButtonVariant.plain}
|
|
273
|
+
isCircle
|
|
286
274
|
isDisabled={isDisabled || page === sources.length}
|
|
287
275
|
aria-label={toNextPageAriaLabel}
|
|
288
276
|
data-action="next"
|
|
@@ -292,20 +280,7 @@ const SourcesCardBase: FunctionComponent<SourcesCardBaseProps> = ({
|
|
|
292
280
|
handleNewPage(event, newPage);
|
|
293
281
|
}}
|
|
294
282
|
>
|
|
295
|
-
<
|
|
296
|
-
{/* these are inline because the viewBox that works in a round icon is different than the PatternFly default */}
|
|
297
|
-
<svg
|
|
298
|
-
className="pf-v6-svg"
|
|
299
|
-
viewBox="0 0 180 500"
|
|
300
|
-
fill="currentColor"
|
|
301
|
-
aria-hidden="true"
|
|
302
|
-
role="img"
|
|
303
|
-
width="1em"
|
|
304
|
-
height="1em"
|
|
305
|
-
>
|
|
306
|
-
<path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"></path>
|
|
307
|
-
</svg>
|
|
308
|
-
</Icon>
|
|
283
|
+
<RhMicronsCaretRightIcon />
|
|
309
284
|
</Button>
|
|
310
285
|
</nav>
|
|
311
286
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -60,9 +60,6 @@ export * from './FilePreview';
|
|
|
60
60
|
export { default as ImagePreview } from './ImagePreview';
|
|
61
61
|
export * from './ImagePreview';
|
|
62
62
|
|
|
63
|
-
export { default as LoadingMessage } from './LoadingMessage';
|
|
64
|
-
export * from './LoadingMessage';
|
|
65
|
-
|
|
66
63
|
export { default as MarkdownContent } from './MarkdownContent';
|
|
67
64
|
export * from './MarkdownContent';
|
|
68
65
|
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { useState, isValidElement, cloneElement, Children, FunctionComponent, ReactNode } from 'react';
|
|
2
|
-
import AttachMenu from '@patternfly/chatbot/dist/dynamic/AttachMenu';
|
|
3
|
-
import SourceDetailsMenuItem from '@patternfly/chatbot/dist/dynamic/SourceDetailsMenuItem';
|
|
4
|
-
import { Button, Divider, DropdownGroup, DropdownItem, DropdownList } from '@patternfly/react-core';
|
|
5
|
-
import { BellIcon, CodeIcon, ClipboardIcon, CalendarAltIcon, UploadIcon } from '@patternfly/react-icons';
|
|
6
|
-
import PaperclipIcon from './PaperclipIcon';
|
|
7
|
-
|
|
8
|
-
const initialMenuItems = [
|
|
9
|
-
<DropdownList key="list-1">
|
|
10
|
-
<DropdownItem className="pf-chatbot-source-details-dropdown-item" value="auth-operator Pod" id="0">
|
|
11
|
-
<SourceDetailsMenuItem
|
|
12
|
-
icon={
|
|
13
|
-
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
14
|
-
<path
|
|
15
|
-
d="M0 12.5C0 5.87258 5.37258 0.5 12 0.5C18.6274 0.5 24 5.87258 24 12.5C24 19.1274 18.6274 24.5 12 24.5C5.37258 24.5 0 19.1274 0 12.5Z"
|
|
16
|
-
fill="currentColor"
|
|
17
|
-
/>
|
|
18
|
-
<g clipPath="url(#clip0_3280_27488)">
|
|
19
|
-
<path
|
|
20
|
-
d="M8.25 8.75C8.25 7.92266 8.92266 7.25 9.75 7.25H12C14.0719 7.25 15.75 8.92812 15.75 11C15.75 13.0719 14.0719 14.75 12 14.75H9.75V17C9.75 17.4148 9.41484 17.75 9 17.75C8.58516 17.75 8.25 17.4148 8.25 17V14V8.75ZM9.75 13.25H12C13.2422 13.25 14.25 12.2422 14.25 11C14.25 9.75781 13.2422 8.75 12 8.75H9.75V13.25Z"
|
|
21
|
-
fill="white"
|
|
22
|
-
/>
|
|
23
|
-
</g>
|
|
24
|
-
<defs>
|
|
25
|
-
<clipPath id="clip0_3280_27488">
|
|
26
|
-
<rect width="7.5" height="12" fill="white" transform="translate(8.25 6.5)" />
|
|
27
|
-
</clipPath>
|
|
28
|
-
</defs>
|
|
29
|
-
</svg>
|
|
30
|
-
}
|
|
31
|
-
name="auth-operator"
|
|
32
|
-
type="Pod"
|
|
33
|
-
/>
|
|
34
|
-
</DropdownItem>
|
|
35
|
-
</DropdownList>,
|
|
36
|
-
<DropdownGroup key="group2">
|
|
37
|
-
<DropdownList>
|
|
38
|
-
<DropdownItem value="Alerts" id="1" icon={<BellIcon />}>
|
|
39
|
-
Alerts
|
|
40
|
-
</DropdownItem>
|
|
41
|
-
<DropdownItem value="Events" id="2" icon={<CalendarAltIcon />}>
|
|
42
|
-
Events
|
|
43
|
-
</DropdownItem>
|
|
44
|
-
<DropdownItem value="Logs" id="3" icon={<ClipboardIcon />}>
|
|
45
|
-
Logs
|
|
46
|
-
</DropdownItem>
|
|
47
|
-
<DropdownItem value="YAML - Status" id="4" icon={<CodeIcon />}>
|
|
48
|
-
YAML - Status
|
|
49
|
-
</DropdownItem>
|
|
50
|
-
<DropdownItem value="YAML - All contents" id="5" icon={<CodeIcon />}>
|
|
51
|
-
YAML - All contents
|
|
52
|
-
</DropdownItem>
|
|
53
|
-
</DropdownList>
|
|
54
|
-
</DropdownGroup>
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const uploadMenuItems = [
|
|
58
|
-
<Divider key="divider" />,
|
|
59
|
-
<DropdownList key="list-2">
|
|
60
|
-
<DropdownItem key="upload" value="upload" id="upload" icon={<UploadIcon />}>
|
|
61
|
-
Upload from computer
|
|
62
|
-
</DropdownItem>
|
|
63
|
-
</DropdownList>
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
export const AttachmentMenuExample: FunctionComponent = () => {
|
|
67
|
-
const [isOpen, setIsOpen] = useState<boolean>(false);
|
|
68
|
-
const [userFacingMenuItems, setUserFacingMenuItems] = useState<ReactNode>([]);
|
|
69
|
-
|
|
70
|
-
const onToggleClick = () => {
|
|
71
|
-
setIsOpen(!isOpen);
|
|
72
|
-
setUserFacingMenuItems(initialMenuItems.concat(uploadMenuItems));
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const findMatchingElements = (elements: ReactNode[], targetValue: string) => {
|
|
76
|
-
let matchingElements = [] as ReactNode[];
|
|
77
|
-
|
|
78
|
-
elements.forEach((element) => {
|
|
79
|
-
if (isValidElement(element)) {
|
|
80
|
-
// Check if the element's value matches the targetValue
|
|
81
|
-
if (element.props.value && element.props.value.toLowerCase().includes(targetValue.toLowerCase())) {
|
|
82
|
-
matchingElements.push(cloneElement(element, { key: element.props.value }));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Recursively check the element's children
|
|
86
|
-
const children = Children.toArray(element.props.children);
|
|
87
|
-
matchingElements = matchingElements.concat(findMatchingElements(children, targetValue));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return matchingElements;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const onTextChange = (textValue: string) => {
|
|
95
|
-
if (textValue === '') {
|
|
96
|
-
setUserFacingMenuItems(initialMenuItems.concat(uploadMenuItems));
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const newMenuItems = findMatchingElements(initialMenuItems, textValue);
|
|
101
|
-
// this is necessary because the React nodes we find traversing the recursive search
|
|
102
|
-
// aren't correctly wrapped in a DropdownList. This leads to problems with the
|
|
103
|
-
// auth-operator item where it winds up floating in a bad place in the DOM and never
|
|
104
|
-
// gets removed
|
|
105
|
-
setUserFacingMenuItems(
|
|
106
|
-
<>
|
|
107
|
-
<DropdownList>
|
|
108
|
-
{newMenuItems.length === 0 ? (
|
|
109
|
-
<DropdownItem key="no-items">No results found</DropdownItem>
|
|
110
|
-
) : (
|
|
111
|
-
newMenuItems.map((item) => item)
|
|
112
|
-
)}
|
|
113
|
-
</DropdownList>
|
|
114
|
-
{uploadMenuItems.map((item) => item)}
|
|
115
|
-
</>
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<AttachMenu
|
|
121
|
-
filteredItems={userFacingMenuItems}
|
|
122
|
-
isOpen={isOpen}
|
|
123
|
-
onOpenChange={(isOpen) => setIsOpen(isOpen)}
|
|
124
|
-
onOpenChangeKeys={['Escape']}
|
|
125
|
-
// eslint-disable-next-line no-console
|
|
126
|
-
onSelect={(_ev, value) => console.log('selected', value)}
|
|
127
|
-
handleTextInputChange={onTextChange}
|
|
128
|
-
popperProps={{ direction: 'up', distance: 8 }}
|
|
129
|
-
searchInputPlaceholder="Search cluster resources..."
|
|
130
|
-
toggle={(toggleRef) => (
|
|
131
|
-
<Button
|
|
132
|
-
style={{
|
|
133
|
-
alignItems: 'center',
|
|
134
|
-
borderRadius: '50%',
|
|
135
|
-
display: 'flex',
|
|
136
|
-
height: '48px',
|
|
137
|
-
justifyContent: 'center',
|
|
138
|
-
padding: '0',
|
|
139
|
-
width: '48px',
|
|
140
|
-
lineHeight: '1rem'
|
|
141
|
-
}}
|
|
142
|
-
ref={toggleRef}
|
|
143
|
-
onClick={onToggleClick}
|
|
144
|
-
icon={<img src={PaperclipIcon} alt="Add an attachment" />}
|
|
145
|
-
/>
|
|
146
|
-
)}
|
|
147
|
-
/>
|
|
148
|
-
);
|
|
149
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<svg width="18" height="20" viewBox="0 0 18 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<g clip-path="url(#clip0_3934_2737)">
|
|
3
|
-
<path d="M14.4766 3.27344C13.5234 2.32031 11.9766 2.32031 11.0234 3.27344L3.83594 10.4609C2.19141 12.1055 2.19141 14.7695 3.83594 16.4141C5.48047 18.0586 8.14453 18.0586 9.78906 16.4141L15.7266 10.4766C16.1523 10.0508 16.8477 10.0508 17.2734 10.4766C17.6992 10.9023 17.6992 11.5977 17.2734 12.0234L11.3359 17.9609C8.83594 20.4609 4.78906 20.4609 2.28906 17.9609C-0.210938 15.4609 -0.210938 11.4141 2.28906 8.91406L9.47656 1.72656C11.2852 -0.0820313 14.2148 -0.0820313 16.0234 1.72656C17.832 3.53516 17.832 6.46484 16.0234 8.27344L9.14844 15.1484C8.03125 16.2656 6.21875 16.2656 5.10156 15.1484C3.98438 14.0312 3.98438 12.2188 5.10156 11.1016L10.7266 5.47656C11.1523 5.05078 11.8477 5.05078 12.2734 5.47656C12.6992 5.90234 12.6992 6.59766 12.2734 7.02344L6.64844 12.6484C6.38672 12.9102 6.38672 13.3398 6.64844 13.6016C6.91016 13.8633 7.33984 13.8633 7.60156 13.6016L14.4766 6.72656C15.4297 5.77344 15.4297 4.22656 14.4766 3.27344Z" fill="white"/>
|
|
4
|
-
</g>
|
|
5
|
-
<defs>
|
|
6
|
-
<clipPath id="clip0_3934_2737">
|
|
7
|
-
<rect width="17.5" height="20" fill="white" transform="translate(0.25)"/>
|
|
8
|
-
</clipPath>
|
|
9
|
-
</defs>
|
|
10
|
-
</svg>
|