@snack-uikit/code-editor 0.6.5-preview-6c5a9bc3.0 → 0.7.1-preview-8e48e357.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,251 +3,161 @@
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
- ## 0.6.4 (2025-05-16)
6
+ # 0.7.0 (2025-05-28)
7
7
 
8
- ### Only dependencies have been changed
9
- * [@snack-uikit/loaders@0.9.5](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
10
- * [@snack-uikit/utils@3.8.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
8
+ ### Features
11
9
 
10
+ - **PDS-2227:** add copy button for code editor ([6891964](https://github.com/cloud-ru-tech/snack-uikit/commit/6891964be3dffecab54a3a226f250f6d303da7e9))
12
11
 
12
+ ## 0.6.4 (2025-05-16)
13
13
 
14
+ ### Only dependencies have been changed
14
15
 
16
+ - [@snack-uikit/loaders@0.9.5](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
17
+ - [@snack-uikit/utils@3.8.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
15
18
 
16
19
  ## 0.6.3 (2025-05-12)
17
20
 
18
21
  ### Only dependencies have been changed
19
- * [@snack-uikit/loaders@0.9.4](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
20
-
21
-
22
-
23
22
 
23
+ - [@snack-uikit/loaders@0.9.4](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
24
24
 
25
25
  ## 0.6.2 (2025-04-29)
26
26
 
27
-
28
27
  ### Bug Fixes
29
28
 
30
- * **PDS-2207:** Fix incorrect overwriting of the incoming path value ([4311430](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/43114301fac79ab3a5fc7e5278167c0bba4a5fe0))
31
-
32
-
33
-
34
-
29
+ - **PDS-2207:** Fix incorrect overwriting of the incoming path value ([4311430](https://github.com/cloud-ru-tech/snack-uikit/commit/43114301fac79ab3a5fc7e5278167c0bba4a5fe0))
35
30
 
36
31
  ## 0.6.1 (2025-04-21)
37
32
 
38
-
39
33
  ### Bug Fixes
40
34
 
41
- * **PDS-2163:** Code-editor reset blue border ([bbdfc42](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/bbdfc427f6c1b78c7526dd29dcd15f24be96a661))
42
-
43
-
44
-
45
-
35
+ - **PDS-2163:** Code-editor reset blue border ([bbdfc42](https://github.com/cloud-ru-tech/snack-uikit/commit/bbdfc427f6c1b78c7526dd29dcd15f24be96a661))
46
36
 
47
37
  # 0.6.0 (2025-03-27)
48
38
 
49
-
50
39
  ### BREAKING CHANGES
51
40
 
52
-
53
- * **FF-6299:** Remove module level initial function. ([5b2280a](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/5b2280af6fd2a14f990598e717d117818bf10353))
54
-
55
-
56
-
41
+ - **FF-6299:** Remove module level initial function. ([5b2280a](https://github.com/cloud-ru-tech/snack-uikit/commit/5b2280af6fd2a14f990598e717d117818bf10353))
57
42
 
58
43
  ## 0.5.2 (2025-03-17)
59
44
 
60
45
  ### Only dependencies have been changed
61
- * [@snack-uikit/loaders@0.9.3](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
62
- * [@snack-uikit/utils@3.8.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
63
-
64
-
65
-
66
46
 
47
+ - [@snack-uikit/loaders@0.9.3](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
48
+ - [@snack-uikit/utils@3.8.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
67
49
 
68
50
  ## 0.5.1 (2025-03-04)
69
51
 
70
52
  ### Only dependencies have been changed
71
- * [@snack-uikit/loaders@0.9.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
72
- * [@snack-uikit/utils@3.8.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
73
-
74
-
75
-
76
53
 
54
+ - [@snack-uikit/loaders@0.9.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
55
+ - [@snack-uikit/utils@3.8.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
77
56
 
78
57
  # 0.5.0 (2025-02-07)
79
58
 
80
-
81
59
  ### Features
82
60
 
83
- * **PDS-1445:** support json schema for yaml, json languages ([a709fe5](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/a709fe5e061917c5017de1bd1b6f01c15f4b3002))
84
-
85
-
86
-
87
-
61
+ - **PDS-1445:** support json schema for yaml, json languages ([a709fe5](https://github.com/cloud-ru-tech/snack-uikit/commit/a709fe5e061917c5017de1bd1b6f01c15f4b3002))
88
62
 
89
63
  ## 0.4.7 (2025-01-23)
90
64
 
91
65
  ### Only dependencies have been changed
92
- * [@snack-uikit/loaders@0.9.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
93
- * [@snack-uikit/utils@3.7.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
94
-
95
-
96
-
97
66
 
67
+ - [@snack-uikit/loaders@0.9.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
68
+ - [@snack-uikit/utils@3.7.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
98
69
 
99
70
  ## 0.4.6 (2024-12-17)
100
71
 
101
72
  ### Only dependencies have been changed
102
- * [@snack-uikit/loaders@0.9.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
103
-
104
-
105
-
106
73
 
74
+ - [@snack-uikit/loaders@0.9.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
107
75
 
108
76
  ## 0.4.5 (2024-12-12)
109
77
 
110
78
  ### Only dependencies have been changed
111
- * [@snack-uikit/loaders@0.8.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
112
- * [@snack-uikit/utils@3.6.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
113
-
114
-
115
-
116
79
 
80
+ - [@snack-uikit/loaders@0.8.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
81
+ - [@snack-uikit/utils@3.6.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
117
82
 
118
83
  ## 0.4.4 (2024-11-27)
119
84
 
120
-
121
85
  ### Bug Fixes
122
86
 
123
- * **PDS-1023:** fix calc isDark ([8c34b37](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/8c34b3758b20ef57c4f68e1dbc0472acf6ef611c))
124
-
125
-
126
-
127
-
87
+ - **PDS-1023:** fix calc isDark ([8c34b37](https://github.com/cloud-ru-tech/snack-uikit/commit/8c34b3758b20ef57c4f68e1dbc0472acf6ef611c))
128
88
 
129
89
  ## 0.4.3 (2024-11-14)
130
90
 
131
91
  ### Only dependencies have been changed
132
- * [@snack-uikit/loaders@0.8.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
133
-
134
-
135
-
136
92
 
93
+ - [@snack-uikit/loaders@0.8.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
137
94
 
138
95
  ## 0.4.2 (2024-11-12)
139
96
 
140
97
  ### Only dependencies have been changed
141
- * [@snack-uikit/loaders@0.8.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
142
-
143
-
144
-
145
98
 
99
+ - [@snack-uikit/loaders@0.8.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
146
100
 
147
101
  ## 0.4.1 (2024-10-31)
148
102
 
149
103
  ### Only dependencies have been changed
150
- * [@snack-uikit/loaders@0.7.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
151
-
152
-
153
-
154
104
 
105
+ - [@snack-uikit/loaders@0.7.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/loaders/CHANGELOG.md)
155
106
 
156
107
  # 0.4.0 (2024-10-28)
157
108
 
158
-
159
109
  ### Features
160
110
 
161
- * **FF-5782:** sass use/forward approach ([3e53869](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/3e53869ace864a7718e434b7f410c15dbd911cd5))
162
-
163
-
164
-
165
-
111
+ - **FF-5782:** sass use/forward approach ([3e53869](https://github.com/cloud-ru-tech/snack-uikit/commit/3e53869ace864a7718e434b7f410c15dbd911cd5))
166
112
 
167
113
  # 0.3.0 (2024-10-28)
168
114
 
169
-
170
115
  ### Features
171
116
 
172
- * **FF-5502:** add cjs build ([ffada28](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/ffada28bfdc37ea760eb1c8759342e680bdf8dd6))
173
-
174
-
175
-
176
-
117
+ - **FF-5502:** add cjs build ([ffada28](https://github.com/cloud-ru-tech/snack-uikit/commit/ffada28bfdc37ea760eb1c8759342e680bdf8dd6))
177
118
 
178
119
  ## 0.2.3 (2024-09-23)
179
120
 
180
-
181
121
  ### Bug Fixes
182
122
 
183
- * **PDS-480:** remove direct usage of browser api elements ([1231ff7](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/1231ff7ab7a1b210b579a7b694633ef23bffcf44))
184
-
185
-
186
-
187
-
123
+ - **PDS-480:** remove direct usage of browser api elements ([1231ff7](https://github.com/cloud-ru-tech/snack-uikit/commit/1231ff7ab7a1b210b579a7b694633ef23bffcf44))
188
124
 
189
125
  ## 0.2.2 (2024-07-19)
190
126
 
191
-
192
127
  ### Bug Fixes
193
128
 
194
- * **FF-0000:** code-editor theme init ([da4f622](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/da4f622f5a5b9b8028127d357dbe6fc8e20a81ab))
195
-
196
-
197
-
198
-
129
+ - **FF-0000:** code-editor theme init ([da4f622](https://github.com/cloud-ru-tech/snack-uikit/commit/da4f622f5a5b9b8028127d357dbe6fc8e20a81ab))
199
130
 
200
131
  ## 0.2.1 (2024-07-18)
201
132
 
202
-
203
133
  ### Bug Fixes
204
134
 
205
- * **PDS-450:** add loader config init ([1453a87](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/1453a87b70885d1b1beb351b6cf9124f2cf3889a))
206
-
207
-
208
-
209
-
135
+ - **PDS-450:** add loader config init ([1453a87](https://github.com/cloud-ru-tech/snack-uikit/commit/1453a87b70885d1b1beb351b6cf9124f2cf3889a))
210
136
 
211
137
  # 0.2.0 (2024-04-27)
212
138
 
213
-
214
139
  ### Features
215
140
 
216
- * **PDS-62:** upd default theme; add theme prop ([522efca](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/522efcad7a40cf9dccfef8c5192580c6d2c4b1ee))
217
-
218
-
219
-
220
-
141
+ - **PDS-62:** upd default theme; add theme prop ([522efca](https://github.com/cloud-ru-tech/snack-uikit/commit/522efcad7a40cf9dccfef8c5192580c6d2c4b1ee))
221
142
 
222
143
  ## 0.1.2 (2024-04-23)
223
144
 
224
145
  ### Only dependencies have been changed
225
- * [@snack-uikit/utils@3.3.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
226
-
227
-
228
-
229
146
 
147
+ - [@snack-uikit/utils@3.3.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
230
148
 
231
149
  ## 0.1.1 (2023-12-14)
232
150
 
233
151
  ### Only dependencies have been changed
234
- * [@snack-uikit/utils@3.2.0](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/utils/CHANGELOG.md)
235
-
236
-
237
-
238
152
 
153
+ - [@snack-uikit/utils@3.2.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
239
154
 
240
155
  # 0.1.0 (2023-12-06)
241
156
 
242
-
243
157
  ### Features
244
158
 
245
- * **FF-3646:** add code editor ([f4e6160](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/f4e61608da56ab4bac07a797cf2fb11024551c73))
246
- * **FF-3646:** update imports ([27f5588](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/commits/27f5588fe5a85486cafe1a76641249992d3fd310))
247
-
248
-
249
-
250
-
159
+ - **FF-3646:** add code editor ([f4e6160](https://github.com/cloud-ru-tech/snack-uikit/commit/f4e61608da56ab4bac07a797cf2fb11024551c73))
160
+ - **FF-3646:** update imports ([27f5588](https://github.com/cloud-ru-tech/snack-uikit/commit/27f5588fe5a85486cafe1a76641249992d3fd310))
251
161
 
252
162
  ## CHANGELOG
253
163
 
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  | jsonSchema* | `JsonSchema` | - | Схема для валидации |
16
16
  | themeName | `string` | - | Название текущей темы. Значение не важно, важно что смена значения запускает пересчет стилей. |
17
17
  | hasBackground | `boolean` | true | Включение/отключение псевдобекграунда |
18
- | hasCopyHeader | `boolean` | - | Включение/отключение шапки с кнопкой копирования |
18
+ | hasHeader | `boolean` | - | Включение/отключение шапки |
19
19
  | onCopyClick | `() => void` | - | Клик по кнопке копирования |
20
20
  | defaultValue | `string` | - | Default value of the current model |
21
21
  | defaultLanguage | `string` | - | Default language of the current model |
@@ -10,12 +10,12 @@ export type CodeEditorProps = WithSupportProps<{
10
10
  */
11
11
  hasBackground?: boolean;
12
12
  /**
13
- * Включение/отключение шапки с кнопкой копирования
13
+ * Включение/отключение шапки
14
14
  */
15
- hasCopyHeader?: boolean;
15
+ hasHeader?: boolean;
16
16
  /**
17
17
  * Клик по кнопке копирования
18
18
  */
19
19
  onCopyClick?(): void;
20
20
  }> & (EditorBaseProps | EditorWithJsonSchemaProps);
21
- export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick, hasCopyHeader, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick, hasHeader, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -40,9 +40,9 @@ function CodeEditor(_a) {
40
40
  onMount,
41
41
  language,
42
42
  onCopyClick,
43
- hasCopyHeader
43
+ hasHeader
44
44
  } = _a,
45
- props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "hasCopyHeader"]);
45
+ props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "hasHeader"]);
46
46
  const monaco = (0, react_1.useMonaco)();
47
47
  const [wrapperElement, setWrapperElement] = (0, react_2.useState)(null);
48
48
  const {
@@ -119,10 +119,10 @@ function CodeEditor(_a) {
119
119
  className: className
120
120
  }, (0, utils_1.extractSupportProps)(props), {
121
121
  ref: setWrapperElement,
122
- children: [hasCopyHeader && (0, jsx_runtime_1.jsxs)("div", {
122
+ children: [hasHeader && (0, jsx_runtime_1.jsxs)("div", {
123
123
  className: styles_module_scss_1.default.headline,
124
124
  children: [language && (0, jsx_runtime_1.jsx)(typography_1.Typography.SansLabelS, {
125
- children: (0, utils_2.toTitleCase)(language)
125
+ children: (0, utils_2.uppercaseFirstLetter)(language)
126
126
  }), (0, jsx_runtime_1.jsx)(CopyButton_1.CopyButton, {
127
127
  valueToCopy: props.value || '',
128
128
  size: 's',
@@ -4,6 +4,6 @@ export type CopyButtonProps = WithSupportProps<{
4
4
  valueToCopy: string | number;
5
5
  size?: ButtonFunctionProps['size'];
6
6
  className?: string;
7
- onClick?: ButtonFunctionProps['onClick'];
7
+ onClick?(): void;
8
8
  }>;
9
9
  export declare function CopyButton({ valueToCopy, size, className, onClick, ...rest }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", {
19
19
  exports.CopyButton = CopyButton;
20
20
  const jsx_runtime_1 = require("react/jsx-runtime");
21
21
  const react_1 = require("react");
22
- const frontend_tools_copy_to_clipboard_1 = require("@cloud-ru/frontend-tools-copy-to-clipboard");
22
+ const ft_copy_to_clipboard_1 = require("@cloud-ru/ft-copy-to-clipboard");
23
23
  const button_1 = require("@snack-uikit/button");
24
24
  const icons_1 = require("@snack-uikit/icons");
25
25
  const locale_1 = require("@snack-uikit/locale");
@@ -43,11 +43,11 @@ function CopyButton(_a) {
43
43
  const closeChecked = () => setIsCheckedOpen(false);
44
44
  const handleClick = event => {
45
45
  event.stopPropagation();
46
- valueToCopy && (0, frontend_tools_copy_to_clipboard_1.copyToClipboard)(String(valueToCopy));
46
+ valueToCopy && (0, ft_copy_to_clipboard_1.copyToClipboard)(String(valueToCopy));
47
47
  openChecked();
48
48
  clearTimeout(timerId.current);
49
49
  timerId.current = setTimeout(closeChecked, 1000);
50
- onClick === null || onClick === void 0 ? void 0 : onClick(event);
50
+ onClick === null || onClick === void 0 ? void 0 : onClick();
51
51
  };
52
52
  (0, react_1.useEffect)(() => () => {
53
53
  closeChecked();
@@ -13,9 +13,9 @@
13
13
  }
14
14
 
15
15
  .headline{
16
- min-height:var(--size-markdown-code-editor-headline-min-height, 36px);
17
- padding-left:var(--space-markdown-code-editor-headline-horizontal-padding, 12px);
18
- padding-right:var(--space-markdown-code-editor-headline-horizontal-padding, 12px);
16
+ min-height:var(--size-code-editor-headline-min-height, 36px);
17
+ padding-left:var(--space-code-editor-headline-horizontal-padding, 12px);
18
+ padding-right:var(--space-code-editor-headline-horizontal-padding, 12px);
19
19
  display:flex;
20
20
  align-items:center;
21
21
  justify-content:space-between;
@@ -3,4 +3,4 @@ import { JsonSchema } from './types';
3
3
  export declare function rgb2hsl(HTMLcolor: string): number[];
4
4
  export declare function isDark(color: string): boolean;
5
5
  export declare const getJsonSchema: (jsonSchema?: JsonSchema) => SchemasSettings | undefined;
6
- export declare function toTitleCase(value: string): string;
6
+ export declare function uppercaseFirstLetter(value: string): string;
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "__esModule", {
11
11
  exports.getJsonSchema = void 0;
12
12
  exports.rgb2hsl = rgb2hsl;
13
13
  exports.isDark = isDark;
14
- exports.toTitleCase = toTitleCase;
14
+ exports.uppercaseFirstLetter = uppercaseFirstLetter;
15
15
  const chroma_js_1 = __importDefault(require("chroma-js"));
16
16
  const constants_1 = require("./constants");
17
17
  function rgb2hsl(HTMLcolor) {
@@ -52,11 +52,10 @@ const getJsonSchema = jsonSchema => jsonSchema && Object.assign(Object.assign({}
52
52
  fileMatch: [jsonSchema.fileMatch]
53
53
  });
54
54
  exports.getJsonSchema = getJsonSchema;
55
- function toTitleCase(value) {
56
- if (value.trim().length === 0) {
55
+ function uppercaseFirstLetter(value) {
56
+ const trimmedValue = value.trim();
57
+ if (trimmedValue.length === 0) {
57
58
  return value;
58
59
  }
59
- const valueLetters = value.trim().split('');
60
- valueLetters[0] = valueLetters[0].toUpperCase();
61
- return valueLetters.join('');
60
+ return trimmedValue[0].toUpperCase() + trimmedValue.slice(1);
62
61
  }
@@ -10,12 +10,12 @@ export type CodeEditorProps = WithSupportProps<{
10
10
  */
11
11
  hasBackground?: boolean;
12
12
  /**
13
- * Включение/отключение шапки с кнопкой копирования
13
+ * Включение/отключение шапки
14
14
  */
15
- hasCopyHeader?: boolean;
15
+ hasHeader?: boolean;
16
16
  /**
17
17
  * Клик по кнопке копирования
18
18
  */
19
19
  onCopyClick?(): void;
20
20
  }> & (EditorBaseProps | EditorWithJsonSchemaProps);
21
- export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick, hasCopyHeader, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function CodeEditor({ themeName, className, theme, options, loading, hasBackground, onMount, language, onCopyClick, hasHeader, ...props }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -20,9 +20,9 @@ import { CODE_EDITOR_OPTIONS, DEFAULT_THEME_OPTIONS, DEFAULT_THEME_VALUES } from
20
20
  import { CopyButton } from './CopyButton';
21
21
  import { useApplyJsonSchema, useCalculatedThemeValues } from './hooks';
22
22
  import styles from './styles.module.css';
23
- import { isDark, toTitleCase } from './utils';
23
+ import { isDark, uppercaseFirstLetter } from './utils';
24
24
  export function CodeEditor(_a) {
25
- var { themeName, className, theme, options, loading, hasBackground = true, onMount, language, onCopyClick, hasCopyHeader } = _a, props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "hasCopyHeader"]);
25
+ var { themeName, className, theme, options, loading, hasBackground = true, onMount, language, onCopyClick, hasHeader } = _a, props = __rest(_a, ["themeName", "className", "theme", "options", "loading", "hasBackground", "onMount", "language", "onCopyClick", "hasHeader"]);
26
26
  const monaco = useMonaco();
27
27
  const [wrapperElement, setWrapperElement] = useState(null);
28
28
  const { jsonSchemaProps, jsonSchemaOptions } = useApplyJsonSchema(language, 'jsonSchema' in props ? props.jsonSchema : undefined);
@@ -89,5 +89,5 @@ export function CodeEditor(_a) {
89
89
  fontFamily: themeValues.mono.body.s['font-family'],
90
90
  }
91
91
  : DEFAULT_THEME_OPTIONS.mono.s)), options)), [options, themeValues === null || themeValues === void 0 ? void 0 : themeValues.mono, jsonSchemaOptions]);
92
- return (_jsxs("div", Object.assign({ className: className }, extractSupportProps(props), { ref: setWrapperElement, children: [hasCopyHeader && (_jsxs("div", { className: styles.headline, children: [language && _jsx(Typography.SansLabelS, { children: toTitleCase(language) }), _jsx(CopyButton, { valueToCopy: props.value || '', size: 's', onClick: onCopyClick })] })), _jsx(Editor, Object.assign({}, jsonSchemaProps, props, { theme: theme !== null && theme !== void 0 ? theme : (dark ? 'snackDark' : 'snack'), className: cn({ [styles.editor]: hasBackground }), loading: loading !== null && loading !== void 0 ? loading : _jsx(Spinner, {}), options: mergedOptions, onMount: onEditorMount, language: language }))] })));
92
+ return (_jsxs("div", Object.assign({ className: className }, extractSupportProps(props), { ref: setWrapperElement, children: [hasHeader && (_jsxs("div", { className: styles.headline, children: [language && _jsx(Typography.SansLabelS, { children: uppercaseFirstLetter(language) }), _jsx(CopyButton, { valueToCopy: props.value || '', size: 's', onClick: onCopyClick })] })), _jsx(Editor, Object.assign({}, jsonSchemaProps, props, { theme: theme !== null && theme !== void 0 ? theme : (dark ? 'snackDark' : 'snack'), className: cn({ [styles.editor]: hasBackground }), loading: loading !== null && loading !== void 0 ? loading : _jsx(Spinner, {}), options: mergedOptions, onMount: onEditorMount, language: language }))] })));
93
93
  }
@@ -4,6 +4,6 @@ export type CopyButtonProps = WithSupportProps<{
4
4
  valueToCopy: string | number;
5
5
  size?: ButtonFunctionProps['size'];
6
6
  className?: string;
7
- onClick?: ButtonFunctionProps['onClick'];
7
+ onClick?(): void;
8
8
  }>;
9
9
  export declare function CopyButton({ valueToCopy, size, className, onClick, ...rest }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { useEffect, useRef, useState } from 'react';
14
- import { copyToClipboard } from '@cloud-ru/frontend-tools-copy-to-clipboard';
14
+ import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
15
15
  import { ButtonFunction } from '@snack-uikit/button';
16
16
  import { CheckSVG, CopySVG } from '@snack-uikit/icons';
17
17
  import { useLocale } from '@snack-uikit/locale';
@@ -31,7 +31,7 @@ export function CopyButton(_a) {
31
31
  openChecked();
32
32
  clearTimeout(timerId.current);
33
33
  timerId.current = setTimeout(closeChecked, 1000);
34
- onClick === null || onClick === void 0 ? void 0 : onClick(event);
34
+ onClick === null || onClick === void 0 ? void 0 : onClick();
35
35
  };
36
36
  useEffect(() => () => {
37
37
  closeChecked();
@@ -13,9 +13,9 @@
13
13
  }
14
14
 
15
15
  .headline{
16
- min-height:var(--size-markdown-code-editor-headline-min-height, 36px);
17
- padding-left:var(--space-markdown-code-editor-headline-horizontal-padding, 12px);
18
- padding-right:var(--space-markdown-code-editor-headline-horizontal-padding, 12px);
16
+ min-height:var(--size-code-editor-headline-min-height, 36px);
17
+ padding-left:var(--space-code-editor-headline-horizontal-padding, 12px);
18
+ padding-right:var(--space-code-editor-headline-horizontal-padding, 12px);
19
19
  display:flex;
20
20
  align-items:center;
21
21
  justify-content:space-between;
@@ -3,4 +3,4 @@ import { JsonSchema } from './types';
3
3
  export declare function rgb2hsl(HTMLcolor: string): number[];
4
4
  export declare function isDark(color: string): boolean;
5
5
  export declare const getJsonSchema: (jsonSchema?: JsonSchema) => SchemasSettings | undefined;
6
- export declare function toTitleCase(value: string): string;
6
+ export declare function uppercaseFirstLetter(value: string): string;
@@ -38,11 +38,10 @@ export function isDark(color) {
38
38
  return (h < 0.55 && l >= 0.5) || (h >= 0.55 && l >= 0.75);
39
39
  }
40
40
  export const getJsonSchema = (jsonSchema) => jsonSchema && Object.assign(Object.assign({}, jsonSchema), { uri: (jsonSchema === null || jsonSchema === void 0 ? void 0 : jsonSchema.uri) || DEFAULT_SCHEMA_URI, fileMatch: [jsonSchema.fileMatch] });
41
- export function toTitleCase(value) {
42
- if (value.trim().length === 0) {
41
+ export function uppercaseFirstLetter(value) {
42
+ const trimmedValue = value.trim();
43
+ if (trimmedValue.length === 0) {
43
44
  return value;
44
45
  }
45
- const valueLetters = value.trim().split('');
46
- valueLetters[0] = valueLetters[0].toUpperCase();
47
- return valueLetters.join('');
46
+ return trimmedValue[0].toUpperCase() + trimmedValue.slice(1);
48
47
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.6.5-preview-6c5a9bc3.0",
7
+ "version": "0.7.1-preview-8e48e357.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -16,10 +16,10 @@
16
16
  "import": "./dist/esm/index.js",
17
17
  "require": "./dist/cjs/index.js"
18
18
  },
19
- "homepage": "https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/tree/master/packages/code-editor",
19
+ "homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/code-editor",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit.git",
22
+ "url": "https://github.com/cloud-ru-tech/snack-uikit.git",
23
23
  "directory": "packages/code-editor"
24
24
  },
25
25
  "author": "Nikita Ershov <niershov@cloud.ru>",
@@ -36,12 +36,11 @@
36
36
  "license": "Apache-2.0",
37
37
  "scripts": {},
38
38
  "dependencies": {
39
- "@cloud-ru/frontend-tools-copy-to-clipboard": "0.0.1-preview-8188049.0",
39
+ "@cloud-ru/ft-copy-to-clipboard": "0.1.0",
40
40
  "@monaco-editor/react": "4.6.0",
41
41
  "@snack-uikit/button": "0.19.11",
42
42
  "@snack-uikit/icons": "0.26.3",
43
43
  "@snack-uikit/loaders": "0.9.5",
44
- "@snack-uikit/locale": "0.14.1-preview-6c5a9bc3.0",
45
44
  "@snack-uikit/tooltip": "0.17.2",
46
45
  "@snack-uikit/typography": "0.8.7",
47
46
  "@snack-uikit/utils": "3.8.2",
@@ -49,8 +48,11 @@
49
48
  "classnames": "2.5.1",
50
49
  "monaco-yaml": "5.2.3"
51
50
  },
51
+ "peerDependencies": {
52
+ "@snack-uikit/locale": "*"
53
+ },
52
54
  "devDependencies": {
53
55
  "@types/chroma-js": "2.4.4"
54
56
  },
55
- "gitHead": "f7b20fc5008846a7aaddf93c2cbeb6197978e97f"
57
+ "gitHead": "ef04beebbc2d36eb83cfbf3a755dae003d7377b7"
56
58
  }
@@ -11,7 +11,7 @@ import { CopyButton } from './CopyButton';
11
11
  import { useApplyJsonSchema, useCalculatedThemeValues } from './hooks';
12
12
  import styles from './styles.module.scss';
13
13
  import { EditorBaseProps, EditorWithJsonSchemaProps } from './types';
14
- import { isDark, toTitleCase } from './utils';
14
+ import { isDark, uppercaseFirstLetter } from './utils';
15
15
 
16
16
  export type CodeEditorProps = WithSupportProps<{
17
17
  /**
@@ -23,9 +23,9 @@ export type CodeEditorProps = WithSupportProps<{
23
23
  */
24
24
  hasBackground?: boolean;
25
25
  /**
26
- * Включение/отключение шапки с кнопкой копирования
26
+ * Включение/отключение шапки
27
27
  */
28
- hasCopyHeader?: boolean;
28
+ hasHeader?: boolean;
29
29
  /**
30
30
  * Клик по кнопке копирования
31
31
  */
@@ -43,7 +43,7 @@ export function CodeEditor({
43
43
  onMount,
44
44
  language,
45
45
  onCopyClick,
46
- hasCopyHeader,
46
+ hasHeader,
47
47
  ...props
48
48
  }: CodeEditorProps) {
49
49
  const monaco = useMonaco();
@@ -144,9 +144,9 @@ export function CodeEditor({
144
144
 
145
145
  return (
146
146
  <div className={className} {...extractSupportProps(props)} ref={setWrapperElement}>
147
- {hasCopyHeader && (
147
+ {hasHeader && (
148
148
  <div className={styles.headline}>
149
- {language && <Typography.SansLabelS>{toTitleCase(language)}</Typography.SansLabelS>}
149
+ {language && <Typography.SansLabelS>{uppercaseFirstLetter(language)}</Typography.SansLabelS>}
150
150
  <CopyButton valueToCopy={props.value || ''} size={'s'} onClick={onCopyClick} />
151
151
  </div>
152
152
  )}
@@ -1,6 +1,6 @@
1
1
  import { MouseEventHandler, useEffect, useRef, useState } from 'react';
2
2
 
3
- import { copyToClipboard } from '@cloud-ru/frontend-tools-copy-to-clipboard';
3
+ import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
4
4
  import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
5
5
  import { CheckSVG, CopySVG } from '@snack-uikit/icons';
6
6
  import { useLocale } from '@snack-uikit/locale';
@@ -13,7 +13,7 @@ export type CopyButtonProps = WithSupportProps<{
13
13
  valueToCopy: string | number;
14
14
  size?: ButtonFunctionProps['size'];
15
15
  className?: string;
16
- onClick?: ButtonFunctionProps['onClick'];
16
+ onClick?(): void;
17
17
  }>;
18
18
 
19
19
  export function CopyButton({ valueToCopy, size = 's', className, onClick, ...rest }: CopyButtonProps) {
@@ -29,7 +29,7 @@ export function CopyButton({ valueToCopy, size = 's', className, onClick, ...res
29
29
  openChecked();
30
30
  clearTimeout(timerId.current);
31
31
  timerId.current = setTimeout(closeChecked, 1000);
32
- onClick?.(event);
32
+ onClick?.();
33
33
  };
34
34
 
35
35
  useEffect(
@@ -1,5 +1,5 @@
1
1
  @use '@snack-uikit/figma-tokens/build/scss/styles-theme-variables' as var;
2
- @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-markdown' as stm;
2
+ @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-codeEditor' as stc;
3
3
 
4
4
 
5
5
 
@@ -22,12 +22,12 @@
22
22
  }
23
23
 
24
24
  .headline {
25
- @include stm.composite-var(stm.$markdown-syntax-code-editor-headline);
25
+ @include stc.composite-var(stc.$code-editor-headline);
26
26
 
27
27
  display: flex;
28
28
  align-items: center;
29
29
  justify-content: space-between;
30
30
 
31
- background-color: stm.$sys-neutral-background;
32
- border-color: stm.$sys-neutral-decor-default;
31
+ background-color: stc.$sys-neutral-background;
32
+ border-color: stc.$sys-neutral-decor-default;
33
33
  }
@@ -57,12 +57,12 @@ export function isDark(color: string) {
57
57
  export const getJsonSchema = (jsonSchema?: JsonSchema): SchemasSettings | undefined =>
58
58
  jsonSchema && { ...jsonSchema, uri: jsonSchema?.uri || DEFAULT_SCHEMA_URI, fileMatch: [jsonSchema.fileMatch] };
59
59
 
60
- export function toTitleCase(value: string) {
61
- if (value.trim().length === 0) {
60
+ export function uppercaseFirstLetter(value: string) {
61
+ const trimmedValue = value.trim();
62
+
63
+ if (trimmedValue.length === 0) {
62
64
  return value;
63
65
  }
64
66
 
65
- const valueLetters = value.trim().split('');
66
- valueLetters[0] = valueLetters[0].toUpperCase();
67
- return valueLetters.join('');
67
+ return trimmedValue[0].toUpperCase() + trimmedValue.slice(1);
68
68
  }