@synerise/ds-code-area 1.1.23 → 1.2.1

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 CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-area@1.2.0...@synerise/ds-code-area@1.2.1) (2025-09-26)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **code-area:** drop default value ([abb250e](https://github.com/Synerise/synerise-design/commit/abb250e38136c4a18f768aa8a4a25ef5de286ee6))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-area@1.1.23...@synerise/ds-code-area@1.2.0) (2025-09-25)
18
+
19
+
20
+ ### Features
21
+
22
+ * **code-area:** add placeholder prop ([a02bb94](https://github.com/Synerise/synerise-design/commit/a02bb949f56a736cff8bb056e70d954ca1663cf1))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [1.1.23](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-area@1.1.22...@synerise/ds-code-area@1.1.23) (2025-09-23)
7
29
 
8
30
  **Note:** Version bump only for package @synerise/ds-code-area
package/README.md CHANGED
@@ -64,6 +64,7 @@ const syntaxOptions = [
64
64
  | onSyntaxChange | triggered when user switches syntax | `(newSyntax: SyntaxName) => void` | - |
65
65
  | texts | customise displayed texts | `CodeAreaTexts` | - |
66
66
  | getPopupContainer | customise where fullscreen layer is rendered into | getPopupContainer (@synerise/ds-utils) | - |
67
+ | placeholder | placeholder content | `ReactNode` | - |
67
68
 
68
69
  ### CodeAreaTexts
69
70
 
@@ -1,4 +1,7 @@
1
1
  export declare const AriaContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const EditorPlaceholder: import("styled-components").StyledComponent<"div", any, {
3
+ shouldShowPlaceholder?: boolean;
4
+ }, never>;
2
5
  export declare const EditorInnerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
6
  export declare const CodeAreaContent: import("styled-components").StyledComponent<"div", any, {}, never>;
4
7
  export declare const EditorWrapper: import("styled-components").StyledComponent<"div", any, {
@@ -8,17 +8,23 @@ export var AriaContainer = styled.div.withConfig({
8
8
  displayName: "CodeAreastyles__AriaContainer",
9
9
  componentId: "sc-svoej2-1"
10
10
  })(["flex:0 0 0;"]);
11
+ export var EditorPlaceholder = styled.div.withConfig({
12
+ displayName: "CodeAreastyles__EditorPlaceholder",
13
+ componentId: "sc-svoej2-2"
14
+ })(["pointer-events:none;position:absolute;left:62px;right:0;top:0;bottom:0;display:", ";"], function (props) {
15
+ return props.shouldShowPlaceholder ? 'block' : 'none';
16
+ });
11
17
  export var EditorInnerWrapper = styled.div.withConfig({
12
18
  displayName: "CodeAreastyles__EditorInnerWrapper",
13
- componentId: "sc-svoej2-2"
14
- })([""]);
19
+ componentId: "sc-svoej2-3"
20
+ })(["position:relative;"]);
15
21
  export var CodeAreaContent = styled.div.withConfig({
16
22
  displayName: "CodeAreastyles__CodeAreaContent",
17
- componentId: "sc-svoej2-3"
23
+ componentId: "sc-svoej2-4"
18
24
  })(["flex:1 1 100%;display:flex;min-height:0;flex-direction:column;"]);
19
25
  export var EditorWrapper = styled.div.withConfig({
20
26
  displayName: "CodeAreastyles__EditorWrapper",
21
- componentId: "sc-svoej2-4"
27
+ componentId: "sc-svoej2-5"
22
28
  })(["border:solid 1px ", ";border-radius:3px;display:flex;flex-direction:column;flex:1 1 100%;min-height:0;padding-top:12px;", ";canvas{opacity:0;}"], function (props) {
23
29
  return props.hasError ? props.theme.palette['red-600'] : props.theme.palette['grey-200'];
24
30
  }, function (props) {
@@ -26,15 +32,15 @@ export var EditorWrapper = styled.div.withConfig({
26
32
  });
27
33
  export var FullscreenHeaderTitle = styled(Title).withConfig({
28
34
  displayName: "CodeAreastyles__FullscreenHeaderTitle",
29
- componentId: "sc-svoej2-5"
35
+ componentId: "sc-svoej2-6"
30
36
  })(["display:flex;gap:16px;align-items:center;margin-bottom:0;"]);
31
37
  export var FullscreenHeader = styled(FlexRow).withConfig({
32
38
  displayName: "CodeAreastyles__FullscreenHeader",
33
- componentId: "sc-svoej2-6"
39
+ componentId: "sc-svoej2-7"
34
40
  })(["padding:16px 24px;"]);
35
41
  export var CodeAreaWrapper = styled.div.withConfig({
36
42
  displayName: "CodeAreastyles__CodeAreaWrapper",
37
- componentId: "sc-svoej2-7"
43
+ componentId: "sc-svoej2-8"
38
44
  })(["", " ", "{", ";}"], function (props) {
39
45
  if (props.isFullscreen) {
40
46
  return css(["position:fixed;width:100vw;height:100vh;z-index:", ";left:0;top:0;background:", ";", "{height:calc(100vh - ", "px);}", "{margin:0 24px;}"], props.zIndex !== undefined ? props.zIndex : props.theme.variables['zindex-modal'], props.theme.palette.white, EditorInnerWrapper, props.requiredSpace, CodeAreaContent);
@@ -45,55 +51,55 @@ export var CodeAreaWrapper = styled.div.withConfig({
45
51
  });
46
52
  export var AdditionalDescription = styled.div.withConfig({
47
53
  displayName: "CodeAreastyles__AdditionalDescription",
48
- componentId: "sc-svoej2-8"
54
+ componentId: "sc-svoej2-9"
49
55
  })(["margin-bottom:8px;"]);
50
56
  export var ContentBelow = styled(FlexRow).withConfig({
51
57
  displayName: "CodeAreastyles__ContentBelow",
52
- componentId: "sc-svoej2-9"
58
+ componentId: "sc-svoej2-10"
53
59
  })(["", " align-items:flex-start;"], function (props) {
54
60
  return !props.isEmpty && "margin-top: 8px;";
55
61
  });
56
62
  export var ContentAbove = styled(FlexRow).withConfig({
57
63
  displayName: "CodeAreastyles__ContentAbove",
58
- componentId: "sc-svoej2-10"
64
+ componentId: "sc-svoej2-11"
59
65
  })(["margin-bottom:8px;flex:0 0 auto;"]);
60
66
  export var SyntaxTitle = styled(Text).withConfig({
61
67
  displayName: "CodeAreastyles__SyntaxTitle",
62
- componentId: "sc-svoej2-11"
68
+ componentId: "sc-svoej2-12"
63
69
  })([""]);
64
70
  export var BottomBar = styled(FlexRow).withConfig({
65
71
  displayName: "CodeAreastyles__BottomBar",
66
- componentId: "sc-svoej2-12"
72
+ componentId: "sc-svoej2-13"
67
73
  })(["border-top:solid 1px ", ";padding:8px;flex:0 0 auto;"], function (props) {
68
74
  return props.theme.palette['grey-200'];
69
75
  });
70
76
  export var LeftSide = styled.div.withConfig({
71
77
  displayName: "CodeAreastyles__LeftSide",
72
- componentId: "sc-svoej2-13"
78
+ componentId: "sc-svoej2-14"
73
79
  })([""]);
74
80
  export var RightSide = styled.div.withConfig({
75
81
  displayName: "CodeAreastyles__RightSide",
76
- componentId: "sc-svoej2-14"
82
+ componentId: "sc-svoej2-15"
77
83
  })(["margin-left:auto;display:flex;gap:8px;"]);
78
84
  export var SyntaxSelect = styled(LeftSide).withConfig({
79
85
  displayName: "CodeAreastyles__SyntaxSelect",
80
- componentId: "sc-svoej2-15"
86
+ componentId: "sc-svoej2-16"
81
87
  })(["padding-left:8px;"]);
82
88
  export var BottomBarElement = styled.div.withConfig({
83
89
  displayName: "CodeAreastyles__BottomBarElement",
84
- componentId: "sc-svoej2-16"
90
+ componentId: "sc-svoej2-17"
85
91
  })([""]);
86
92
  export var Description = styled.div.withConfig({
87
93
  displayName: "CodeAreastyles__Description",
88
- componentId: "sc-svoej2-17"
94
+ componentId: "sc-svoej2-18"
89
95
  })([""]);
90
96
  export var Counter = styled.div.withConfig({
91
97
  displayName: "CodeAreastyles__Counter",
92
- componentId: "sc-svoej2-18"
98
+ componentId: "sc-svoej2-19"
93
99
  })(["font-weight:500;"]);
94
100
  export var ErrorText = styled.div.withConfig({
95
101
  displayName: "CodeAreastyles__ErrorText",
96
- componentId: "sc-svoej2-19"
102
+ componentId: "sc-svoej2-20"
97
103
  })(["color:", ";margin-bottom:4px;"], function (props) {
98
104
  return props.theme.palette['red-600'];
99
105
  });
@@ -25,6 +25,7 @@ export type CodeAreaCommonProps<SyntaxName extends CodeAreaSyntax = CodeAreaSynt
25
25
  currentSyntax: SyntaxName;
26
26
  allowFullscreen?: boolean;
27
27
  isFullscreen: boolean;
28
+ placeholder?: ReactNode;
28
29
  toggleFullscreen: () => void;
29
30
  value?: string;
30
31
  defaultValue?: string;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { type CodeAreaEditorRawProps } from '../CodeArea.types';
3
- export declare const CodeAreaEditorRaw: ({ onMount, beforeMount, options, errorText, texts, allowFullscreen, toggleFullscreen, renderFooterContent, isFullscreen, count, counterLimit, onChange, isValid, onDidChangeMarkers, isSyntaxSelectVisible, syntaxOptions, currentSyntax, readOnly, onSyntaxChange, loaderConfig, ...props }: CodeAreaEditorRawProps) => React.JSX.Element;
3
+ export declare const CodeAreaEditorRaw: ({ onMount, beforeMount, options, errorText, texts, allowFullscreen, toggleFullscreen, renderFooterContent, isFullscreen, count, counterLimit, onChange, isValid, onDidChangeMarkers, isSyntaxSelectVisible, syntaxOptions, currentSyntax, readOnly, onSyntaxChange, loaderConfig, placeholder, value, defaultValue, ...props }: CodeAreaEditorRawProps) => React.JSX.Element;
4
4
  export default CodeAreaEditorRaw;
@@ -1,7 +1,7 @@
1
- var _excluded = ["onMount", "beforeMount", "options", "errorText", "texts", "allowFullscreen", "toggleFullscreen", "renderFooterContent", "isFullscreen", "count", "counterLimit", "onChange", "isValid", "onDidChangeMarkers", "isSyntaxSelectVisible", "syntaxOptions", "currentSyntax", "readOnly", "onSyntaxChange", "loaderConfig"];
1
+ var _excluded = ["onMount", "beforeMount", "options", "errorText", "texts", "allowFullscreen", "toggleFullscreen", "renderFooterContent", "isFullscreen", "count", "counterLimit", "onChange", "isValid", "onDidChangeMarkers", "isSyntaxSelectVisible", "syntaxOptions", "currentSyntax", "readOnly", "onSyntaxChange", "loaderConfig", "placeholder", "value", "defaultValue"];
2
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
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 } from 'react';
4
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import Editor, { loader } from '@monaco-editor/react';
6
6
  import { InlineSelect } from '@synerise/ds-inline-edit';
7
7
  import Loader from '@synerise/ds-loader';
@@ -32,11 +32,17 @@ export var CodeAreaEditorRaw = function CodeAreaEditorRaw(_ref) {
32
32
  readOnly = _ref.readOnly,
33
33
  onSyntaxChange = _ref.onSyntaxChange,
34
34
  loaderConfig = _ref.loaderConfig,
35
+ placeholder = _ref.placeholder,
36
+ value = _ref.value,
37
+ defaultValue = _ref.defaultValue,
35
38
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
36
39
  var monacoRef = useRef(null);
37
40
  var loaderConfigSet = useRef(false);
38
41
  var editorRef = useRef(null);
39
42
  var wrapperRef = useRef(null);
43
+ var _useState = useState(false),
44
+ isTouched = _useState[0],
45
+ setIsTouched = _useState[1];
40
46
  var _useResizeObserver = useResizeObserver(wrapperRef),
41
47
  height = _useResizeObserver.height,
42
48
  width = _useResizeObserver.width;
@@ -80,6 +86,7 @@ export var CodeAreaEditorRaw = function CodeAreaEditorRaw(_ref) {
80
86
  if (editorRef.current) {
81
87
  editorRef.current.pushUndoStop();
82
88
  }
89
+ setIsTouched(true);
83
90
  onChange && onChange(newValue, event);
84
91
  }, [onChange, counterLimit]);
85
92
  var _useMemo = useMemo(function () {
@@ -136,12 +143,17 @@ export var CodeAreaEditorRaw = function CodeAreaEditorRaw(_ref) {
136
143
  }
137
144
  }, [currentSyntax]);
138
145
  var isBottomBarShowing = Boolean(isSyntaxSelectVisible || allowFullscreen && !isFullscreen);
146
+ var shouldShowPlaceholder = useMemo(function () {
147
+ return isTouched && !value || !value && !defaultValue;
148
+ }, [defaultValue, isTouched, value]);
139
149
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.EditorWrapper, {
140
150
  hasError: Boolean(errorText)
141
151
  }, /*#__PURE__*/React.createElement(S.EditorInnerWrapper, {
142
152
  ref: wrapperRef
143
153
  }, /*#__PURE__*/React.createElement(Editor, _extends({}, props, {
144
154
  width: width,
155
+ value: value,
156
+ defaultValue: defaultValue,
145
157
  height: height,
146
158
  language: currentSyntax,
147
159
  theme: DS_MONACO_THEME_NAME,
@@ -150,7 +162,9 @@ export var CodeAreaEditorRaw = function CodeAreaEditorRaw(_ref) {
150
162
  beforeMount: handleBeforeMount,
151
163
  onMount: handleEditorDidMount,
152
164
  loading: /*#__PURE__*/React.createElement(Loader, null)
153
- }))), isBottomBarShowing && /*#__PURE__*/React.createElement(BottomBar, {
165
+ })), placeholder && /*#__PURE__*/React.createElement(S.EditorPlaceholder, {
166
+ shouldShowPlaceholder: shouldShowPlaceholder
167
+ }, placeholder)), isBottomBarShowing && /*#__PURE__*/React.createElement(BottomBar, {
154
168
  texts: allTexts,
155
169
  syntaxSelect: syntaxSelect,
156
170
  allowFullscreen: allowFullscreen && !isFullscreen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-code-area",
3
- "version": "1.1.23",
3
+ "version": "1.2.1",
4
4
  "description": "CodeArea UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -36,12 +36,12 @@
36
36
  "types": "dist/index.d.ts",
37
37
  "dependencies": {
38
38
  "@monaco-editor/react": "4.4.6",
39
- "@synerise/ds-button": "^1.4.11",
40
- "@synerise/ds-core": "^1.5.2",
39
+ "@synerise/ds-button": "^1.4.12",
40
+ "@synerise/ds-core": "^1.6.0",
41
41
  "@synerise/ds-form-field": "^1.1.16",
42
42
  "@synerise/ds-icon": "^1.7.2",
43
- "@synerise/ds-inline-edit": "^1.0.28",
44
- "@synerise/ds-loader": "^1.0.9",
43
+ "@synerise/ds-inline-edit": "^1.0.30",
44
+ "@synerise/ds-loader": "^1.0.10",
45
45
  "@synerise/ds-tooltip": "^1.2.0",
46
46
  "@synerise/ds-typography": "^1.0.21",
47
47
  "@synerise/ds-utils": "^1.4.2"
@@ -56,5 +56,5 @@
56
56
  "devDependencies": {
57
57
  "monaco-editor": "0.34.1"
58
58
  },
59
- "gitHead": "4f56489ade5b08524578821d0c51c963002ff48c"
59
+ "gitHead": "25221abb694880c2416ceb5f7598a5c7329f3379"
60
60
  }