@synerise/ds-code-area 1.3.1 → 1.3.3
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/CHANGELOG.md +8 -0
- package/README.md +3 -1
- package/dist/CodeArea.d.ts +2 -2
- package/dist/CodeArea.figma.d.ts +1 -0
- package/dist/CodeArea.figma.js +68 -0
- package/dist/CodeArea.js +31 -29
- package/dist/CodeArea.styles.d.ts +24 -24
- package/dist/CodeArea.styles.js +62 -55
- package/dist/CodeArea.types.d.ts +4 -4
- package/dist/CodeArea.types.js +1 -1
- package/dist/components/AriaContainer.d.ts +1 -1
- package/dist/components/AriaContainer.js +14 -13
- package/dist/components/BottomBar.d.ts +2 -2
- package/dist/components/BottomBar.js +25 -28
- package/dist/components/CodeAreaEditor.d.ts +5 -5
- package/dist/components/CodeAreaEditor.js +81 -104
- package/dist/components/CodeAreaEditorRaw.d.ts +2 -2
- package/dist/components/CodeAreaEditorRaw.js +118 -142
- package/dist/components/ContentAbove.d.ts +1 -1
- package/dist/components/ContentAbove.js +14 -11
- package/dist/components/ContentBelow.d.ts +2 -2
- package/dist/components/ContentBelow.js +22 -20
- package/dist/components/FullscreenHeader.d.ts +2 -2
- package/dist/components/FullscreenHeader.js +20 -21
- package/dist/components/index.js +14 -6
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +23 -17
- package/dist/index.js +25 -2
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/calculateRequiredSpace.js +8 -5
- package/dist/utils/getCharCount.js +6 -3
- package/dist/utils/getDefaultTexts.d.ts +1 -1
- package/dist/utils/getDefaultTexts.js +15 -19
- package/dist/utils/index.js +8 -3
- package/package.json +15 -15
|
@@ -1,111 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
texts
|
|
32
|
-
isFullscreen
|
|
33
|
-
toggleFullscreen
|
|
34
|
-
syntaxOptions
|
|
35
|
-
value
|
|
36
|
-
renderFooterContent
|
|
37
|
-
readOnly
|
|
38
|
-
defaultValue
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return counterLimit && (!placement ||
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useRef, useCallback, useMemo, useEffect } from "react";
|
|
3
|
+
import { FormFieldLabel } from "@synerise/ds-form-field";
|
|
4
|
+
import { useResizeObserver } from "@synerise/ds-utils";
|
|
5
|
+
import { Counter, AdditionalDescription, CodeAreaWrapper, CodeAreaContent } from "../CodeArea.styles.js";
|
|
6
|
+
import { calculateRequiredSpace } from "../utils/calculateRequiredSpace.js";
|
|
7
|
+
import { getCharCount } from "../utils/getCharCount.js";
|
|
8
|
+
import { getDefaultTexts } from "../utils/getDefaultTexts.js";
|
|
9
|
+
import { CodeAreaEditorRaw } from "./CodeAreaEditorRaw.js";
|
|
10
|
+
import { ContentAbove } from "./ContentAbove.js";
|
|
11
|
+
import { ContentBelow } from "./ContentBelow.js";
|
|
12
|
+
import { FullscreenHeader } from "./FullscreenHeader.js";
|
|
13
|
+
const CodeAreaEditor = forwardRef(({
|
|
14
|
+
renderAdditionalDescription,
|
|
15
|
+
description,
|
|
16
|
+
errorText,
|
|
17
|
+
style,
|
|
18
|
+
zIndex,
|
|
19
|
+
className,
|
|
20
|
+
counter,
|
|
21
|
+
fullscreenLabel,
|
|
22
|
+
tooltip,
|
|
23
|
+
label,
|
|
24
|
+
tooltipProps,
|
|
25
|
+
height,
|
|
26
|
+
noBorder,
|
|
27
|
+
...props
|
|
28
|
+
}, forwardedRef) => {
|
|
29
|
+
const {
|
|
30
|
+
allowFullscreen,
|
|
31
|
+
texts,
|
|
32
|
+
isFullscreen,
|
|
33
|
+
toggleFullscreen,
|
|
34
|
+
syntaxOptions,
|
|
35
|
+
value,
|
|
36
|
+
renderFooterContent,
|
|
37
|
+
readOnly,
|
|
38
|
+
defaultValue
|
|
39
|
+
} = props;
|
|
40
|
+
const [isValid, setIsValid] = useState(true);
|
|
41
|
+
const contentBelowRef = useRef(null);
|
|
42
|
+
const {
|
|
43
|
+
height: contentBelowHeight
|
|
44
|
+
} = useResizeObserver(contentBelowRef);
|
|
45
|
+
const counterLimit = counter?.limit;
|
|
46
|
+
const count = getCharCount(value || defaultValue, counterLimit);
|
|
47
|
+
const renderCounter = useCallback((placement) => {
|
|
48
|
+
return counterLimit && (!placement || counter?.placement === placement) && /* @__PURE__ */ jsxs(Counter, { children: [
|
|
49
|
+
count,
|
|
50
|
+
" / ",
|
|
51
|
+
counter.limit
|
|
52
|
+
] });
|
|
49
53
|
}, [counterLimit, counter, count]);
|
|
50
|
-
|
|
54
|
+
const handleOnDidChangeMarkers = useCallback((markers) => {
|
|
51
55
|
setIsValid(!markers.length);
|
|
52
56
|
}, []);
|
|
53
|
-
|
|
54
|
-
return label &&
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
title: tooltip
|
|
60
|
-
}) : undefined
|
|
61
|
-
});
|
|
57
|
+
const labelWithTooltip = useMemo(() => {
|
|
58
|
+
return label && /* @__PURE__ */ jsx(FormFieldLabel, { label, tooltip, tooltipConfig: tooltip || tooltipProps ? {
|
|
59
|
+
...tooltipProps,
|
|
60
|
+
placement: isFullscreen ? "right" : void 0,
|
|
61
|
+
title: tooltip
|
|
62
|
+
} : void 0 });
|
|
62
63
|
}, [isFullscreen, tooltip, tooltipProps, label]);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, [count, isValid, isFullscreen, renderAdditionalDescription]);
|
|
70
|
-
useEffect(function () {
|
|
64
|
+
const additionalDescription = useMemo(() => renderAdditionalDescription && /* @__PURE__ */ jsx(AdditionalDescription, { children: renderAdditionalDescription({
|
|
65
|
+
isFullscreen,
|
|
66
|
+
count,
|
|
67
|
+
isValid
|
|
68
|
+
}) }), [count, isValid, isFullscreen, renderAdditionalDescription]);
|
|
69
|
+
useEffect(() => {
|
|
71
70
|
setIsValid(!errorText);
|
|
72
71
|
}, [errorText]);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
customHeight: height
|
|
86
|
-
}, isFullscreen && /*#__PURE__*/React.createElement(FullscreenHeader, {
|
|
87
|
-
label: fullscreenLabel || labelWithTooltip,
|
|
88
|
-
texts: allTexts,
|
|
89
|
-
onClick: toggleFullscreen
|
|
90
|
-
}), !isFullscreen && /*#__PURE__*/React.createElement(ContentAbove, {
|
|
91
|
-
label: labelWithTooltip,
|
|
92
|
-
counter: renderCounter('top')
|
|
93
|
-
}), /*#__PURE__*/React.createElement(S.CodeAreaContent, null, /*#__PURE__*/React.createElement(CodeAreaEditorRaw, _extends({}, props, {
|
|
94
|
-
onDidChangeMarkers: handleOnDidChangeMarkers,
|
|
95
|
-
counter: counter,
|
|
96
|
-
errorText: errorText,
|
|
97
|
-
count: count,
|
|
98
|
-
counterLimit: counterLimit,
|
|
99
|
-
isBottomBarShowing: isBottomBarShowing,
|
|
100
|
-
isSyntaxSelectVisible: isSyntaxSelectVisible,
|
|
101
|
-
isValid: isValid,
|
|
102
|
-
noBorder: noBorder
|
|
103
|
-
})), /*#__PURE__*/React.createElement(ContentBelow, {
|
|
104
|
-
ref: contentBelowRef,
|
|
105
|
-
errorText: errorText,
|
|
106
|
-
description: description,
|
|
107
|
-
additionalDescription: additionalDescription,
|
|
108
|
-
counter: renderCounter(!isFullscreen ? 'bottom' : undefined)
|
|
109
|
-
})));
|
|
72
|
+
const isSyntaxSelectVisible = syntaxOptions && syntaxOptions.length > 1 && !readOnly;
|
|
73
|
+
const isBottomBarShowing = Boolean(isSyntaxSelectVisible || allowFullscreen && !isFullscreen || renderFooterContent);
|
|
74
|
+
const requiredSpace = isFullscreen ? calculateRequiredSpace(isBottomBarShowing, contentBelowHeight) : 0;
|
|
75
|
+
const allTexts = getDefaultTexts(texts);
|
|
76
|
+
return /* @__PURE__ */ jsxs(CodeAreaWrapper, { ref: forwardedRef, readOnly: !!readOnly, requiredSpace, className, style, isFullscreen, zIndex, customHeight: height, children: [
|
|
77
|
+
isFullscreen && /* @__PURE__ */ jsx(FullscreenHeader, { label: fullscreenLabel || labelWithTooltip, texts: allTexts, onClick: toggleFullscreen }),
|
|
78
|
+
!isFullscreen && /* @__PURE__ */ jsx(ContentAbove, { label: labelWithTooltip, counter: renderCounter("top") }),
|
|
79
|
+
/* @__PURE__ */ jsxs(CodeAreaContent, { children: [
|
|
80
|
+
/* @__PURE__ */ jsx(CodeAreaEditorRaw, { ...props, onDidChangeMarkers: handleOnDidChangeMarkers, counter, errorText, count, counterLimit, isBottomBarShowing, isSyntaxSelectVisible, isValid, noBorder }),
|
|
81
|
+
/* @__PURE__ */ jsx(ContentBelow, { ref: contentBelowRef, errorText, description, additionalDescription, counter: renderCounter(!isFullscreen ? "bottom" : void 0) })
|
|
82
|
+
] })
|
|
83
|
+
] });
|
|
110
84
|
});
|
|
111
|
-
export
|
|
85
|
+
export {
|
|
86
|
+
CodeAreaEditor,
|
|
87
|
+
CodeAreaEditor as default
|
|
88
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CodeAreaEditorRawProps } from '../CodeArea.types';
|
|
3
3
|
export declare const CodeAreaEditorRaw: ({ onMount, beforeMount, options, errorText, texts, allowFullscreen, toggleFullscreen, renderFooterContent, isBottomBarShowing, isFullscreen, count, counterLimit, onChange, isValid, onDidChangeMarkers, isSyntaxSelectVisible, syntaxOptions, currentSyntax, readOnly, onSyntaxChange, loaderConfig, placeholder, value, defaultValue, noBorder, ...props }: CodeAreaEditorRawProps) => React.JSX.Element;
|
|
4
4
|
export default CodeAreaEditorRaw;
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var monacoAriaContainerElement = useMemo(function () {
|
|
52
|
-
return document.createElement('div');
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useMemo, useCallback, useEffect } from "react";
|
|
3
|
+
import Editor, { loader } from "@monaco-editor/react";
|
|
4
|
+
import { InlineSelect } from "@synerise/ds-inline-edit";
|
|
5
|
+
import Loader from "@synerise/ds-loader";
|
|
6
|
+
import { useResizeObserver, NOOP } from "@synerise/ds-utils";
|
|
7
|
+
import { SyntaxTitle, BottomBarElement, EditorWrapper, EditorInnerWrapper, EditorPlaceholder } from "../CodeArea.styles.js";
|
|
8
|
+
import { MONACO_DEFAULT_OPTIONS, DS_MONACO_THEME_NAME, DS_MONACO_THEME, TRIGGER_SOURCE } from "../constants.js";
|
|
9
|
+
import { getDefaultTexts } from "../utils/getDefaultTexts.js";
|
|
10
|
+
import { AriaContainer } from "./AriaContainer.js";
|
|
11
|
+
import { BottomBar } from "./BottomBar.js";
|
|
12
|
+
const CodeAreaEditorRaw = ({
|
|
13
|
+
onMount,
|
|
14
|
+
beforeMount,
|
|
15
|
+
options,
|
|
16
|
+
errorText,
|
|
17
|
+
texts,
|
|
18
|
+
allowFullscreen,
|
|
19
|
+
toggleFullscreen,
|
|
20
|
+
renderFooterContent,
|
|
21
|
+
isBottomBarShowing,
|
|
22
|
+
isFullscreen,
|
|
23
|
+
count,
|
|
24
|
+
counterLimit,
|
|
25
|
+
onChange,
|
|
26
|
+
isValid,
|
|
27
|
+
onDidChangeMarkers,
|
|
28
|
+
isSyntaxSelectVisible,
|
|
29
|
+
syntaxOptions,
|
|
30
|
+
currentSyntax,
|
|
31
|
+
readOnly,
|
|
32
|
+
onSyntaxChange,
|
|
33
|
+
loaderConfig,
|
|
34
|
+
placeholder,
|
|
35
|
+
value,
|
|
36
|
+
defaultValue,
|
|
37
|
+
noBorder,
|
|
38
|
+
...props
|
|
39
|
+
}) => {
|
|
40
|
+
const monacoRef = useRef(null);
|
|
41
|
+
const loaderConfigSet = useRef(false);
|
|
42
|
+
const editorRef = useRef(null);
|
|
43
|
+
const wrapperRef = useRef(null);
|
|
44
|
+
const [isTouched, setIsTouched] = useState(false);
|
|
45
|
+
const {
|
|
46
|
+
height,
|
|
47
|
+
width
|
|
48
|
+
} = useResizeObserver(wrapperRef);
|
|
49
|
+
const monacoAriaContainerElement = useMemo(() => {
|
|
50
|
+
return document.createElement("div");
|
|
53
51
|
}, []);
|
|
54
52
|
if (loaderConfig && !loaderConfigSet.current) {
|
|
55
53
|
loader.config(loaderConfig);
|
|
56
54
|
loaderConfigSet.current = true;
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
|
|
56
|
+
const editorOptions = useMemo(() => {
|
|
57
|
+
return {
|
|
58
|
+
...MONACO_DEFAULT_OPTIONS,
|
|
59
|
+
...options,
|
|
60
|
+
readOnly,
|
|
61
61
|
domReadOnly: readOnly,
|
|
62
62
|
ariaContainerElement: monacoAriaContainerElement
|
|
63
|
-
}
|
|
63
|
+
};
|
|
64
64
|
}, [options, readOnly, monacoAriaContainerElement]);
|
|
65
|
-
|
|
65
|
+
const allTexts = useMemo(() => {
|
|
66
66
|
return getDefaultTexts(texts);
|
|
67
67
|
}, [texts]);
|
|
68
|
-
|
|
68
|
+
const handleBeforeMount = useCallback((monacoInstance) => {
|
|
69
69
|
monacoRef.current = monacoInstance;
|
|
70
70
|
monacoInstance.editor.defineTheme(DS_MONACO_THEME_NAME, DS_MONACO_THEME);
|
|
71
71
|
monacoInstance.editor.setTheme(DS_MONACO_THEME_NAME);
|
|
72
|
-
monacoInstance.editor.onDidChangeMarkers(
|
|
73
|
-
|
|
72
|
+
monacoInstance.editor.onDidChangeMarkers(() => {
|
|
73
|
+
const markers = monacoInstance.editor.getModelMarkers({});
|
|
74
74
|
onDidChangeMarkers && onDidChangeMarkers(markers);
|
|
75
75
|
});
|
|
76
|
-
monacoInstance.editor.colorize(
|
|
76
|
+
monacoInstance.editor.colorize("test", "html", {});
|
|
77
77
|
beforeMount && beforeMount(monacoInstance);
|
|
78
78
|
}, [onDidChangeMarkers, beforeMount]);
|
|
79
|
-
|
|
79
|
+
const handleEditorDidMount = useCallback((monacoEditor, monacoInstance) => {
|
|
80
80
|
editorRef.current = monacoEditor;
|
|
81
81
|
onMount && onMount(monacoEditor, monacoInstance);
|
|
82
82
|
}, [onMount]);
|
|
83
|
-
|
|
83
|
+
const handleChange = useCallback((newValue, event) => {
|
|
84
84
|
if (counterLimit && newValue && newValue.length > counterLimit) {
|
|
85
|
-
editorRef.current && editorRef.current.trigger(TRIGGER_SOURCE,
|
|
85
|
+
editorRef.current && editorRef.current.trigger(TRIGGER_SOURCE, "undo", null);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
if (editorRef.current) {
|
|
@@ -91,91 +91,67 @@ export var CodeAreaEditorRaw = function CodeAreaEditorRaw(_ref) {
|
|
|
91
91
|
setIsTouched(true);
|
|
92
92
|
onChange && onChange(newValue, event);
|
|
93
93
|
}, [onChange, counterLimit]);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
var currentItem = syntaxOptions == null ? void 0 : syntaxOptions.find(function (item) {
|
|
104
|
-
return item.language === currentSyntax;
|
|
105
|
-
});
|
|
94
|
+
const {
|
|
95
|
+
syntaxDataSource,
|
|
96
|
+
currentSyntaxItem
|
|
97
|
+
} = useMemo(() => {
|
|
98
|
+
const source = syntaxOptions?.map((item) => {
|
|
99
|
+
const {
|
|
100
|
+
label: itemLabel,
|
|
101
|
+
language
|
|
102
|
+
} = item;
|
|
106
103
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
language: currentSyntax
|
|
110
|
-
}
|
|
104
|
+
key: language,
|
|
105
|
+
text: itemLabel || language
|
|
111
106
|
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}, currentSyntaxItem.label || currentSyntaxItem.language);
|
|
107
|
+
});
|
|
108
|
+
const currentItem = syntaxOptions?.find((item) => {
|
|
109
|
+
return item.language === currentSyntax;
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
syntaxDataSource: source,
|
|
113
|
+
currentSyntaxItem: currentItem || {
|
|
114
|
+
language: currentSyntax
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}, [currentSyntax, syntaxOptions]);
|
|
118
|
+
const syntaxSelect = useMemo(() => {
|
|
119
|
+
return syntaxDataSource && syntaxDataSource.length > 1 && !readOnly ? /* @__PURE__ */ jsx(InlineSelect, { size: "small", expanded: false, input: {
|
|
120
|
+
name: "syntax-select",
|
|
121
|
+
value: currentSyntaxItem.label || currentSyntaxItem.language,
|
|
122
|
+
onChange: NOOP
|
|
123
|
+
}, onValueChange: (item) => {
|
|
124
|
+
item.key && onSyntaxChange && onSyntaxChange(`${item.key}`);
|
|
125
|
+
}, initialValue: currentSyntaxItem.label || currentSyntaxItem.language, dataSource: syntaxDataSource }) : /* @__PURE__ */ jsx(SyntaxTitle, { size: "small", children: currentSyntaxItem.label || currentSyntaxItem.language });
|
|
132
126
|
}, [currentSyntaxItem.label, currentSyntaxItem.language, onSyntaxChange, readOnly, syntaxDataSource]);
|
|
133
|
-
|
|
134
|
-
return renderFooterContent &&
|
|
135
|
-
isFullscreen
|
|
136
|
-
count
|
|
137
|
-
isValid
|
|
138
|
-
}));
|
|
127
|
+
const customFooterContent = useMemo(() => {
|
|
128
|
+
return renderFooterContent && /* @__PURE__ */ jsx(BottomBarElement, { children: renderFooterContent({
|
|
129
|
+
isFullscreen,
|
|
130
|
+
count,
|
|
131
|
+
isValid
|
|
132
|
+
}) });
|
|
139
133
|
}, [renderFooterContent, isFullscreen, count, isValid]);
|
|
140
|
-
useEffect(
|
|
134
|
+
useEffect(() => {
|
|
141
135
|
if (editorRef.current) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
currentModel && ((_monacoRef$current = monacoRef.current) == null ? void 0 : _monacoRef$current.editor.setModelLanguage(currentModel, currentSyntax));
|
|
136
|
+
const currentModel = editorRef.current?.getModel();
|
|
137
|
+
currentModel && monacoRef.current?.editor.setModelLanguage(currentModel, currentSyntax);
|
|
145
138
|
}
|
|
146
139
|
}, [currentSyntax]);
|
|
147
|
-
|
|
140
|
+
const shouldShowPlaceholder = useMemo(() => {
|
|
148
141
|
return isTouched && !value || !value && !defaultValue;
|
|
149
142
|
}, [defaultValue, isTouched, value]);
|
|
150
|
-
return
|
|
151
|
-
noBorder:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
beforeMount: handleBeforeMount,
|
|
165
|
-
onMount: handleEditorDidMount,
|
|
166
|
-
loading: /*#__PURE__*/React.createElement(Loader, null)
|
|
167
|
-
})), placeholder && /*#__PURE__*/React.createElement(S.EditorPlaceholder, {
|
|
168
|
-
shouldShowPlaceholder: shouldShowPlaceholder
|
|
169
|
-
}, placeholder)), isBottomBarShowing && /*#__PURE__*/React.createElement(BottomBar, {
|
|
170
|
-
texts: allTexts,
|
|
171
|
-
syntaxSelect: syntaxSelect,
|
|
172
|
-
allowFullscreen: allowFullscreen && !isFullscreen,
|
|
173
|
-
toggleFullscreen: toggleFullscreen,
|
|
174
|
-
customFooterContent: customFooterContent,
|
|
175
|
-
noBorder: noBorder,
|
|
176
|
-
hasError: Boolean(errorText)
|
|
177
|
-
})), /*#__PURE__*/React.createElement(AriaContainer, {
|
|
178
|
-
element: monacoAriaContainerElement
|
|
179
|
-
}));
|
|
143
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
144
|
+
/* @__PURE__ */ jsxs(EditorWrapper, { noBorder, hasError: Boolean(errorText), children: [
|
|
145
|
+
/* @__PURE__ */ jsxs(EditorInnerWrapper, { ref: wrapperRef, children: [
|
|
146
|
+
/* @__PURE__ */ jsx(Editor, { ...props, width, value, defaultValue, height, language: currentSyntax, theme: DS_MONACO_THEME_NAME, options: editorOptions, onChange: handleChange, beforeMount: handleBeforeMount, onMount: handleEditorDidMount, loading: /* @__PURE__ */ jsx(Loader, {}) }),
|
|
147
|
+
placeholder && /* @__PURE__ */ jsx(EditorPlaceholder, { shouldShowPlaceholder, children: placeholder })
|
|
148
|
+
] }),
|
|
149
|
+
isBottomBarShowing && /* @__PURE__ */ jsx(BottomBar, { texts: allTexts, syntaxSelect, allowFullscreen: allowFullscreen && !isFullscreen, toggleFullscreen, customFooterContent, noBorder, hasError: Boolean(errorText) })
|
|
150
|
+
] }),
|
|
151
|
+
/* @__PURE__ */ jsx(AriaContainer, { element: monacoAriaContainerElement })
|
|
152
|
+
] });
|
|
153
|
+
};
|
|
154
|
+
export {
|
|
155
|
+
CodeAreaEditorRaw,
|
|
156
|
+
CodeAreaEditorRaw as default
|
|
180
157
|
};
|
|
181
|
-
export default CodeAreaEditorRaw;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"data-testid": "code-area-counter-top"
|
|
10
|
-
}
|
|
11
|
-
};
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ContentAbove as ContentAbove$1, LeftSide, RightSide } from "../CodeArea.styles.js";
|
|
3
|
+
const ContentAbove = ({
|
|
4
|
+
label,
|
|
5
|
+
counter
|
|
6
|
+
}) => {
|
|
7
|
+
return label || counter ? /* @__PURE__ */ jsxs(ContentAbove$1, { children: [
|
|
8
|
+
label && /* @__PURE__ */ jsx(LeftSide, { "data-testid": "code-area-label", children: label }),
|
|
9
|
+
counter && /* @__PURE__ */ jsx(RightSide, { "data-testid": "code-area-counter-top", children: counter })
|
|
10
|
+
] }) : /* @__PURE__ */ jsx(Fragment, {});
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
ContentAbove
|
|
14
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import {
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { CodeAreaProps } from '../CodeArea.types';
|
|
3
3
|
export declare const ContentBelow: React.ForwardRefExoticComponent<Pick<CodeAreaProps, "description" | "errorText"> & {
|
|
4
4
|
additionalDescription?: ReactNode;
|
|
5
5
|
counter?: ReactNode;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ContentBelow as ContentBelow$1, LeftSide, ErrorText, Description, RightSide } from "../CodeArea.styles.js";
|
|
4
|
+
const ContentBelow = forwardRef(({
|
|
5
|
+
description,
|
|
6
|
+
additionalDescription,
|
|
7
|
+
errorText,
|
|
8
|
+
counter
|
|
9
|
+
}, ref) => {
|
|
10
|
+
const isEmpty = !(description || additionalDescription || errorText || counter);
|
|
11
|
+
return /* @__PURE__ */ jsxs(ContentBelow$1, { "data-testid": "code-area-below", ref, isEmpty, children: [
|
|
12
|
+
(description || additionalDescription || errorText) && /* @__PURE__ */ jsxs(LeftSide, { children: [
|
|
13
|
+
additionalDescription,
|
|
14
|
+
errorText && /* @__PURE__ */ jsx(ErrorText, { "data-testid": "code-area-error", children: errorText }),
|
|
15
|
+
description && /* @__PURE__ */ jsx(Description, { "data-testid": "code-area-description", children: description })
|
|
16
|
+
] }),
|
|
17
|
+
counter && /* @__PURE__ */ jsx(RightSide, { "data-testid": "code-area-counter-bottom", children: counter })
|
|
18
|
+
] });
|
|
19
|
+
});
|
|
20
|
+
export {
|
|
21
|
+
ContentBelow
|
|
22
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import {
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { CodeAreaTexts } from '../CodeArea.types';
|
|
3
3
|
type FullscreenHeaderProps = {
|
|
4
4
|
label?: ReactNode;
|
|
5
5
|
texts: CodeAreaTexts;
|