@synerise/ds-code-area 1.3.2 → 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.
@@ -1,14 +1,14 @@
1
- import React from 'react';
2
- export declare const CodeAreaEditor: React.ForwardRefExoticComponent<Omit<import("@monaco-editor/react").EditorProps, "language" | "height"> & {
1
+ import { default as React } from 'react';
2
+ export declare const CodeAreaEditor: React.ForwardRefExoticComponent<Omit<import('@monaco-editor/react').EditorProps, "language" | "height"> & {
3
3
  label?: React.ReactNode;
4
4
  description?: React.ReactNode;
5
- texts?: Partial<import("../CodeArea.types").CodeAreaTexts>;
5
+ texts?: Partial<import('../CodeArea.types').CodeAreaTexts>;
6
6
  counter?: {
7
7
  limit: number;
8
8
  placement?: "bottom" | "top";
9
9
  };
10
10
  errorText?: React.ReactNode;
11
- syntaxOptions?: import("../CodeArea.types").CodeAreaSyntaxOption<string>[] | undefined;
11
+ syntaxOptions?: import('../CodeArea.types').CodeAreaSyntaxOption<string>[] | undefined;
12
12
  currentSyntax: string;
13
13
  allowFullscreen?: boolean;
14
14
  isFullscreen: boolean;
@@ -18,7 +18,7 @@ export declare const CodeAreaEditor: React.ForwardRefExoticComponent<Omit<import
18
18
  defaultValue?: string;
19
19
  readOnly?: boolean;
20
20
  tooltip?: React.ReactNode;
21
- tooltipProps?: import("@synerise/ds-tooltip").TooltipProps;
21
+ tooltipProps?: import('@synerise/ds-tooltip').TooltipProps;
22
22
  style?: React.CSSProperties;
23
23
  zIndex?: string | number;
24
24
  noBorder?: boolean;
@@ -1,111 +1,88 @@
1
- var _excluded = ["renderAdditionalDescription", "description", "errorText", "style", "zIndex", "className", "counter", "fullscreenLabel", "tooltip", "label", "tooltipProps", "height", "noBorder"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
- import { FormFieldLabel } from '@synerise/ds-form-field';
6
- import { useResizeObserver } from '@synerise/ds-utils';
7
- import * as S from '../CodeArea.styles';
8
- import { calculateRequiredSpace } from '../utils/calculateRequiredSpace';
9
- import { getCharCount } from '../utils/getCharCount';
10
- import { getDefaultTexts } from '../utils/getDefaultTexts';
11
- import { CodeAreaEditorRaw } from './CodeAreaEditorRaw';
12
- import { ContentAbove } from './ContentAbove';
13
- import { ContentBelow } from './ContentBelow';
14
- import { FullscreenHeader } from './FullscreenHeader';
15
- export var CodeAreaEditor = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
16
- var renderAdditionalDescription = _ref.renderAdditionalDescription,
17
- description = _ref.description,
18
- errorText = _ref.errorText,
19
- style = _ref.style,
20
- zIndex = _ref.zIndex,
21
- className = _ref.className,
22
- counter = _ref.counter,
23
- fullscreenLabel = _ref.fullscreenLabel,
24
- tooltip = _ref.tooltip,
25
- label = _ref.label,
26
- tooltipProps = _ref.tooltipProps,
27
- height = _ref.height,
28
- noBorder = _ref.noBorder,
29
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
30
- var allowFullscreen = props.allowFullscreen,
31
- texts = props.texts,
32
- isFullscreen = props.isFullscreen,
33
- toggleFullscreen = props.toggleFullscreen,
34
- syntaxOptions = props.syntaxOptions,
35
- value = props.value,
36
- renderFooterContent = props.renderFooterContent,
37
- readOnly = props.readOnly,
38
- defaultValue = props.defaultValue;
39
- var _useState = useState(true),
40
- isValid = _useState[0],
41
- setIsValid = _useState[1];
42
- var contentBelowRef = useRef(null);
43
- var _useResizeObserver = useResizeObserver(contentBelowRef),
44
- contentBelowHeight = _useResizeObserver.height;
45
- var counterLimit = counter == null ? void 0 : counter.limit;
46
- var count = getCharCount(value || defaultValue, counterLimit);
47
- var renderCounter = useCallback(function (placement) {
48
- return counterLimit && (!placement || (counter == null ? void 0 : counter.placement) === placement) && /*#__PURE__*/React.createElement(S.Counter, null, count, " / ", counter.limit);
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
- var handleOnDidChangeMarkers = useCallback(function (markers) {
54
+ const handleOnDidChangeMarkers = useCallback((markers) => {
51
55
  setIsValid(!markers.length);
52
56
  }, []);
53
- var labelWithTooltip = useMemo(function () {
54
- return label && /*#__PURE__*/React.createElement(FormFieldLabel, {
55
- label: label,
56
- tooltip: tooltip,
57
- tooltipConfig: tooltip || tooltipProps ? _extends({}, tooltipProps, {
58
- placement: isFullscreen ? 'right' : undefined,
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
- var additionalDescription = useMemo(function () {
64
- return renderAdditionalDescription && /*#__PURE__*/React.createElement(S.AdditionalDescription, null, renderAdditionalDescription({
65
- isFullscreen: isFullscreen,
66
- count: count,
67
- isValid: isValid
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
- var isSyntaxSelectVisible = syntaxOptions && syntaxOptions.length > 1 && !readOnly;
74
- var isBottomBarShowing = Boolean(isSyntaxSelectVisible || allowFullscreen && !isFullscreen || renderFooterContent);
75
- var requiredSpace = isFullscreen ? calculateRequiredSpace(isBottomBarShowing, contentBelowHeight) : 0;
76
- var allTexts = getDefaultTexts(texts);
77
- return /*#__PURE__*/React.createElement(S.CodeAreaWrapper, {
78
- ref: forwardedRef,
79
- readOnly: !!readOnly,
80
- requiredSpace: requiredSpace,
81
- className: className,
82
- style: style,
83
- isFullscreen: isFullscreen,
84
- zIndex: zIndex,
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 default CodeAreaEditor;
85
+ export {
86
+ CodeAreaEditor,
87
+ CodeAreaEditor as default
88
+ };
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type CodeAreaEditorRawProps } from '../CodeArea.types';
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
- var _excluded = ["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"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
- import Editor, { loader } from '@monaco-editor/react';
6
- import { InlineSelect } from '@synerise/ds-inline-edit';
7
- import Loader from '@synerise/ds-loader';
8
- import { NOOP, useResizeObserver } from '@synerise/ds-utils';
9
- import * as S from '../CodeArea.styles';
10
- import { DS_MONACO_THEME, DS_MONACO_THEME_NAME, MONACO_DEFAULT_OPTIONS, TRIGGER_SOURCE } from '../constants';
11
- import { getDefaultTexts } from '../utils/getDefaultTexts';
12
- import { AriaContainer } from './AriaContainer';
13
- import { BottomBar } from './BottomBar';
14
- export var CodeAreaEditorRaw = function CodeAreaEditorRaw(_ref) {
15
- var onMount = _ref.onMount,
16
- beforeMount = _ref.beforeMount,
17
- options = _ref.options,
18
- errorText = _ref.errorText,
19
- texts = _ref.texts,
20
- allowFullscreen = _ref.allowFullscreen,
21
- toggleFullscreen = _ref.toggleFullscreen,
22
- renderFooterContent = _ref.renderFooterContent,
23
- isBottomBarShowing = _ref.isBottomBarShowing,
24
- isFullscreen = _ref.isFullscreen,
25
- count = _ref.count,
26
- counterLimit = _ref.counterLimit,
27
- onChange = _ref.onChange,
28
- isValid = _ref.isValid,
29
- onDidChangeMarkers = _ref.onDidChangeMarkers,
30
- isSyntaxSelectVisible = _ref.isSyntaxSelectVisible,
31
- syntaxOptions = _ref.syntaxOptions,
32
- currentSyntax = _ref.currentSyntax,
33
- readOnly = _ref.readOnly,
34
- onSyntaxChange = _ref.onSyntaxChange,
35
- loaderConfig = _ref.loaderConfig,
36
- placeholder = _ref.placeholder,
37
- value = _ref.value,
38
- defaultValue = _ref.defaultValue,
39
- noBorder = _ref.noBorder,
40
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
41
- var monacoRef = useRef(null);
42
- var loaderConfigSet = useRef(false);
43
- var editorRef = useRef(null);
44
- var wrapperRef = useRef(null);
45
- var _useState = useState(false),
46
- isTouched = _useState[0],
47
- setIsTouched = _useState[1];
48
- var _useResizeObserver = useResizeObserver(wrapperRef),
49
- height = _useResizeObserver.height,
50
- width = _useResizeObserver.width;
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
- var editorOptions = useMemo(function () {
59
- return _extends({}, MONACO_DEFAULT_OPTIONS, options, {
60
- readOnly: readOnly,
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
- var allTexts = useMemo(function () {
65
+ const allTexts = useMemo(() => {
66
66
  return getDefaultTexts(texts);
67
67
  }, [texts]);
68
- var handleBeforeMount = useCallback(function (monacoInstance) {
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(function () {
73
- var markers = monacoInstance.editor.getModelMarkers({});
72
+ monacoInstance.editor.onDidChangeMarkers(() => {
73
+ const markers = monacoInstance.editor.getModelMarkers({});
74
74
  onDidChangeMarkers && onDidChangeMarkers(markers);
75
75
  });
76
- monacoInstance.editor.colorize('test', 'html', {});
76
+ monacoInstance.editor.colorize("test", "html", {});
77
77
  beforeMount && beforeMount(monacoInstance);
78
78
  }, [onDidChangeMarkers, beforeMount]);
79
- var handleEditorDidMount = useCallback(function (monacoEditor, monacoInstance) {
79
+ const handleEditorDidMount = useCallback((monacoEditor, monacoInstance) => {
80
80
  editorRef.current = monacoEditor;
81
81
  onMount && onMount(monacoEditor, monacoInstance);
82
82
  }, [onMount]);
83
- var handleChange = useCallback(function (newValue, event) {
83
+ const handleChange = useCallback((newValue, event) => {
84
84
  if (counterLimit && newValue && newValue.length > counterLimit) {
85
- editorRef.current && editorRef.current.trigger(TRIGGER_SOURCE, 'undo', null);
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
- var _useMemo = useMemo(function () {
95
- var source = syntaxOptions == null ? void 0 : syntaxOptions.map(function (item) {
96
- var itemLabel = item.label,
97
- language = item.language;
98
- return {
99
- key: language,
100
- text: itemLabel || language
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
- syntaxDataSource: source,
108
- currentSyntaxItem: currentItem || {
109
- language: currentSyntax
110
- }
104
+ key: language,
105
+ text: itemLabel || language
111
106
  };
112
- }, [currentSyntax, syntaxOptions]),
113
- syntaxDataSource = _useMemo.syntaxDataSource,
114
- currentSyntaxItem = _useMemo.currentSyntaxItem;
115
- var syntaxSelect = useMemo(function () {
116
- return syntaxDataSource && syntaxDataSource.length > 1 && !readOnly ? /*#__PURE__*/React.createElement(InlineSelect, {
117
- size: "small",
118
- expanded: false,
119
- input: {
120
- name: 'syntax-select',
121
- value: currentSyntaxItem.label || currentSyntaxItem.language,
122
- onChange: NOOP
123
- },
124
- onValueChange: function onValueChange(item) {
125
- item.key && onSyntaxChange && onSyntaxChange("" + item.key);
126
- },
127
- initialValue: currentSyntaxItem.label || currentSyntaxItem.language,
128
- dataSource: syntaxDataSource
129
- }) : /*#__PURE__*/React.createElement(S.SyntaxTitle, {
130
- size: "small"
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
- var customFooterContent = useMemo(function () {
134
- return renderFooterContent && /*#__PURE__*/React.createElement(S.BottomBarElement, null, renderFooterContent({
135
- isFullscreen: isFullscreen,
136
- count: count,
137
- isValid: 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(function () {
134
+ useEffect(() => {
141
135
  if (editorRef.current) {
142
- var _editorRef$current, _monacoRef$current;
143
- var currentModel = (_editorRef$current = editorRef.current) == null ? void 0 : _editorRef$current.getModel();
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
- var shouldShowPlaceholder = useMemo(function () {
140
+ const shouldShowPlaceholder = useMemo(() => {
148
141
  return isTouched && !value || !value && !defaultValue;
149
142
  }, [defaultValue, isTouched, value]);
150
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.EditorWrapper, {
151
- noBorder: noBorder,
152
- hasError: Boolean(errorText)
153
- }, /*#__PURE__*/React.createElement(S.EditorInnerWrapper, {
154
- ref: wrapperRef
155
- }, /*#__PURE__*/React.createElement(Editor, _extends({}, props, {
156
- width: width,
157
- value: value,
158
- defaultValue: defaultValue,
159
- height: height,
160
- language: currentSyntax,
161
- theme: DS_MONACO_THEME_NAME,
162
- options: editorOptions,
163
- onChange: handleChange,
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,4 +1,4 @@
1
- import React, { type ReactNode } from 'react';
1
+ import { default as React, ReactNode } from 'react';
2
2
  type ContentAboveProps = {
3
3
  label?: ReactNode;
4
4
  counter?: ReactNode;
@@ -1,11 +1,14 @@
1
- import React from 'react';
2
- import * as S from '../CodeArea.styles';
3
- export var ContentAbove = function ContentAbove(_ref) {
4
- var label = _ref.label,
5
- counter = _ref.counter;
6
- return label || counter ? /*#__PURE__*/React.createElement(S.ContentAbove, null, label && /*#__PURE__*/React.createElement(S.LeftSide, {
7
- "data-testid": "code-area-label"
8
- }, label), counter && /*#__PURE__*/React.createElement(S.RightSide, {
9
- "data-testid": "code-area-counter-top"
10
- }, counter)) : /*#__PURE__*/React.createElement(React.Fragment, null);
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, { type ReactNode } from 'react';
2
- import { type CodeAreaProps } from '../CodeArea.types';
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 React, { forwardRef } from 'react';
2
- import * as S from '../CodeArea.styles';
3
- export var ContentBelow = /*#__PURE__*/forwardRef(function (_ref, ref) {
4
- var description = _ref.description,
5
- additionalDescription = _ref.additionalDescription,
6
- errorText = _ref.errorText,
7
- counter = _ref.counter;
8
- var isEmpty = !(description || additionalDescription || errorText || counter);
9
- return /*#__PURE__*/React.createElement(S.ContentBelow, {
10
- "data-testid": "code-area-below",
11
- ref: ref,
12
- isEmpty: isEmpty
13
- }, (description || additionalDescription || errorText) && /*#__PURE__*/React.createElement(S.LeftSide, null, additionalDescription, errorText && /*#__PURE__*/React.createElement(S.ErrorText, {
14
- "data-testid": "code-area-error"
15
- }, errorText), description && /*#__PURE__*/React.createElement(S.Description, {
16
- "data-testid": "code-area-description"
17
- }, description)), counter && /*#__PURE__*/React.createElement(S.RightSide, {
18
- "data-testid": "code-area-counter-bottom"
19
- }, counter));
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
+ };