@patternfly/react-code-editor 5.0.0-alpha.5 → 5.0.0-alpha.50

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,13 +7,14 @@ import {
7
7
  EmptyState,
8
8
  EmptyStateBody,
9
9
  EmptyStateIcon,
10
- EmptyStateSecondaryActions,
10
+ EmptyStateActions,
11
11
  EmptyStateVariant,
12
+ EmptyStateFooter,
12
13
  getResizeObserver,
13
14
  Popover,
14
15
  PopoverProps,
15
- Title,
16
- TooltipPosition
16
+ TooltipPosition,
17
+ EmptyStateHeader
17
18
  } from '@patternfly/react-core';
18
19
  import MonacoEditor, { ChangeHandler, EditorDidMount } from 'react-monaco-editor';
19
20
  import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
@@ -382,7 +383,7 @@ export class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState
382
383
  editorDidMount: EditorDidMount = (editor, monaco) => {
383
384
  // eslint-disable-next-line no-bitwise
384
385
  editor.addCommand(monaco.KeyMod.Shift | monaco.KeyCode.Tab, () => this.wrapperRef.current.focus());
385
- Array.from(document.getElementsByClassName('monaco-editor')).forEach(editorElement =>
386
+ Array.from(document.getElementsByClassName('monaco-editor')).forEach((editorElement) =>
386
387
  editorElement.removeAttribute('role')
387
388
  );
388
389
  this.props.onEditorDidMount(editor, monaco);
@@ -418,7 +419,7 @@ export class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState
418
419
  this.handleFileChange('', fileHandle.name); // Show the filename while reading
419
420
  this.handleFileReadStarted();
420
421
  this.readFile(fileHandle)
421
- .then(data => {
422
+ .then((data) => {
422
423
  this.handleFileReadFinished();
423
424
  this.toggleEmptyState();
424
425
  this.handleFileChange(data, fileHandle.name);
@@ -518,30 +519,40 @@ export class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState
518
519
  const emptyState =
519
520
  providedEmptyState ||
520
521
  (isUploadEnabled ? (
521
- <EmptyState variant={EmptyStateVariant.small}>
522
- <EmptyStateIcon icon={CodeIcon} />
523
- <Title headingLevel="h4" size="lg">
524
- {emptyStateTitle}
525
- </Title>
522
+ <EmptyState variant={EmptyStateVariant.sm}>
523
+ <EmptyStateHeader
524
+ titleText={emptyStateTitle}
525
+ icon={<EmptyStateIcon icon={CodeIcon} />}
526
+ headingLevel="h4"
527
+ />
526
528
  <EmptyStateBody>{emptyStateBody}</EmptyStateBody>
527
- <Button variant="primary" onClick={open}>
528
- {emptyStateButton}
529
- </Button>
530
- <EmptyStateSecondaryActions>
531
- <Button variant="link" onClick={this.toggleEmptyState}>
532
- {emptyStateLink}
533
- </Button>
534
- </EmptyStateSecondaryActions>
529
+ <EmptyStateFooter>
530
+ <EmptyStateActions>
531
+ <Button variant="primary" onClick={open}>
532
+ {emptyStateButton}
533
+ </Button>
534
+ </EmptyStateActions>
535
+ <EmptyStateActions>
536
+ <Button variant="link" onClick={this.toggleEmptyState}>
537
+ {emptyStateLink}
538
+ </Button>
539
+ </EmptyStateActions>
540
+ </EmptyStateFooter>
535
541
  </EmptyState>
536
542
  ) : (
537
- <EmptyState variant={EmptyStateVariant.small}>
538
- <EmptyStateIcon icon={CodeIcon} />
539
- <Title headingLevel="h4" size="lg">
540
- {emptyStateTitle}
541
- </Title>
542
- <Button variant="primary" onClick={this.toggleEmptyState}>
543
- {emptyStateLink}
544
- </Button>
543
+ <EmptyState variant={EmptyStateVariant.sm}>
544
+ <EmptyStateHeader
545
+ titleText={emptyStateTitle}
546
+ icon={<EmptyStateIcon icon={CodeIcon} />}
547
+ headingLevel="h4"
548
+ />
549
+ <EmptyStateFooter>
550
+ <EmptyStateActions>
551
+ <Button variant="primary" onClick={this.toggleEmptyState}>
552
+ {emptyStateLink}
553
+ </Button>
554
+ </EmptyStateActions>
555
+ </EmptyStateFooter>
545
556
  </EmptyState>
546
557
  ));
547
558
 
@@ -634,7 +645,7 @@ export class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState
634
645
  {isUploadEnabled || providedEmptyState ? (
635
646
  <div
636
647
  {...getRootProps({
637
- onClick: event => event.preventDefault() // Prevents clicking TextArea from opening file dialog
648
+ onClick: (event) => event.preventDefault() // Prevents clicking TextArea from opening file dialog
638
649
  })}
639
650
  className={`pf-c-file-upload ${isDragActive && 'pf-m-drag-hover'} ${isLoading && 'pf-m-loading'}`}
640
651
  >
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Button, ButtonProps, PopoverPosition, Tooltip } from '@patternfly/react-core';
2
+ import { Button, ButtonProps, Tooltip } from '@patternfly/react-core';
3
3
  import { CodeEditorContext } from './CodeEditorUtils';
4
4
 
5
5
  /** Allows customizing the code editor controls by passing this sub-component into the
@@ -11,32 +11,8 @@ export interface CodeEditorControlProps extends Omit<ButtonProps, 'onClick'> {
11
11
  'aria-label'?: string;
12
12
  /** Additional classes added to the code editor control. */
13
13
  className?: string;
14
- /** @deprecated Delay in ms before the tooltip appears. */
15
- entryDelay?: number;
16
- /** @deprecated Delay in ms before the tooltip disappears. */
17
- exitDelay?: number;
18
14
  /** Icon rendered inside the code editor control. */
19
15
  icon: React.ReactNode;
20
- /** @deprecated Maximum width of the tooltip (default 150px). */
21
- maxWidth?: string;
22
- /** @deprecated Copy button popover position. */
23
- position?:
24
- | PopoverPosition
25
- | 'auto'
26
- | 'top'
27
- | 'bottom'
28
- | 'left'
29
- | 'right'
30
- | 'top-start'
31
- | 'top-end'
32
- | 'bottom-start'
33
- | 'bottom-end'
34
- | 'left-start'
35
- | 'left-end'
36
- | 'right-start'
37
- | 'right-end';
38
- /** @deprecated Text to display in the tooltip*/
39
- toolTipText?: React.ReactNode;
40
16
  /** Event handler for the click of the button */
41
17
  onClick: (code: string, event?: any) => void;
42
18
  /** Flag indicating that the button is visible above the code editor. */
@@ -49,11 +25,6 @@ export const CodeEditorControl: React.FunctionComponent<CodeEditorControlProps>
49
25
  icon,
50
26
  className,
51
27
  'aria-label': ariaLabel,
52
- toolTipText,
53
- exitDelay,
54
- entryDelay,
55
- maxWidth,
56
- position,
57
28
  onClick = () => {},
58
29
  isVisible = true,
59
30
  tooltipProps = {},
@@ -61,57 +32,12 @@ export const CodeEditorControl: React.FunctionComponent<CodeEditorControlProps>
61
32
  }: CodeEditorControlProps) => {
62
33
  const context = React.useContext(CodeEditorContext);
63
34
 
64
- if (entryDelay !== undefined) {
65
- // eslint-disable-next-line no-console
66
- console.warn(
67
- 'CodeEditorControl: entryDelay prop has been deprecated. ' +
68
- 'Pass the entryDelay via the tooltipProps prop instead.'
69
- );
70
- }
71
-
72
- if (exitDelay !== undefined) {
73
- // eslint-disable-next-line no-console
74
- console.warn(
75
- 'CodeEditorControl: exitDelay prop has been deprecated. ' +
76
- 'Pass the exitDelay via the tooltipProps prop instead.'
77
- );
78
- }
79
-
80
- if (maxWidth !== undefined) {
81
- // eslint-disable-next-line no-console
82
- console.warn(
83
- 'CodeEditorControl: maxWidth prop has been deprecated. ' + 'Pass the maxWidth via the tooltipProps prop instead.'
84
- );
85
- }
86
-
87
- if (position !== undefined) {
88
- // eslint-disable-next-line no-console
89
- console.warn(
90
- 'CodeEditorControl: position prop has been deprecated. ' + 'Pass the position via the tooltipProps prop instead.'
91
- );
92
- }
93
-
94
- if (toolTipText !== undefined) {
95
- // eslint-disable-next-line no-console
96
- console.warn(
97
- 'CodeEditorControl: toolTipText prop has been deprecated. ' +
98
- 'Pass the toolTipText by setting the content field in tooltipProps prop instead.'
99
- );
100
- }
101
-
102
35
  const onCustomClick = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
103
36
  onClick(context.code, event);
104
37
  };
105
38
 
106
39
  return isVisible ? (
107
- <Tooltip
108
- exitDelay={exitDelay}
109
- entryDelay={entryDelay}
110
- maxWidth={maxWidth}
111
- position={position}
112
- content={<div>{toolTipText}</div>}
113
- {...tooltipProps}
114
- >
40
+ <Tooltip {...tooltipProps}>
115
41
  <Button className={className} onClick={onCustomClick} variant="control" aria-label={ariaLabel} {...props}>
116
42
  {icon}
117
43
  </Button>
@@ -40,7 +40,7 @@ export const CodeEditorBasic: React.FunctionComponent = () => {
40
40
  <Checkbox
41
41
  label="Dark theme"
42
42
  isChecked={isDarkTheme}
43
- onChange={toggleDarkTheme}
43
+ onChange={(_event, checked) => toggleDarkTheme(checked)}
44
44
  aria-label="dark theme checkbox"
45
45
  id="toggle-theme"
46
46
  name="toggle-theme"
@@ -48,7 +48,7 @@ export const CodeEditorBasic: React.FunctionComponent = () => {
48
48
  <Checkbox
49
49
  label="Line numbers"
50
50
  isChecked={isLineNumbersVisible}
51
- onChange={toggleLineNumbers}
51
+ onChange={(_event, checked) => toggleLineNumbers(checked)}
52
52
  aria-label="line numbers checkbox"
53
53
  id="toggle-line-numbers"
54
54
  name="toggle-line-numbers"
@@ -56,7 +56,7 @@ export const CodeEditorBasic: React.FunctionComponent = () => {
56
56
  <Checkbox
57
57
  label="Read only"
58
58
  isChecked={isReadOnly}
59
- onChange={toggleReadOnly}
59
+ onChange={(_event, checked) => toggleReadOnly(checked)}
60
60
  aria-label="read only checkbox"
61
61
  id="toggle-read-only"
62
62
  name="toggle-read-only"
@@ -64,7 +64,7 @@ export const CodeEditorBasic: React.FunctionComponent = () => {
64
64
  <Checkbox
65
65
  label="Minimap"
66
66
  isChecked={isMinimapVisible}
67
- onChange={toggleMinimap}
67
+ onChange={(_event, checked) => toggleMinimap(checked)}
68
68
  aria-label="display minimap checkbox"
69
69
  id="toggle-minimap"
70
70
  name="toggle-minimap"