@patternfly/chatbot 6.3.0 → 6.4.0-prerelease.2
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/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +5 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +3 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +17 -0
- package/dist/cjs/FileDropZone/FileDropZone.d.ts +1 -2
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +1 -10
- package/dist/cjs/Message/Message.d.ts +4 -2
- package/dist/cjs/Message/Message.js +4 -4
- package/dist/cjs/Message/Message.test.js +26 -0
- package/dist/cjs/Message/MessageInput.d.ts +3 -1
- package/dist/cjs/Message/MessageInput.js +2 -2
- package/dist/cjs/MessageBar/AttachButton.d.ts +2 -2
- package/dist/cjs/MessageBar/MessageBar.d.ts +2 -2
- package/dist/cjs/MessageBox/MessageBox.js +1 -1
- package/dist/cjs/MessageDivider/MessageDivider.d.ts +9 -0
- package/dist/cjs/MessageDivider/MessageDivider.js +23 -0
- package/dist/cjs/MessageDivider/MessageDivider.test.d.ts +1 -0
- package/dist/cjs/MessageDivider/MessageDivider.test.js +29 -0
- package/dist/cjs/MessageDivider/index.d.ts +2 -0
- package/dist/cjs/MessageDivider/index.js +23 -0
- package/dist/cjs/ResponseActions/ResponseActions.d.ts +1 -0
- package/dist/cjs/ResponseActions/ResponseActions.js +4 -4
- package/dist/cjs/ResponseActions/ResponseActions.test.js +6 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/css/main.css +56 -55
- package/dist/css/main.css.map +1 -1
- package/dist/dynamic/MessageDivider/package.json +1 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +5 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +5 -5
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +17 -0
- package/dist/esm/FileDropZone/FileDropZone.d.ts +1 -2
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +1 -7
- package/dist/esm/Message/Message.d.ts +4 -2
- package/dist/esm/Message/Message.js +4 -4
- package/dist/esm/Message/Message.test.js +26 -0
- package/dist/esm/Message/MessageInput.d.ts +3 -1
- package/dist/esm/Message/MessageInput.js +2 -2
- package/dist/esm/MessageBar/AttachButton.d.ts +2 -2
- package/dist/esm/MessageBar/MessageBar.d.ts +2 -2
- package/dist/esm/MessageBox/MessageBox.js +1 -1
- package/dist/esm/MessageDivider/MessageDivider.d.ts +9 -0
- package/dist/esm/MessageDivider/MessageDivider.js +21 -0
- package/dist/esm/MessageDivider/MessageDivider.test.d.ts +1 -0
- package/dist/esm/MessageDivider/MessageDivider.test.js +24 -0
- package/dist/esm/MessageDivider/index.d.ts +2 -0
- package/dist/esm/MessageDivider/index.js +2 -0
- package/dist/esm/ResponseActions/ResponseActions.d.ts +1 -0
- package/dist/esm/ResponseActions/ResponseActions.js +5 -5
- package/dist/esm/ResponseActions/ResponseActions.test.js +6 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithDividers.tsx +24 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +15 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +39 -7
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +9 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithPin.tsx +196 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +9 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +33 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotDisplayMode.tsx +486 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotTranscripts.tsx +565 -0
- package/src/Chatbot/Chatbot.scss +1 -1
- package/src/ChatbotContent/ChatbotContent.scss +1 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +14 -2
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +58 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +29 -12
- package/src/ChatbotFooter/ChatbotFooter.scss +1 -1
- package/src/ChatbotHeader/ChatbotHeader.scss +3 -3
- package/src/ChatbotToggle/ChatbotToggle.scss +2 -2
- package/src/FileDropZone/FileDropZone.tsx +2 -2
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +3 -27
- package/src/Message/Message.scss +9 -7
- package/src/Message/Message.test.tsx +35 -0
- package/src/Message/Message.tsx +8 -4
- package/src/Message/MessageInput.tsx +5 -1
- package/src/MessageBar/AttachButton.tsx +2 -2
- package/src/MessageBar/MessageBar.tsx +2 -2
- package/src/MessageBar/SendButton.scss +3 -3
- package/src/MessageBox/JumpButton.scss +1 -1
- package/src/MessageBox/MessageBox.tsx +1 -1
- package/src/MessageDivider/MessageDivider.scss +45 -0
- package/src/MessageDivider/MessageDivider.test.tsx +24 -0
- package/src/MessageDivider/MessageDivider.tsx +35 -0
- package/src/MessageDivider/index.ts +3 -0
- package/src/ResponseActions/ResponseActions.test.tsx +6 -1
- package/src/ResponseActions/ResponseActions.tsx +24 -3
- package/src/index.ts +3 -0
- package/src/main.scss +1 -52
- package/dist/cjs/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.d.ts +0 -62
- package/dist/cjs/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.js +0 -139
- package/dist/esm/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.d.ts +0 -62
- package/dist/esm/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.js +0 -133
- package/src/Message/CodeBlockMessage/ExpandableSectionForSyntaxHighlighter.tsx +0 -223
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
OutlinedThumbsUpIcon,
|
|
7
7
|
OutlinedThumbsDownIcon,
|
|
8
8
|
OutlinedCopyIcon,
|
|
9
|
-
DownloadIcon
|
|
9
|
+
DownloadIcon,
|
|
10
|
+
PencilAltIcon
|
|
10
11
|
} from '@patternfly/react-icons';
|
|
11
12
|
import ResponseActionButton from './ResponseActionButton';
|
|
12
13
|
import { ButtonProps, TooltipProps } from '@patternfly/react-core';
|
|
@@ -50,6 +51,7 @@ export interface ResponseActionProps {
|
|
|
50
51
|
share?: ActionProps;
|
|
51
52
|
download?: ActionProps;
|
|
52
53
|
listen?: ActionProps;
|
|
54
|
+
edit?: ActionProps;
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -58,7 +60,7 @@ export const ResponseActions: FunctionComponent<ResponseActionProps> = ({ action
|
|
|
58
60
|
const [clickStatePersisted, setClickStatePersisted] = useState<boolean>(false);
|
|
59
61
|
useEffect(() => {
|
|
60
62
|
// Define the order of precedence for checking initial `isClicked`
|
|
61
|
-
const actionPrecedence = ['positive', 'negative', 'copy', 'share', 'download', 'listen'];
|
|
63
|
+
const actionPrecedence = ['positive', 'negative', 'copy', 'edit', 'share', 'download', 'listen'];
|
|
62
64
|
let initialActive: string | undefined;
|
|
63
65
|
|
|
64
66
|
// Check predefined actions first based on precedence
|
|
@@ -83,7 +85,7 @@ export const ResponseActions: FunctionComponent<ResponseActionProps> = ({ action
|
|
|
83
85
|
setActiveButton(initialActive);
|
|
84
86
|
}, [actions]);
|
|
85
87
|
|
|
86
|
-
const { positive, negative, copy, share, download, listen, ...additionalActions } = actions;
|
|
88
|
+
const { positive, negative, copy, edit, share, download, listen, ...additionalActions } = actions;
|
|
87
89
|
const responseActions = useRef<HTMLDivElement>(null);
|
|
88
90
|
|
|
89
91
|
useEffect(() => {
|
|
@@ -165,6 +167,24 @@ export const ResponseActions: FunctionComponent<ResponseActionProps> = ({ action
|
|
|
165
167
|
aria-controls={copy['aria-controls']}
|
|
166
168
|
></ResponseActionButton>
|
|
167
169
|
)}
|
|
170
|
+
{edit && (
|
|
171
|
+
<ResponseActionButton
|
|
172
|
+
{...edit}
|
|
173
|
+
ariaLabel={edit.ariaLabel ?? 'Edit'}
|
|
174
|
+
clickedAriaLabel={edit.ariaLabel ?? 'Editing'}
|
|
175
|
+
onClick={(e) => handleClick(e, 'edit', edit.onClick)}
|
|
176
|
+
className={edit.className}
|
|
177
|
+
isDisabled={edit.isDisabled}
|
|
178
|
+
tooltipContent={edit.tooltipContent ?? 'Edit '}
|
|
179
|
+
clickedTooltipContent={edit.clickedTooltipContent ?? 'Editing'}
|
|
180
|
+
tooltipProps={edit.tooltipProps}
|
|
181
|
+
icon={<PencilAltIcon />}
|
|
182
|
+
isClicked={activeButton === 'edit'}
|
|
183
|
+
ref={edit.ref}
|
|
184
|
+
aria-expanded={edit['aria-expanded']}
|
|
185
|
+
aria-controls={edit['aria-controls']}
|
|
186
|
+
></ResponseActionButton>
|
|
187
|
+
)}
|
|
168
188
|
{share && (
|
|
169
189
|
<ResponseActionButton
|
|
170
190
|
{...share}
|
|
@@ -219,6 +239,7 @@ export const ResponseActions: FunctionComponent<ResponseActionProps> = ({ action
|
|
|
219
239
|
aria-controls={listen['aria-controls']}
|
|
220
240
|
></ResponseActionButton>
|
|
221
241
|
)}
|
|
242
|
+
|
|
222
243
|
{Object.keys(additionalActions).map((action) => (
|
|
223
244
|
<ResponseActionButton
|
|
224
245
|
{...additionalActions[action]}
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,9 @@ export * from './MessageBar';
|
|
|
63
63
|
export { default as MessageBox } from './MessageBox';
|
|
64
64
|
export * from './MessageBox';
|
|
65
65
|
|
|
66
|
+
export { default as MessageDivider } from './MessageDivider';
|
|
67
|
+
export * from './MessageDivider';
|
|
68
|
+
|
|
66
69
|
export { default as PreviewAttachment } from './PreviewAttachment';
|
|
67
70
|
export * from './PreviewAttachment';
|
|
68
71
|
|
package/src/main.scss
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
@import './Message/UserFeedback/UserFeedback';
|
|
27
27
|
@import './MessageBar/MessageBar';
|
|
28
28
|
@import './MessageBox/MessageBox';
|
|
29
|
+
@import './MessageDivider/MessageDivider';
|
|
29
30
|
@import './MessageBox/JumpButton';
|
|
30
31
|
@import './ResponseActions/ResponseActions';
|
|
31
32
|
@import './Settings/Settings';
|
|
@@ -33,58 +34,6 @@
|
|
|
33
34
|
@import './SourceDetailsMenuItem/SourceDetailsMenuItem';
|
|
34
35
|
@import './TermsOfUse/TermsOfUse';
|
|
35
36
|
|
|
36
|
-
:where(:root) {
|
|
37
|
-
// ============================================================================
|
|
38
|
-
// Chatbot Custom Default Tokens
|
|
39
|
-
// ============================================================================
|
|
40
|
-
|
|
41
|
-
--pf-t--chatbot--heading--font-family: var(
|
|
42
|
-
--pf-v6-c-content--heading--FontFamily,
|
|
43
|
-
redhatdisplayvf,
|
|
44
|
-
redhatdisplay,
|
|
45
|
-
helvetica,
|
|
46
|
-
arial,
|
|
47
|
-
sans-serif
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
--pf-t--chatbot--illustration--fill: var(--pf-t--color--red--50);
|
|
51
|
-
--pf-t--chatbot--code--background: var(--pf-t--color--gray--20);
|
|
52
|
-
|
|
53
|
-
--pf-t--chatbot-toggle--background--hover: var(--pf-t--color--gray--70);
|
|
54
|
-
|
|
55
|
-
--pf-t--chatbot--blue-icon--background--color--hover: rgba(
|
|
56
|
-
146,
|
|
57
|
-
197,
|
|
58
|
-
249,
|
|
59
|
-
0.25
|
|
60
|
-
); // --pf-t--global--color--nonstatus--blue--default @ 25%
|
|
61
|
-
--pf-t--chatbot--blue-icon--fill--hover: var(--pf-t--global--color--brand--hover);
|
|
62
|
-
|
|
63
|
-
// ============================================================================
|
|
64
|
-
// Chatbot Default tokens using PF semantic tokens
|
|
65
|
-
// ============================================================================
|
|
66
|
-
--pf-t--chatbot-toggle--color: var(--pf-t--global--icon--color--inverse);
|
|
67
|
-
--pf-t--chatbot--background: var(--pf-t--global--background--color--secondary--default);
|
|
68
|
-
--pf-t--chatbot--border: var(--pf-t--global--border--color--default);
|
|
69
|
-
|
|
70
|
-
--pf-t--chatbot--icon--fill--active: var(--pf-t--global--text--color--regular);
|
|
71
|
-
|
|
72
|
-
--pf-t--chatbot--blue-icon--fill: var(--pf-t--global--color--brand--default);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ============================================================================
|
|
76
|
-
// Chatbot Custom Dark Theme Tokens
|
|
77
|
-
// ============================================================================
|
|
78
|
-
:where(.pf-v6-theme-dark) {
|
|
79
|
-
--pf-t--chatbot--illustration--fill: var(--pf-t--color--white);
|
|
80
|
-
--pf-t--chatbot--code--background: var(--pf-t--color--gray--60);
|
|
81
|
-
|
|
82
|
-
--pf-t--chatbot-toggle--background--hover: var(--pf-t--color--gray--20);
|
|
83
|
-
|
|
84
|
-
--pf-t--chatbot--blue-icon--background--color--hover: var(--pf-t--global--color--brand--hover);
|
|
85
|
-
--pf-t--chatbot--blue-icon--fill--hover: var(--pf-t--global--icon--color--inverse);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
37
|
.ws-full-page-utils {
|
|
89
38
|
left: 0 !important;
|
|
90
39
|
right: auto !important;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import { PickOptional } from '@patternfly/react-core';
|
|
3
|
-
export declare enum ExpandableSectionVariant {
|
|
4
|
-
default = "default",
|
|
5
|
-
truncate = "truncate"
|
|
6
|
-
}
|
|
7
|
-
/** The main expandable section component. */
|
|
8
|
-
export interface ExpandableSectionProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onToggle'> {
|
|
9
|
-
/** Content rendered inside the expandable section. */
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
/** Additional classes added to the expandable section. */
|
|
12
|
-
className?: string;
|
|
13
|
-
/** Id of the content of the expandable section. When passing in the isDetached property, this
|
|
14
|
-
* property's value should match the contentId property of the expandable section toggle sub-component.
|
|
15
|
-
*/
|
|
16
|
-
contentId?: string;
|
|
17
|
-
/** Id of the toggle of the expandable section, which provides an accessible name to the
|
|
18
|
-
* expandable section content via the aria-labelledby attribute. When the isDetached property
|
|
19
|
-
* is also passed in, the value of this property must match the toggleId property of the
|
|
20
|
-
* expandable section toggle sub-component.
|
|
21
|
-
*/
|
|
22
|
-
toggleId?: string;
|
|
23
|
-
/** Display size variant. Set to "lg" for disclosure styling. */
|
|
24
|
-
displaySize?: 'default' | 'lg';
|
|
25
|
-
/** Indicates the expandable section has a detached toggle. */
|
|
26
|
-
isDetached?: boolean;
|
|
27
|
-
/** Flag to indicate if the content is expanded. */
|
|
28
|
-
isExpanded?: boolean;
|
|
29
|
-
/** Flag to indicate if the content is indented. */
|
|
30
|
-
isIndented?: boolean;
|
|
31
|
-
/** Flag to indicate the width of the component is limited. Set to "true" for disclosure styling. */
|
|
32
|
-
isWidthLimited?: boolean;
|
|
33
|
-
/** Truncates the expandable content to the specified number of lines when using the
|
|
34
|
-
* "truncate" variant.
|
|
35
|
-
*/
|
|
36
|
-
truncateMaxLines?: number;
|
|
37
|
-
/** Determines the variant of the expandable section. When passing in "truncate" as the
|
|
38
|
-
* variant, the expandable content will be truncated after 3 lines by default.
|
|
39
|
-
*/
|
|
40
|
-
variant?: 'default' | 'truncate';
|
|
41
|
-
language?: string;
|
|
42
|
-
}
|
|
43
|
-
interface ExpandableSectionState {
|
|
44
|
-
isExpanded: boolean;
|
|
45
|
-
hasToggle: boolean;
|
|
46
|
-
previousWidth: number | undefined;
|
|
47
|
-
}
|
|
48
|
-
declare class ExpandableSectionForSyntaxHighlighter extends Component<ExpandableSectionProps, ExpandableSectionState> {
|
|
49
|
-
static displayName: string;
|
|
50
|
-
constructor(props: ExpandableSectionProps);
|
|
51
|
-
expandableContentRef: import("react").RefObject<HTMLDivElement>;
|
|
52
|
-
observer: any;
|
|
53
|
-
static defaultProps: PickOptional<ExpandableSectionProps>;
|
|
54
|
-
componentDidMount(): void;
|
|
55
|
-
componentDidUpdate(prevProps: ExpandableSectionProps): void;
|
|
56
|
-
componentWillUnmount(): void;
|
|
57
|
-
checkToggleVisibility: () => void;
|
|
58
|
-
resize: () => void;
|
|
59
|
-
handleResize: (...args: any[]) => void;
|
|
60
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
61
|
-
}
|
|
62
|
-
export { ExpandableSectionForSyntaxHighlighter };
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ExpandableSectionForSyntaxHighlighter = exports.ExpandableSectionVariant = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const react_1 = require("react");
|
|
20
|
-
const expandable_section_1 = __importDefault(require("@patternfly/react-styles/css/components/ExpandableSection/expandable-section"));
|
|
21
|
-
const react_styles_1 = require("@patternfly/react-styles");
|
|
22
|
-
const c_expandable_section_m_truncate__content_LineClamp_1 = __importDefault(require("@patternfly/react-tokens/dist/esm/c_expandable_section_m_truncate__content_LineClamp"));
|
|
23
|
-
const react_core_1 = require("@patternfly/react-core");
|
|
24
|
-
var ExpandableSectionVariant;
|
|
25
|
-
(function (ExpandableSectionVariant) {
|
|
26
|
-
ExpandableSectionVariant["default"] = "default";
|
|
27
|
-
ExpandableSectionVariant["truncate"] = "truncate";
|
|
28
|
-
})(ExpandableSectionVariant || (exports.ExpandableSectionVariant = ExpandableSectionVariant = {}));
|
|
29
|
-
const setLineClamp = (element, lines, language, isExpanded) => {
|
|
30
|
-
if (!element || !lines || lines < 1 || typeof isExpanded === 'undefined') {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (language) {
|
|
34
|
-
const selector = `.language-${language.toLowerCase()}`;
|
|
35
|
-
const childElement = element.querySelector(selector);
|
|
36
|
-
if (!childElement) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (isExpanded) {
|
|
40
|
-
// Reset all truncation-related styles to their default values
|
|
41
|
-
childElement.style.removeProperty('-webkit-line-clamp');
|
|
42
|
-
childElement.style.removeProperty('display');
|
|
43
|
-
childElement.style.removeProperty('-webkit-box-orient');
|
|
44
|
-
childElement.style.removeProperty('overflow');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
childElement.style.setProperty('-webkit-line-clamp', lines.toString());
|
|
48
|
-
childElement.style.setProperty('display', '-webkit-box');
|
|
49
|
-
childElement.style.setProperty('-webkit-box-orient', 'vertical');
|
|
50
|
-
childElement.style.setProperty('overflow', 'hidden');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
class ExpandableSectionForSyntaxHighlighter extends react_1.Component {
|
|
55
|
-
constructor(props) {
|
|
56
|
-
var _a;
|
|
57
|
-
super(props);
|
|
58
|
-
this.expandableContentRef = (0, react_1.createRef)();
|
|
59
|
-
/* eslint-disable-next-line */
|
|
60
|
-
this.observer = () => { };
|
|
61
|
-
this.checkToggleVisibility = () => {
|
|
62
|
-
var _a;
|
|
63
|
-
if ((_a = this.expandableContentRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
64
|
-
const maxLines = this.props.truncateMaxLines || parseInt(c_expandable_section_m_truncate__content_LineClamp_1.default.value);
|
|
65
|
-
const totalLines = this.expandableContentRef.current.scrollHeight /
|
|
66
|
-
parseInt(getComputedStyle(this.expandableContentRef.current).lineHeight);
|
|
67
|
-
this.setState({
|
|
68
|
-
hasToggle: totalLines > maxLines
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
this.resize = () => {
|
|
73
|
-
if (this.expandableContentRef.current) {
|
|
74
|
-
const { offsetWidth } = this.expandableContentRef.current;
|
|
75
|
-
if (this.state.previousWidth !== offsetWidth) {
|
|
76
|
-
this.setState({ previousWidth: offsetWidth });
|
|
77
|
-
this.checkToggleVisibility();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
this.handleResize = (0, react_core_1.debounce)(this.resize, 250);
|
|
82
|
-
this.state = {
|
|
83
|
-
isExpanded: (_a = props.isExpanded) !== null && _a !== void 0 ? _a : false,
|
|
84
|
-
hasToggle: true,
|
|
85
|
-
previousWidth: undefined
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
componentDidMount() {
|
|
89
|
-
if (this.props.variant === ExpandableSectionVariant.truncate) {
|
|
90
|
-
const expandableContent = this.expandableContentRef.current;
|
|
91
|
-
if (expandableContent) {
|
|
92
|
-
this.setState({ previousWidth: expandableContent.offsetWidth });
|
|
93
|
-
this.observer = (0, react_core_1.getResizeObserver)(expandableContent, this.handleResize, false);
|
|
94
|
-
if (this.props.truncateMaxLines) {
|
|
95
|
-
setLineClamp(expandableContent, this.props.truncateMaxLines, this.props.language, this.state.isExpanded);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
this.checkToggleVisibility();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
componentDidUpdate(prevProps) {
|
|
102
|
-
if (this.props.variant === ExpandableSectionVariant.truncate &&
|
|
103
|
-
(prevProps.truncateMaxLines !== this.props.truncateMaxLines ||
|
|
104
|
-
prevProps.children !== this.props.children ||
|
|
105
|
-
prevProps.isExpanded !== this.props.isExpanded)) {
|
|
106
|
-
const expandableContent = this.expandableContentRef.current;
|
|
107
|
-
setLineClamp(expandableContent, this.props.truncateMaxLines, this.props.language, this.props.isExpanded);
|
|
108
|
-
this.checkToggleVisibility();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
componentWillUnmount() {
|
|
112
|
-
if (this.props.variant === ExpandableSectionVariant.truncate) {
|
|
113
|
-
this.observer();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
render() {
|
|
117
|
-
const _a = this.props, { className, children, isExpanded, isDetached, displaySize, isWidthLimited, isIndented, contentId, toggleId, variant,
|
|
118
|
-
// Gets rid of console error about it being on a DOM element
|
|
119
|
-
// eslint-disable-next-line
|
|
120
|
-
truncateMaxLines } = _a, props = __rest(_a, ["className", "children", "isExpanded", "isDetached", "displaySize", "isWidthLimited", "isIndented", "contentId", "toggleId", "variant", "truncateMaxLines"]);
|
|
121
|
-
if (isDetached && !toggleId) {
|
|
122
|
-
/* eslint-disable no-console */
|
|
123
|
-
console.warn('ExpandableSection: The toggleId value must be passed in and must match the toggleId of the ExpandableSectionToggle.');
|
|
124
|
-
}
|
|
125
|
-
const uniqueContentId = contentId || (0, react_core_1.getUniqueId)('expandable-section-content');
|
|
126
|
-
const uniqueToggleId = toggleId || (0, react_core_1.getUniqueId)('expandable-section-toggle');
|
|
127
|
-
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, react_styles_1.css)(expandable_section_1.default.expandableSection, isExpanded && expandable_section_1.default.modifiers.expanded, displaySize === 'lg' && expandable_section_1.default.modifiers.displayLg, isWidthLimited && expandable_section_1.default.modifiers.limitWidth, isIndented && expandable_section_1.default.modifiers.indented, variant === ExpandableSectionVariant.truncate && expandable_section_1.default.modifiers.truncate, className) }, props, { children: (0, jsx_runtime_1.jsx)("div", { ref: this.expandableContentRef, className: (0, react_styles_1.css)(expandable_section_1.default.expandableSectionContent), hidden: variant !== ExpandableSectionVariant.truncate && !isExpanded, id: uniqueContentId, "aria-labelledby": uniqueToggleId, role: "region", children: children }) })));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.ExpandableSectionForSyntaxHighlighter = ExpandableSectionForSyntaxHighlighter;
|
|
131
|
-
ExpandableSectionForSyntaxHighlighter.displayName = 'ExpandableSection';
|
|
132
|
-
ExpandableSectionForSyntaxHighlighter.defaultProps = {
|
|
133
|
-
className: '',
|
|
134
|
-
isDetached: false,
|
|
135
|
-
displaySize: 'default',
|
|
136
|
-
isWidthLimited: false,
|
|
137
|
-
isIndented: false,
|
|
138
|
-
variant: 'default'
|
|
139
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import { PickOptional } from '@patternfly/react-core';
|
|
3
|
-
export declare enum ExpandableSectionVariant {
|
|
4
|
-
default = "default",
|
|
5
|
-
truncate = "truncate"
|
|
6
|
-
}
|
|
7
|
-
/** The main expandable section component. */
|
|
8
|
-
export interface ExpandableSectionProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onToggle'> {
|
|
9
|
-
/** Content rendered inside the expandable section. */
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
/** Additional classes added to the expandable section. */
|
|
12
|
-
className?: string;
|
|
13
|
-
/** Id of the content of the expandable section. When passing in the isDetached property, this
|
|
14
|
-
* property's value should match the contentId property of the expandable section toggle sub-component.
|
|
15
|
-
*/
|
|
16
|
-
contentId?: string;
|
|
17
|
-
/** Id of the toggle of the expandable section, which provides an accessible name to the
|
|
18
|
-
* expandable section content via the aria-labelledby attribute. When the isDetached property
|
|
19
|
-
* is also passed in, the value of this property must match the toggleId property of the
|
|
20
|
-
* expandable section toggle sub-component.
|
|
21
|
-
*/
|
|
22
|
-
toggleId?: string;
|
|
23
|
-
/** Display size variant. Set to "lg" for disclosure styling. */
|
|
24
|
-
displaySize?: 'default' | 'lg';
|
|
25
|
-
/** Indicates the expandable section has a detached toggle. */
|
|
26
|
-
isDetached?: boolean;
|
|
27
|
-
/** Flag to indicate if the content is expanded. */
|
|
28
|
-
isExpanded?: boolean;
|
|
29
|
-
/** Flag to indicate if the content is indented. */
|
|
30
|
-
isIndented?: boolean;
|
|
31
|
-
/** Flag to indicate the width of the component is limited. Set to "true" for disclosure styling. */
|
|
32
|
-
isWidthLimited?: boolean;
|
|
33
|
-
/** Truncates the expandable content to the specified number of lines when using the
|
|
34
|
-
* "truncate" variant.
|
|
35
|
-
*/
|
|
36
|
-
truncateMaxLines?: number;
|
|
37
|
-
/** Determines the variant of the expandable section. When passing in "truncate" as the
|
|
38
|
-
* variant, the expandable content will be truncated after 3 lines by default.
|
|
39
|
-
*/
|
|
40
|
-
variant?: 'default' | 'truncate';
|
|
41
|
-
language?: string;
|
|
42
|
-
}
|
|
43
|
-
interface ExpandableSectionState {
|
|
44
|
-
isExpanded: boolean;
|
|
45
|
-
hasToggle: boolean;
|
|
46
|
-
previousWidth: number | undefined;
|
|
47
|
-
}
|
|
48
|
-
declare class ExpandableSectionForSyntaxHighlighter extends Component<ExpandableSectionProps, ExpandableSectionState> {
|
|
49
|
-
static displayName: string;
|
|
50
|
-
constructor(props: ExpandableSectionProps);
|
|
51
|
-
expandableContentRef: import("react").RefObject<HTMLDivElement>;
|
|
52
|
-
observer: any;
|
|
53
|
-
static defaultProps: PickOptional<ExpandableSectionProps>;
|
|
54
|
-
componentDidMount(): void;
|
|
55
|
-
componentDidUpdate(prevProps: ExpandableSectionProps): void;
|
|
56
|
-
componentWillUnmount(): void;
|
|
57
|
-
checkToggleVisibility: () => void;
|
|
58
|
-
resize: () => void;
|
|
59
|
-
handleResize: (...args: any[]) => void;
|
|
60
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
61
|
-
}
|
|
62
|
-
export { ExpandableSectionForSyntaxHighlighter };
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { Component, createRef } from 'react';
|
|
14
|
-
import styles from '@patternfly/react-styles/css/components/ExpandableSection/expandable-section';
|
|
15
|
-
import { css } from '@patternfly/react-styles';
|
|
16
|
-
import lineClamp from '@patternfly/react-tokens/dist/esm/c_expandable_section_m_truncate__content_LineClamp';
|
|
17
|
-
import { debounce, getResizeObserver, getUniqueId } from '@patternfly/react-core';
|
|
18
|
-
export var ExpandableSectionVariant;
|
|
19
|
-
(function (ExpandableSectionVariant) {
|
|
20
|
-
ExpandableSectionVariant["default"] = "default";
|
|
21
|
-
ExpandableSectionVariant["truncate"] = "truncate";
|
|
22
|
-
})(ExpandableSectionVariant || (ExpandableSectionVariant = {}));
|
|
23
|
-
const setLineClamp = (element, lines, language, isExpanded) => {
|
|
24
|
-
if (!element || !lines || lines < 1 || typeof isExpanded === 'undefined') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (language) {
|
|
28
|
-
const selector = `.language-${language.toLowerCase()}`;
|
|
29
|
-
const childElement = element.querySelector(selector);
|
|
30
|
-
if (!childElement) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (isExpanded) {
|
|
34
|
-
// Reset all truncation-related styles to their default values
|
|
35
|
-
childElement.style.removeProperty('-webkit-line-clamp');
|
|
36
|
-
childElement.style.removeProperty('display');
|
|
37
|
-
childElement.style.removeProperty('-webkit-box-orient');
|
|
38
|
-
childElement.style.removeProperty('overflow');
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
childElement.style.setProperty('-webkit-line-clamp', lines.toString());
|
|
42
|
-
childElement.style.setProperty('display', '-webkit-box');
|
|
43
|
-
childElement.style.setProperty('-webkit-box-orient', 'vertical');
|
|
44
|
-
childElement.style.setProperty('overflow', 'hidden');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
class ExpandableSectionForSyntaxHighlighter extends Component {
|
|
49
|
-
constructor(props) {
|
|
50
|
-
var _a;
|
|
51
|
-
super(props);
|
|
52
|
-
this.expandableContentRef = createRef();
|
|
53
|
-
/* eslint-disable-next-line */
|
|
54
|
-
this.observer = () => { };
|
|
55
|
-
this.checkToggleVisibility = () => {
|
|
56
|
-
var _a;
|
|
57
|
-
if ((_a = this.expandableContentRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
58
|
-
const maxLines = this.props.truncateMaxLines || parseInt(lineClamp.value);
|
|
59
|
-
const totalLines = this.expandableContentRef.current.scrollHeight /
|
|
60
|
-
parseInt(getComputedStyle(this.expandableContentRef.current).lineHeight);
|
|
61
|
-
this.setState({
|
|
62
|
-
hasToggle: totalLines > maxLines
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
this.resize = () => {
|
|
67
|
-
if (this.expandableContentRef.current) {
|
|
68
|
-
const { offsetWidth } = this.expandableContentRef.current;
|
|
69
|
-
if (this.state.previousWidth !== offsetWidth) {
|
|
70
|
-
this.setState({ previousWidth: offsetWidth });
|
|
71
|
-
this.checkToggleVisibility();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
this.handleResize = debounce(this.resize, 250);
|
|
76
|
-
this.state = {
|
|
77
|
-
isExpanded: (_a = props.isExpanded) !== null && _a !== void 0 ? _a : false,
|
|
78
|
-
hasToggle: true,
|
|
79
|
-
previousWidth: undefined
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
componentDidMount() {
|
|
83
|
-
if (this.props.variant === ExpandableSectionVariant.truncate) {
|
|
84
|
-
const expandableContent = this.expandableContentRef.current;
|
|
85
|
-
if (expandableContent) {
|
|
86
|
-
this.setState({ previousWidth: expandableContent.offsetWidth });
|
|
87
|
-
this.observer = getResizeObserver(expandableContent, this.handleResize, false);
|
|
88
|
-
if (this.props.truncateMaxLines) {
|
|
89
|
-
setLineClamp(expandableContent, this.props.truncateMaxLines, this.props.language, this.state.isExpanded);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
this.checkToggleVisibility();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
componentDidUpdate(prevProps) {
|
|
96
|
-
if (this.props.variant === ExpandableSectionVariant.truncate &&
|
|
97
|
-
(prevProps.truncateMaxLines !== this.props.truncateMaxLines ||
|
|
98
|
-
prevProps.children !== this.props.children ||
|
|
99
|
-
prevProps.isExpanded !== this.props.isExpanded)) {
|
|
100
|
-
const expandableContent = this.expandableContentRef.current;
|
|
101
|
-
setLineClamp(expandableContent, this.props.truncateMaxLines, this.props.language, this.props.isExpanded);
|
|
102
|
-
this.checkToggleVisibility();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
componentWillUnmount() {
|
|
106
|
-
if (this.props.variant === ExpandableSectionVariant.truncate) {
|
|
107
|
-
this.observer();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
render() {
|
|
111
|
-
const _a = this.props, { className, children, isExpanded, isDetached, displaySize, isWidthLimited, isIndented, contentId, toggleId, variant,
|
|
112
|
-
// Gets rid of console error about it being on a DOM element
|
|
113
|
-
// eslint-disable-next-line
|
|
114
|
-
truncateMaxLines } = _a, props = __rest(_a, ["className", "children", "isExpanded", "isDetached", "displaySize", "isWidthLimited", "isIndented", "contentId", "toggleId", "variant", "truncateMaxLines"]);
|
|
115
|
-
if (isDetached && !toggleId) {
|
|
116
|
-
/* eslint-disable no-console */
|
|
117
|
-
console.warn('ExpandableSection: The toggleId value must be passed in and must match the toggleId of the ExpandableSectionToggle.');
|
|
118
|
-
}
|
|
119
|
-
const uniqueContentId = contentId || getUniqueId('expandable-section-content');
|
|
120
|
-
const uniqueToggleId = toggleId || getUniqueId('expandable-section-toggle');
|
|
121
|
-
return (_jsx("div", Object.assign({ className: css(styles.expandableSection, isExpanded && styles.modifiers.expanded, displaySize === 'lg' && styles.modifiers.displayLg, isWidthLimited && styles.modifiers.limitWidth, isIndented && styles.modifiers.indented, variant === ExpandableSectionVariant.truncate && styles.modifiers.truncate, className) }, props, { children: _jsx("div", { ref: this.expandableContentRef, className: css(styles.expandableSectionContent), hidden: variant !== ExpandableSectionVariant.truncate && !isExpanded, id: uniqueContentId, "aria-labelledby": uniqueToggleId, role: "region", children: children }) })));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
ExpandableSectionForSyntaxHighlighter.displayName = 'ExpandableSection';
|
|
125
|
-
ExpandableSectionForSyntaxHighlighter.defaultProps = {
|
|
126
|
-
className: '',
|
|
127
|
-
isDetached: false,
|
|
128
|
-
displaySize: 'default',
|
|
129
|
-
isWidthLimited: false,
|
|
130
|
-
isIndented: false,
|
|
131
|
-
variant: 'default'
|
|
132
|
-
};
|
|
133
|
-
export { ExpandableSectionForSyntaxHighlighter };
|