Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6 rebase #10033

Merged
merged 99 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
d7308ae
fix(RTL): added right-to-left page demo (#9694)
mcoker Nov 2, 2023
e9f0b21
chore(release): releasing packages [ci skip]
patternfly-build Nov 2, 2023
4d4d623
fix(Wizard): onStepChange - skip isDisabled & isHidden (#9748)
jpuzz0 Nov 2, 2023
7f6a62c
fix(Text input): Added aria-expanded (#9705)
tlabaj Nov 2, 2023
bc19f91
fix(Notification Drawer): Added screen reader text for notification d…
tlabaj Nov 2, 2023
9f21cee
feat(Wizard): ability to add props to WizardFooter buttons (#9709)
adamviktora Nov 2, 2023
7eff077
chore(Divider): update tests to new standards (#9714)
mfrances17 Nov 2, 2023
4f459eb
chore(release): releasing packages [ci skip]
patternfly-build Nov 2, 2023
a772c6d
fix(TreeView): define button type (#9770)
kmcfaul Nov 2, 2023
817e9bd
bug(build): fixed built ESM files importing CJS files from react-styl…
wise-king-sullyman Nov 2, 2023
5febe85
chore(release): releasing packages [ci skip]
patternfly-build Nov 2, 2023
fc2907d
chore(deps): update dependency @patternfly/patternfly to v5.2.0-prere…
renovate[bot] Nov 3, 2023
559e6fd
chore(release): releasing packages [ci skip]
patternfly-build Nov 3, 2023
ab18059
feat(Datalist): implement full page Basic demo to match HTML #9048 (#…
Kells512 Nov 3, 2023
981361e
fix(ClipboardCopy): kepp caret position (#9772)
adamviktora Nov 3, 2023
74773b0
chore(release): releasing packages [ci skip]
patternfly-build Nov 3, 2023
b3345c2
chore(deps): update devdependencies (#9757)
renovate[bot] Nov 6, 2023
3131ff6
chore(deps): update dependency @patternfly/patternfly to v5.2.0-prere…
renovate[bot] Nov 10, 2023
93db0ff
chore(deps): update devdependencies (#9800)
renovate[bot] Nov 10, 2023
75442bf
chore(release): releasing packages [ci skip]
patternfly-build Nov 10, 2023
a12cf31
fix(DatePicker): updated logic for parsing and focus management (#9794)
thatblindgeye Nov 13, 2023
9dccfa9
chore(release): releasing packages [ci skip]
patternfly-build Nov 13, 2023
bf96edb
chore(PrimaryDetail): convert demos to TS (#9787)
jenny-s51 Nov 14, 2023
42fd765
chore(release): releasing packages [ci skip]
patternfly-build Nov 14, 2023
705e9ff
chore(misc): clean up instances of Array.apply (#9798)
jenny-s51 Nov 14, 2023
e96ac1d
chore(release): releasing packages [ci skip]
patternfly-build Nov 14, 2023
9b9622d
chore(eslint): Added React Testing Library linter plugin (#9805)
wise-king-sullyman Nov 14, 2023
4f123b1
chore(release): releasing packages [ci skip]
patternfly-build Nov 14, 2023
2a70043
chore(DataList): update tests (#9672)
kmcfaul Nov 15, 2023
a414253
bug(ClipboardCopy): change children type to string (#9743)
gitdallas Nov 15, 2023
88e1c34
chore(deps): update devdependencies (#9817)
renovate[bot] Nov 15, 2023
4b23675
fix Search Input - composable advanced search demo (#9484)
MariaAga Nov 15, 2023
a7075e0
docs(custom menu): add example with search input inline filtering (#9…
adamviktora Nov 15, 2023
a816ddd
chore(HelperText): update tests (#9761)
kmcfaul Nov 15, 2023
18c140a
fix(Chip): update tooltip vis when chip updates (#9819)
kmcfaul Nov 16, 2023
b957f2f
chore(DescriptionList): update tests (#9753)
kmcfaul Nov 16, 2023
e112034
chore(release): releasing packages [ci skip]
patternfly-build Nov 16, 2023
7d2fd26
chore(TreeView): updated tests (#9773)
thatblindgeye Nov 16, 2023
feeb331
chore(Table) convert demos to ts (#9621)
Dominik-Petrik Nov 17, 2023
3fa692c
chore(release): releasing packages [ci skip]
patternfly-build Nov 17, 2023
fc8f6eb
chore(deps): update devdependencies (#9829)
renovate[bot] Nov 20, 2023
7a2f775
docs(select): Adds documentation to React examples. (#9536)
edonehoo Nov 21, 2023
32dfd89
chore(release): releasing packages [ci skip]
patternfly-build Nov 21, 2023
9b96292
chore(deps): update devdependencies (#9833)
renovate[bot] Nov 21, 2023
d725eb3
chore(deps): update devdependencies (#9837)
renovate[bot] Nov 29, 2023
5fb78ef
fix link to patternfly community contributors document (#9840)
yurith-rubio Nov 29, 2023
046ee9e
chore(deps): update devdependencies (#9846)
renovate[bot] Dec 5, 2023
eb9693f
fix(Table): make tooltip prop consistent (#9803)
kmcfaul Dec 6, 2023
ddc87a7
chore(DataList): convert data list react demo to TS (#9818)
jenny-s51 Dec 6, 2023
9244cf0
fix(AlertGroupDemo): crashed when adding default alerts (#9826)
MariaAga Dec 6, 2023
716c894
chore(release): releasing packages [ci skip]
patternfly-build Dec 6, 2023
fc55516
chore(deps): update dependency @types/jest to v29.5.11 (#9854)
renovate[bot] Dec 6, 2023
65912ac
Update Popover returnFocusOnDeactivate prop (#9865)
jschuler Dec 7, 2023
c9ead43
chore(release): releasing packages [ci skip]
patternfly-build Dec 7, 2023
bb58f8b
chore(deps): update dependency @patternfly/patternfly to v5.2.0-prere…
renovate[bot] Dec 11, 2023
5aa83c5
chore(release): releasing packages [ci skip]
patternfly-build Dec 11, 2023
6d065fd
chore(deps): update devdependencies (#9873)
renovate[bot] Dec 12, 2023
2afb5fd
fix(MenuItem): Add download to MenuItem (#9892)
rhamilto Dec 14, 2023
2ae9642
chore(release): releasing packages [ci skip]
patternfly-build Dec 14, 2023
58e0071
feat(Accordion): added toggle alignment functionality (#9877)
thatblindgeye Dec 20, 2023
a26c4da
chore(release): releasing packages [ci skip]
patternfly-build Dec 20, 2023
ea74593
chore(deps): update devdependencies (#9885)
renovate[bot] Jan 2, 2024
fc9b2ec
chore: add primary button with icon to button docs (#9871)
nicolethoen Jan 2, 2024
25223e7
chore(release): releasing packages [ci skip]
patternfly-build Jan 2, 2024
91b7d62
fix(Chip): prevented duplicate ID being applied (#9886)
thatblindgeye Jan 3, 2024
d67207d
chore(release): releasing packages [ci skip]
patternfly-build Jan 3, 2024
324fbbf
chore(expandablesection): Added a demo to show how to use expandable …
dlabaj Jan 4, 2024
01b0155
chore(release): releasing packages [ci skip]
patternfly-build Jan 4, 2024
54dd134
feat(CodeEditor): use new monaco package (#9842)
kmcfaul Jan 5, 2024
eece332
chore(release): releasing packages [ci skip]
patternfly-build Jan 5, 2024
7ec2aff
feat(Modal next): Introduce a next composable Modal (#9852)
tlabaj Jan 5, 2024
5d9a025
chore(build): Fix lint issues (#9938)
tlabaj Jan 5, 2024
c90c7f2
chore(release): releasing packages [ci skip]
patternfly-build Jan 5, 2024
19ddee7
feat(DragDrop): new drag drop styling fixes (#9784)
kmcfaul Jan 8, 2024
f4175ff
chore(release): releasing packages [ci skip]
patternfly-build Jan 8, 2024
fe40f4a
Add support for isLabelWrapped and component in Checkbox / Radio (#9830)
adamviktora Jan 9, 2024
ae9011b
chore(build): Fix lint errors (#9950)
tlabaj Jan 9, 2024
1ae55d8
chore(release): releasing packages [ci skip]
patternfly-build Jan 9, 2024
20f2bd7
chore(deps): update devdependencies (#9932)
renovate[bot] Jan 9, 2024
74c30e8
fix(Popover): doc click event (#9952)
kmcfaul Jan 10, 2024
53398c8
chore(release): releasing packages [ci skip]
patternfly-build Jan 10, 2024
c14c48c
Update react-core dist/dynamic to include exported styles (#9939)
vojtechszocs Jan 11, 2024
af457ce
chore(release): releasing packages [ci skip]
patternfly-build Jan 11, 2024
10a26e6
chore(deps): update devdependencies (#9955)
renovate[bot] Jan 12, 2024
2dab51f
FileUploadField fix to set name attribute on input element (#9941)
jamestalton Jan 15, 2024
77f45e5
chore(release): releasing packages [ci skip]
patternfly-build Jan 15, 2024
15c5ee9
chore(deps): update devdependencies (#9967)
renovate[bot] Jan 15, 2024
61aac62
Update Victory dependencies (#9963)
dlabrecq Jan 15, 2024
cec6e41
chore(release): releasing packages [ci skip]
patternfly-build Jan 15, 2024
a189781
fix(Clipboard copy): Fixed regression with updating main content when…
tlabaj Jan 16, 2024
c856b07
chore(release): releasing packages [ci skip]
patternfly-build Jan 16, 2024
9395dd5
fix(ClipboardCopy): update main content on children change when expan…
adamviktora Jan 17, 2024
08e52e3
chore(release): releasing packages [ci skip]
patternfly-build Jan 17, 2024
e3fe70f
feat(DragDrop): fix import warning (#10023)
kmcfaul Jan 22, 2024
f62813f
chore(release): releasing packages [ci skip]
patternfly-build Jan 22, 2024
0d72ea1
Merge branch 'main' into v6_rebase
Jan 22, 2024
4d0bd9e
fix accoridan examples
tlabaj Jan 22, 2024
83f8bc8
updates to fix docs
tlabaj Jan 23, 2024
76f646b
bump docs-framework version
nicolethoen Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@octokit/rest": "^20.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "14.5.1",
"@testing-library/user-event": "14.5.2",
"@types/jest": "29.5.11",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
20 changes: 20 additions & 0 deletions packages/react-charts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @patternfly/react-charts

# 7.2.0-prerelease.10 (2024-01-15)

**Note:** Version bump only for package @patternfly/react-charts

# 7.2.0-prerelease.9 (2024-01-11)

**Note:** Version bump only for package @patternfly/react-charts

# 7.2.0-prerelease.8 (2023-12-11)

**Note:** Version bump only for package @patternfly/react-charts

# 7.2.0-prerelease.7 (2023-11-10)

**Note:** Version bump only for package @patternfly/react-charts

# 7.2.0-prerelease.6 (2023-11-03)

**Note:** Version bump only for package @patternfly/react-charts

# 7.2.0-prerelease.5 (2023-10-26)

**Note:** Version bump only for package @patternfly/react-charts
Expand Down
36 changes: 18 additions & 18 deletions packages/react-charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@
"@patternfly/react-styles": "^6.0.0-alpha.9",
"@patternfly/react-tokens": "^6.0.0-alpha.9",
"hoist-non-react-statics": "^3.3.0",
"lodash": "^4.17.19",
"lodash": "^4.17.21",
"tslib": "^2.5.0",
"victory-area": "^36.6.11",
"victory-axis": "^36.6.11",
"victory-bar": "^36.6.11",
"victory-box-plot": "^36.6.11",
"victory-chart": "^36.6.11",
"victory-core": "^36.6.11",
"victory-create-container": "^36.6.11",
"victory-cursor-container": "^36.6.11",
"victory-group": "^36.6.11",
"victory-legend": "^36.6.11",
"victory-line": "^36.6.11",
"victory-pie": "^36.6.11",
"victory-scatter": "^36.6.11",
"victory-stack": "^36.6.11",
"victory-tooltip": "^36.6.11",
"victory-voronoi-container": "^36.6.11",
"victory-zoom-container": "^36.6.11"
"victory-area": "^36.8.1",
"victory-axis": "^36.8.1",
"victory-bar": "^36.8.1",
"victory-box-plot": "^36.8.1",
"victory-chart": "^36.8.1",
"victory-core": "^36.8.1",
"victory-create-container": "^36.8.1",
"victory-cursor-container": "^36.8.1",
"victory-group": "^36.8.1",
"victory-legend": "^36.8.1",
"victory-line": "^36.8.1",
"victory-pie": "^36.8.1",
"victory-scatter": "^36.8.1",
"victory-stack": "^36.8.1",
"victory-tooltip": "^36.8.1",
"victory-voronoi-container": "^36.8.1",
"victory-zoom-container": "^36.8.1"
},
"peerDependencies": {
"react": "^17 || ^18",
Expand Down
9 changes: 3 additions & 6 deletions packages/react-charts/single-packages.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"packageName": "@patternfly/react-charts",
"exclude": [
"dist/esm/deprecated/index.js",
"dist/esm/next/index.js"
]
}
"packageName": "@patternfly/react-charts",
"exclude": ["dist/esm/deprecated/index.js", "dist/esm/next/index.js"]
}
122 changes: 122 additions & 0 deletions packages/react-code-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,128 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.49](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-17)

**Note:** Version bump only for package @patternfly/react-code-editor

# 5.2.0-prerelease.48 (2024-01-16)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.47](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-15)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.46](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-11)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.45](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-10)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.44](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-09)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.43](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-08)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.42](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-05)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.41](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-05)

### Features

- **CodeEditor:** use new monaco package ([#9842](https://github.com/patternfly/patternfly-react/issues/9842)) ([54dd134](https://github.com/patternfly/patternfly-react/commit/54dd134d6c67c4fc1d7630fd1e7c718f66061342))

# [5.2.0-prerelease.40](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-04)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.39](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-03)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.38](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2024-01-02)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.37](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-12-20)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.36](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-12-14)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.35](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-12-11)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.34](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-12-07)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.33](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-12-06)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.32](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-21)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.31](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-17)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.30](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-16)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.29](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-14)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.28](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-14)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.27](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-14)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.26](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-13)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.25](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-10)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.24](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-03)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.23](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-03)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.22](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-02)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.21](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-02)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.20](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-11-02)

**Note:** Version bump only for package @patternfly/react-code-editor

# [5.2.0-prerelease.19](https://github.com/patternfly/patternfly-react/compare/@patternfly/[email protected]...@patternfly/[email protected]) (2023-10-30)

**Note:** Version bump only for package @patternfly/react-code-editor
Expand Down
6 changes: 3 additions & 3 deletions packages/react-code-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"@patternfly/react-icons": "^6.0.0-alpha.9",
"@patternfly/react-styles": "^6.0.0-alpha.9",
"react-dropzone": "14.2.3",
"tslib": "^2.5.0"
"tslib": "^2.5.0",
"@monaco-editor/react": "^4.6.0"
},
"peerDependencies": {
"react": "^17 || ^18",
"react-dom": "^17 || ^18",
"react-monaco-editor": "^0.51.0"
"react-dom": "^17 || ^18"
},
"devDependencies": {
"rimraf": "^2.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
PopoverProps,
TooltipPosition
} from '@patternfly/react-core';
import MonacoEditor, { ChangeHandler, EditorDidMount } from 'react-monaco-editor';
import Editor, { Monaco } from '@monaco-editor/react';
import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
import UploadIcon from '@patternfly/react-icons/dist/esm/icons/upload-icon';
Expand All @@ -26,6 +26,9 @@ import Dropzone, { FileRejection } from 'react-dropzone';
import { CodeEditorContext } from './CodeEditorUtils';
import { CodeEditorControl } from './CodeEditorControl';

export type ChangeHandler = (value: string, event: editor.IModelContentChangedEvent) => void;
export type EditorDidMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void;

export interface Shortcut {
description: string;
keys: string[];
Expand Down Expand Up @@ -619,15 +622,15 @@ class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState> {

const editor = (
<div className={css(styles.codeEditorCode)} ref={this.wrapperRef} tabIndex={0} dir="ltr">
<MonacoEditor
<Editor
height={height}
width={width}
language={language}
value={value}
options={options}
overrideServices={overrideServices}
onChange={this.onChange}
editorDidMount={this.editorDidMount}
onMount={this.editorDidMount}
theme={isDarkTheme ? 'vs-dark' : 'vs-light'}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,79 @@
import React from 'react';
import { render } from '@testing-library/react';
import { render, screen, act } from '@testing-library/react';
import { CodeEditor, Language } from '../CodeEditor';
import styles from '@patternfly/react-styles/css/components/CodeEditor/code-editor';
import fileUploadStyles from '@patternfly/react-styles/css/components/FileUpload/file-upload';

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn()
}))
});

describe('CodeEditor', () => {
beforeAll(() => {
window.HTMLCanvasElement.prototype.getContext = () => ({}) as any;
});
jest.mock('@monaco-editor/react', () => jest.fn(() => <div data-testid="mock-editor"></div>));

test('matches snapshot without props', () => {
const { asFragment } = render(<CodeEditor />);
expect(asFragment()).toMatchSnapshot();
});
test('Matches snapshot without props', () => {
const { asFragment } = render(<CodeEditor code="test" />);
expect(asFragment()).toMatchSnapshot();
});

test('Matches snapshot with control buttons enabled', () => {
const { asFragment } = render(<CodeEditor isUploadEnabled isDownloadEnabled isCopyEnabled code="test" />);
expect(asFragment()).toMatchSnapshot();
});

test(`Renders with default classes ${styles.codeEditor}, ${styles.codeEditorMain}, ${styles.codeEditorCode}`, () => {
render(<CodeEditor />);
expect(screen.getByTestId('mock-editor').parentElement).toHaveClass(styles.codeEditorCode);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement).toHaveClass(styles.codeEditorMain);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement?.parentElement).toHaveClass(styles.codeEditor);
});

test('Renders custom class when className is passed', () => {
render(<CodeEditor className="custom" />);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement?.parentElement).toHaveClass('custom');
});

test(`Renders with ${styles.modifiers.readOnly} when isReadOnly = true`, () => {
render(<CodeEditor isReadOnly />);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement?.parentElement).toHaveClass(
styles.modifiers.readOnly
);
});

test(`Renders with ${fileUploadStyles.fileUpload} when isUploadEnabled = true`, () => {
render(<CodeEditor isUploadEnabled code="test" />);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement?.parentElement).toHaveClass(
fileUploadStyles.fileUpload
);
});

test(`Renders with empty state when code = undefined`, () => {
render(<CodeEditor emptyState={<div>empty</div>} />);
expect(screen.getByText('empty')).toBeInTheDocument();
});

test(`Renders with empty state when isUploadEnabled = true and code = undefined`, () => {
render(<CodeEditor emptyState={<div>empty</div>} isUploadEnabled />);
expect(screen.getByText('empty')).toBeInTheDocument();
});

test(`Renders with language label when isLanguageLabelVisible`, () => {
render(<CodeEditor isLanguageLabelVisible language={Language.java} />);
expect(screen.getByText('JAVA')).toBeInTheDocument();
});

test(`Renders with custom controls when customControls is passed`, () => {
render(<CodeEditor customControls={<div>control</div>} />);
expect(screen.getByText('control')).toBeInTheDocument();
});

test(`Renders with custom header content when headerMainContent is passed`, () => {
render(<CodeEditor headerMainContent="header content" />);
expect(screen.getByText('header content')).toBeInTheDocument();
});

test('matches snapshot with all props', () => {
const { asFragment } = render(
<CodeEditor
isReadOnly
isDarkTheme
isLineNumbersVisible={false}
isUploadEnabled
isLanguageLabelVisible
isDownloadEnabled
isCopyEnabled
height="400px"
code={'test'}
language={Language.javascript}
/>
);
expect(asFragment()).toMatchSnapshot();
test(`Renders with shortcuts when shortcutsPopoverButtonText is passed`, () => {
render(
<CodeEditor shortcutsPopoverButtonText="shortcuts-button" shortcutsPopoverProps={{ bodyContent: 'shortcuts' }} />
);
expect(screen.getByText('shortcuts-button')).toBeInTheDocument();
act(() => {
screen.getByText('shortcuts-button').click();
});
expect(screen.getByText('shortcuts')).toBeInTheDocument();
});
Loading
Loading