@patternfly/react-code-editor 6.2.0-prerelease.8 → 6.2.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/dist/esm/components/CodeEditor/CodeEditor.d.ts +3 -3
  3. package/dist/esm/components/CodeEditor/CodeEditor.d.ts.map +1 -1
  4. package/dist/esm/components/CodeEditor/CodeEditor.js +33 -58
  5. package/dist/esm/components/CodeEditor/CodeEditor.js.map +1 -1
  6. package/dist/esm/components/CodeEditor/CodeEditorControl.d.ts +1 -1
  7. package/dist/esm/components/CodeEditor/CodeEditorControl.d.ts.map +1 -1
  8. package/dist/esm/components/CodeEditor/CodeEditorControl.js +4 -4
  9. package/dist/esm/components/CodeEditor/CodeEditorControl.js.map +1 -1
  10. package/dist/esm/components/CodeEditor/CodeEditorUtils.d.ts +2 -2
  11. package/dist/esm/components/CodeEditor/CodeEditorUtils.d.ts.map +1 -1
  12. package/dist/esm/components/CodeEditor/CodeEditorUtils.js +2 -2
  13. package/dist/esm/components/CodeEditor/CodeEditorUtils.js.map +1 -1
  14. package/dist/js/components/CodeEditor/CodeEditor.d.ts +3 -3
  15. package/dist/js/components/CodeEditor/CodeEditor.d.ts.map +1 -1
  16. package/dist/js/components/CodeEditor/CodeEditor.js +34 -59
  17. package/dist/js/components/CodeEditor/CodeEditor.js.map +1 -1
  18. package/dist/js/components/CodeEditor/CodeEditorControl.d.ts +1 -1
  19. package/dist/js/components/CodeEditor/CodeEditorControl.d.ts.map +1 -1
  20. package/dist/js/components/CodeEditor/CodeEditorControl.js +4 -4
  21. package/dist/js/components/CodeEditor/CodeEditorControl.js.map +1 -1
  22. package/dist/js/components/CodeEditor/CodeEditorUtils.d.ts +2 -2
  23. package/dist/js/components/CodeEditor/CodeEditorUtils.d.ts.map +1 -1
  24. package/dist/js/components/CodeEditor/CodeEditorUtils.js +2 -3
  25. package/dist/js/components/CodeEditor/CodeEditorUtils.js.map +1 -1
  26. package/package.json +5 -5
  27. package/src/components/CodeEditor/CodeEditor.tsx +29 -15
  28. package/src/components/CodeEditor/CodeEditorControl.tsx +2 -2
  29. package/src/components/CodeEditor/CodeEditorUtils.ts +2 -2
  30. package/src/components/CodeEditor/__test__/CodeEditor.test.tsx +3 -5
  31. package/src/components/CodeEditor/__test__/CodeEditorControl.test.tsx +0 -1
  32. package/src/components/CodeEditor/__test__/__snapshots__/CodeEditor.test.tsx.snap +102 -111
  33. package/src/components/CodeEditor/__test__/__snapshots__/CodeEditorControl.test.tsx.snap +0 -1
  34. package/src/components/CodeEditor/examples/CodeEditor.md +1 -0
  35. package/src/components/CodeEditor/examples/CodeEditorBasic.tsx +5 -5
  36. package/src/components/CodeEditor/examples/CodeEditorCustomControl.tsx +2 -2
  37. package/src/components/CodeEditor/examples/CodeEditorFullHeight.tsx +0 -1
  38. package/src/components/CodeEditor/examples/CodeEditorShortcutMainHeader.tsx +4 -4
  39. package/src/components/CodeEditor/examples/CodeEditorSizeToFit.tsx +0 -1
  40. package/src/components/CodeEditor/examples/CodeEditorWithActions.tsx +0 -1
@@ -6,139 +6,124 @@ exports[`Matches snapshot with control buttons enabled 1`] = `
6
6
  class="pf-v6-c-code-editor"
7
7
  >
8
8
  <div
9
- class="pf-v6-c-code-editor__container"
10
- role="presentation"
11
- tabindex="0"
9
+ class="pf-v6-c-code-editor__header"
12
10
  >
13
11
  <div
14
- class="pf-v6-c-code-editor__header"
12
+ class="pf-v6-c-code-editor__header-content"
15
13
  >
16
14
  <div
17
- class="pf-v6-c-code-editor__header-content"
15
+ class="pf-v6-c-code-editor__controls"
18
16
  >
19
17
  <div
20
- class="pf-v6-c-code-editor__controls"
18
+ style="display: contents;"
21
19
  >
22
- <div
23
- style="display: contents;"
20
+ <button
21
+ aria-label="Copy code to clipboard"
22
+ class="pf-v6-c-button pf-m-plain"
23
+ data-ouia-component-id="OUIA-Generated-Button-plain-1"
24
+ data-ouia-component-type="PF6/Button"
25
+ data-ouia-safe="true"
26
+ type="button"
24
27
  >
25
- <button
26
- aria-disabled="false"
27
- aria-label="Copy code to clipboard"
28
- class="pf-v6-c-button pf-m-plain"
29
- data-ouia-component-id="OUIA-Generated-Button-plain-1"
30
- data-ouia-component-type="PF6/Button"
31
- data-ouia-safe="true"
32
- type="button"
28
+ <span
29
+ class="pf-v6-c-button__icon"
33
30
  >
34
- <span
35
- class="pf-v6-c-button__icon"
31
+ <svg
32
+ aria-hidden="true"
33
+ class="pf-v6-svg"
34
+ fill="currentColor"
35
+ height="1em"
36
+ role="img"
37
+ viewBox="0 0 448 512"
38
+ width="1em"
36
39
  >
37
- <svg
38
- aria-hidden="true"
39
- class="pf-v6-svg"
40
- fill="currentColor"
41
- height="1em"
42
- role="img"
43
- viewBox="0 0 448 512"
44
- width="1em"
45
- >
46
- <path
47
- d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
48
- />
49
- </svg>
50
- </span>
51
- </button>
52
- </div>
53
- <div
54
- style="display: contents;"
40
+ <path
41
+ d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
42
+ />
43
+ </svg>
44
+ </span>
45
+ </button>
46
+ </div>
47
+ <div
48
+ style="display: contents;"
49
+ >
50
+ <button
51
+ aria-label="Upload code"
52
+ class="pf-v6-c-button pf-m-plain"
53
+ data-ouia-component-id="OUIA-Generated-Button-plain-2"
54
+ data-ouia-component-type="PF6/Button"
55
+ data-ouia-safe="true"
56
+ type="button"
55
57
  >
56
- <button
57
- aria-disabled="false"
58
- aria-label="Upload code"
59
- class="pf-v6-c-button pf-m-plain"
60
- data-ouia-component-id="OUIA-Generated-Button-plain-2"
61
- data-ouia-component-type="PF6/Button"
62
- data-ouia-safe="true"
63
- type="button"
58
+ <span
59
+ class="pf-v6-c-button__icon"
64
60
  >
65
- <span
66
- class="pf-v6-c-button__icon"
61
+ <svg
62
+ aria-hidden="true"
63
+ class="pf-v6-svg"
64
+ fill="currentColor"
65
+ height="1em"
66
+ role="img"
67
+ viewBox="0 0 512 512"
68
+ width="1em"
67
69
  >
68
- <svg
69
- aria-hidden="true"
70
- class="pf-v6-svg"
71
- fill="currentColor"
72
- height="1em"
73
- role="img"
74
- viewBox="0 0 512 512"
75
- width="1em"
76
- >
77
- <path
78
- d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
79
- />
80
- </svg>
81
- </span>
82
- </button>
83
- </div>
84
- <div
85
- style="display: contents;"
70
+ <path
71
+ d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
72
+ />
73
+ </svg>
74
+ </span>
75
+ </button>
76
+ </div>
77
+ <div
78
+ style="display: contents;"
79
+ >
80
+ <button
81
+ aria-label="Download code"
82
+ class="pf-v6-c-button pf-m-plain"
83
+ data-ouia-component-id="OUIA-Generated-Button-plain-3"
84
+ data-ouia-component-type="PF6/Button"
85
+ data-ouia-safe="true"
86
+ type="button"
86
87
  >
87
- <button
88
- aria-disabled="false"
89
- aria-label="Download code"
90
- class="pf-v6-c-button pf-m-plain"
91
- data-ouia-component-id="OUIA-Generated-Button-plain-3"
92
- data-ouia-component-type="PF6/Button"
93
- data-ouia-safe="true"
94
- type="button"
88
+ <span
89
+ class="pf-v6-c-button__icon"
95
90
  >
96
- <span
97
- class="pf-v6-c-button__icon"
91
+ <svg
92
+ aria-hidden="true"
93
+ class="pf-v6-svg"
94
+ fill="currentColor"
95
+ height="1em"
96
+ role="img"
97
+ viewBox="0 0 512 512"
98
+ width="1em"
98
99
  >
99
- <svg
100
- aria-hidden="true"
101
- class="pf-v6-svg"
102
- fill="currentColor"
103
- height="1em"
104
- role="img"
105
- viewBox="0 0 512 512"
106
- width="1em"
107
- >
108
- <path
109
- d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
110
- />
111
- </svg>
112
- </span>
113
- </button>
114
- </div>
100
+ <path
101
+ d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
102
+ />
103
+ </svg>
104
+ </span>
105
+ </button>
115
106
  </div>
116
- <div
117
- class="pf-v6-c-code-editor__header-main"
118
- />
119
107
  </div>
120
108
  </div>
109
+ </div>
110
+ <div
111
+ class="pf-v6-c-code-editor__main"
112
+ >
113
+ <input
114
+ hidden=""
115
+ style="border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); height: 1px; margin: 0px -1px -1px 0px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap;"
116
+ tabindex="-1"
117
+ type="file"
118
+ />
121
119
  <div
122
- class="pf-v6-c-code-editor__main"
120
+ class="pf-v6-c-code-editor__code"
121
+ dir="ltr"
122
+ tabindex="0"
123
123
  >
124
124
  <div
125
- class="pf-v6-c-code-editor__upload"
126
- >
127
- <input
128
- style="border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); height: 1px; margin: 0px -1px -1px 0px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap;"
129
- tabindex="-1"
130
- type="file"
131
- />
132
- <div
133
- class="pf-v6-c-code-editor__code"
134
- dir="ltr"
135
- tabindex="0"
136
- >
137
- <div
138
- data-testid="mock-editor"
139
- />
140
- </div>
141
- </div>
125
+ data-testid="mock-editor"
126
+ />
142
127
  </div>
143
128
  </div>
144
129
  </div>
@@ -156,6 +141,12 @@ exports[`Matches snapshot without props 1`] = `
156
141
  <div
157
142
  class="pf-v6-c-code-editor__main"
158
143
  >
144
+ <input
145
+ hidden=""
146
+ style="border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); height: 1px; margin: 0px -1px -1px 0px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap;"
147
+ tabindex="-1"
148
+ type="file"
149
+ />
159
150
  <div
160
151
  class="pf-v6-c-code-editor__code"
161
152
  dir="ltr"
@@ -6,7 +6,6 @@ exports[`Matches snapshot 1`] = `
6
6
  style="display: contents;"
7
7
  >
8
8
  <button
9
- aria-disabled="false"
10
9
  class="pf-v6-c-button pf-m-plain"
11
10
  data-ouia-component-id="OUIA-Generated-Button-plain-1"
12
11
  data-ouia-component-type="PF6/Button"
@@ -7,6 +7,7 @@ propComponents: ['CodeEditor', 'CodeEditorControl', 'Popover']
7
7
 
8
8
  Note: Code editor lives in its own package at [@patternfly/react-code-editor](https://www.npmjs.com/package/@patternfly/react-code-editor) and has [**required peer deps**](https://github.com/patternfly/patternfly-react/blob/main/packages/react-code-editor/package.json).
9
9
 
10
+ import { Fragment, useState } from 'react';
10
11
  import { CodeEditor, CodeEditorControl, Language } from '@patternfly/react-code-editor';
11
12
  import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
12
13
 
@@ -1,12 +1,12 @@
1
- import React from 'react';
1
+ import { useState } from 'react';
2
2
  import { CodeEditor, Language } from '@patternfly/react-code-editor';
3
3
  import { Checkbox } from '@patternfly/react-core';
4
4
 
5
5
  export const CodeEditorBasic: React.FunctionComponent = () => {
6
- const [isDarkTheme, setIsDarkTheme] = React.useState(false);
7
- const [isLineNumbersVisible, setIsLineNumbersVisible] = React.useState(true);
8
- const [isReadOnly, setIsReadOnly] = React.useState(false);
9
- const [isMinimapVisible, setIsMinimapVisible] = React.useState(false);
6
+ const [isDarkTheme, setIsDarkTheme] = useState(false);
7
+ const [isLineNumbersVisible, setIsLineNumbersVisible] = useState(true);
8
+ const [isReadOnly, setIsReadOnly] = useState(false);
9
+ const [isMinimapVisible, setIsMinimapVisible] = useState(false);
10
10
 
11
11
  const toggleDarkTheme = (checked) => {
12
12
  setIsDarkTheme(checked);
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ import { useState } from 'react';
2
2
  import { CodeEditor, CodeEditorControl } from '@patternfly/react-code-editor';
3
3
  import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
4
4
 
5
5
  export const CodeEditorCustomControl: React.FunctionComponent = () => {
6
- const [code, setCode] = React.useState('Some example content');
6
+ const [code, setCode] = useState('Some example content');
7
7
 
8
8
  const onChange = (code) => {
9
9
  setCode(code);
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { CodeEditor, Language } from '@patternfly/react-code-editor';
3
2
 
4
3
  export const CodeEditorFullHeight: React.FunctionComponent = () => {
@@ -1,11 +1,11 @@
1
- import React from 'react';
1
+ import { Fragment, useState } from 'react';
2
2
  import { CodeEditor, Language } from '@patternfly/react-code-editor';
3
3
  import { Grid, GridItem, Label, Radio } from '@patternfly/react-core';
4
4
 
5
5
  export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
6
6
  type ShortcutMode = 'PC' | 'Mac';
7
7
 
8
- const [currentShortcutMode, setCurrentShortcutMode] = React.useState<ShortcutMode>('PC');
8
+ const [currentShortcutMode, setCurrentShortcutMode] = useState<ShortcutMode>('PC');
9
9
 
10
10
  const onEditorDidMount = (editor, monaco) => {
11
11
  editor.layout();
@@ -51,7 +51,7 @@ export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
51
51
  bodyContent: (
52
52
  <Grid span={6} hasGutter key="grid">
53
53
  {shortcuts.map((shortcut, index) => (
54
- <React.Fragment key={index}>
54
+ <Fragment key={index}>
55
55
  <GridItem style={{ textAlign: 'right', marginRight: '1em' }}>
56
56
  {shortcut[currentShortcutMode]
57
57
  .map((key) => (
@@ -64,7 +64,7 @@ export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
64
64
  ))}
65
65
  </GridItem>
66
66
  <GridItem>{shortcut.description}</GridItem>
67
- </React.Fragment>
67
+ </Fragment>
68
68
  ))}
69
69
  </Grid>
70
70
  ),
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { CodeEditor, Language } from '@patternfly/react-code-editor';
3
2
 
4
3
  export const CodeEditorSizeToFit: React.FunctionComponent = () => {
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { CodeEditor } from '@patternfly/react-code-editor';
3
2
 
4
3
  export const CodeEditorWithActions: React.FunctionComponent = () => (