@patternfly/chatbot 6.5.0-prerelease.17 → 6.5.0-prerelease.19
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 +29 -2
- package/dist/cjs/CodeModal/CodeModal.d.ts +2 -0
- package/dist/cjs/CodeModal/CodeModal.js +53 -12
- package/dist/cjs/Onboarding/Onboarding.d.ts +36 -0
- package/dist/cjs/Onboarding/Onboarding.js +37 -0
- package/dist/cjs/Onboarding/Onboarding.test.d.ts +1 -0
- package/dist/cjs/Onboarding/Onboarding.test.js +80 -0
- package/dist/cjs/Onboarding/index.d.ts +2 -0
- package/dist/cjs/Onboarding/index.js +23 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/css/main.css +83 -0
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/Onboarding/package.json +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +30 -3
- package/dist/esm/CodeModal/CodeModal.d.ts +2 -0
- package/dist/esm/CodeModal/CodeModal.js +54 -13
- package/dist/esm/Onboarding/Onboarding.d.ts +36 -0
- package/dist/esm/Onboarding/Onboarding.js +30 -0
- package/dist/esm/Onboarding/Onboarding.test.d.ts +1 -0
- package/dist/esm/Onboarding/Onboarding.test.js +75 -0
- package/dist/esm/Onboarding/index.d.ts +2 -0
- package/dist/esm/Onboarding/index.js +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -3
- package/patternfly-docs/content/extensions/chatbot/about-chatbot.md +3 -3
- package/patternfly-docs/content/extensions/chatbot/design-guidelines.md +3 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Analytics/Analytics.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Customizing Messages/Customizing Messages.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +11 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/CompactOnboarding.tsx +141 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/Onboarding.tsx +151 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/RH-Hat-Image.svg +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +38 -20
- package/patternfly-docs/content/extensions/chatbot/examples/demos/AttachmentDemos.md +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +2 -2
- package/patternfly-docs/patternfly-docs.config.js +1 -1
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +56 -14
- package/src/ChatbotModal/ChatbotModal.scss +3 -0
- package/src/CodeModal/CodeModal.tsx +71 -26
- package/src/Onboarding/Onboarding.scss +101 -0
- package/src/Onboarding/Onboarding.test.tsx +148 -0
- package/src/Onboarding/Onboarding.tsx +126 -0
- package/src/Onboarding/index.ts +3 -0
- package/src/index.ts +3 -0
- package/src/main.scss +1 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Terms of Use Modal - Chatbot Modal Extension
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import type { FunctionComponent, MouseEvent as ReactMouseEvent, Ref } from 'react';
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
import { Button, Content, ModalBody, ModalFooter, ModalProps } from '@patternfly/react-core';
|
|
7
|
+
import { ChatbotDisplayMode } from '../Chatbot';
|
|
8
|
+
import ChatbotModal from '../ChatbotModal/ChatbotModal';
|
|
9
|
+
|
|
10
|
+
export interface OnboardingProps extends ModalProps {
|
|
11
|
+
/** Class applied to modal */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Action assigned to primary modal button */
|
|
14
|
+
onPrimaryAction?: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
15
|
+
/** Action assigned to secondary modal button */
|
|
16
|
+
onSecondaryAction: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
17
|
+
/** Name of primary modal button */
|
|
18
|
+
primaryActionBtn?: string;
|
|
19
|
+
/** Name of secondary modal button */
|
|
20
|
+
secondaryActionBtn?: string;
|
|
21
|
+
/** Function that handles modal toggle */
|
|
22
|
+
handleModalToggle: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
23
|
+
/** Whether modal is open */
|
|
24
|
+
isModalOpen: boolean;
|
|
25
|
+
/** Title of modal */
|
|
26
|
+
title?: string;
|
|
27
|
+
/** Display mode for the Chatbot parent; this influences the styles applied */
|
|
28
|
+
displayMode?: ChatbotDisplayMode;
|
|
29
|
+
/** Optional image displayed in header */
|
|
30
|
+
headerImage?: string;
|
|
31
|
+
/** Alt text for optional image displayed in header */
|
|
32
|
+
headerImageAltText?: string;
|
|
33
|
+
/** Ref applied to modal */
|
|
34
|
+
innerRef?: React.Ref<HTMLDivElement>;
|
|
35
|
+
/** OuiaID applied to modal */
|
|
36
|
+
ouiaId?: string;
|
|
37
|
+
/** Sets modal to compact styling. */
|
|
38
|
+
isCompact?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const OnboardingBase: FunctionComponent<OnboardingProps> = ({
|
|
42
|
+
handleModalToggle,
|
|
43
|
+
isModalOpen,
|
|
44
|
+
onPrimaryAction,
|
|
45
|
+
onSecondaryAction,
|
|
46
|
+
primaryActionBtn = 'Continue',
|
|
47
|
+
secondaryActionBtn = 'Skip',
|
|
48
|
+
title = 'Onboarding',
|
|
49
|
+
headerImage,
|
|
50
|
+
headerImageAltText = '',
|
|
51
|
+
displayMode = ChatbotDisplayMode.default,
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
innerRef,
|
|
55
|
+
ouiaId = 'Onboarding',
|
|
56
|
+
isCompact,
|
|
57
|
+
...props
|
|
58
|
+
}: OnboardingProps) => {
|
|
59
|
+
const handlePrimaryAction = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
|
|
60
|
+
handleModalToggle(_event);
|
|
61
|
+
onPrimaryAction && onPrimaryAction(_event);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleSecondaryAction = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent) => {
|
|
65
|
+
onSecondaryAction(_event);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const modal = (
|
|
69
|
+
<ChatbotModal
|
|
70
|
+
isOpen={isModalOpen}
|
|
71
|
+
ouiaId={ouiaId}
|
|
72
|
+
aria-labelledby="onboarding-title"
|
|
73
|
+
aria-describedby="onboarding-modal"
|
|
74
|
+
className={`pf-chatbot__onboarding-modal pf-chatbot__onboarding-modal--${displayMode} ${isCompact ? 'pf-m-compact' : ''} ${className ? className : ''}`}
|
|
75
|
+
displayMode={displayMode}
|
|
76
|
+
onClose={handleModalToggle}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{/* This is a workaround since the PatternFly modal doesn't have ref forwarding */}
|
|
80
|
+
<section className={`pf-chatbot__onboarding--section`} aria-label={title} tabIndex={-1} ref={innerRef}>
|
|
81
|
+
<>
|
|
82
|
+
<ModalBody className="pf-chatbot__onboarding--modal-body">
|
|
83
|
+
{!isCompact && headerImage && (
|
|
84
|
+
<div className="pf-chatbot__onboarding--header">
|
|
85
|
+
<img src={headerImage} className="pf-chatbot__onboarding--image" alt={headerImageAltText} />
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
<div className="pf-chatbot__onboarding--modal-text">
|
|
89
|
+
<h1 className="pf-chatbot__onboarding--title">{title}</h1>
|
|
90
|
+
<Content>{children}</Content>
|
|
91
|
+
</div>
|
|
92
|
+
</ModalBody>
|
|
93
|
+
<ModalFooter className="pf-chatbot__onboarding--footer">
|
|
94
|
+
<Button
|
|
95
|
+
isBlock
|
|
96
|
+
key="onboarding-modal-primary"
|
|
97
|
+
variant="primary"
|
|
98
|
+
onClick={handlePrimaryAction}
|
|
99
|
+
form="onboarding-form"
|
|
100
|
+
size="lg"
|
|
101
|
+
>
|
|
102
|
+
{primaryActionBtn}
|
|
103
|
+
</Button>
|
|
104
|
+
<Button
|
|
105
|
+
isBlock
|
|
106
|
+
key="onboarding-modal-secondary"
|
|
107
|
+
variant="secondary"
|
|
108
|
+
onClick={handleSecondaryAction}
|
|
109
|
+
size="lg"
|
|
110
|
+
>
|
|
111
|
+
{secondaryActionBtn}
|
|
112
|
+
</Button>
|
|
113
|
+
</ModalFooter>
|
|
114
|
+
</>
|
|
115
|
+
</section>
|
|
116
|
+
</ChatbotModal>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return modal;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const Onboarding = forwardRef((props: OnboardingProps, ref: Ref<HTMLDivElement>) => (
|
|
123
|
+
<OnboardingBase innerRef={ref} {...props} />
|
|
124
|
+
));
|
|
125
|
+
|
|
126
|
+
export default Onboarding;
|
package/src/index.ts
CHANGED
|
@@ -75,6 +75,9 @@ export * from './MessageBox';
|
|
|
75
75
|
export { default as MessageDivider } from './MessageDivider';
|
|
76
76
|
export * from './MessageDivider';
|
|
77
77
|
|
|
78
|
+
export { default as Onboarding } from './Onboarding';
|
|
79
|
+
export * from './Onboarding';
|
|
80
|
+
|
|
78
81
|
export { default as PreviewAttachment } from './PreviewAttachment';
|
|
79
82
|
export * from './PreviewAttachment';
|
|
80
83
|
|
package/src/main.scss
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
@import './MessageBox/MessageBox';
|
|
32
32
|
@import './MessageDivider/MessageDivider';
|
|
33
33
|
@import './MessageBox/JumpButton';
|
|
34
|
+
@import './Onboarding/Onboarding';
|
|
34
35
|
@import './ResponseActions/ResponseActions';
|
|
35
36
|
@import './Settings/Settings';
|
|
36
37
|
@import './SourcesCard/SourcesCard.scss';
|
package/tsconfig.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/* Basic Options */
|
|
6
6
|
// "incremental": true, /* Enable incremental compilation */
|
|
7
7
|
"target": "es2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
|
|
8
|
-
"module": "
|
|
8
|
+
"module": "es2020" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
9
9
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
10
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
11
|
// "checkJs": true, /* Report errors in .js files. */
|