@synerise/ds-code-area 2.1.1 → 2.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,25 @@
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
+ ## [2.2.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-area@2.2.0...@synerise/ds-code-area@2.2.1) (2026-11-03)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-code-area
9
+
10
+
11
+
12
+
13
+
14
+ # [2.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-area@2.1.1...@synerise/ds-code-area@2.2.0) (2026-10-29)
15
+
16
+
17
+ ### Features
18
+
19
+ * integrate Token Studio design tokens across the design system ([aabb447](https://github.com/Synerise/synerise-design/commit/aabb447edfb2d0c85e3de1f07e809ef84083453b))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [2.1.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-area@2.1.0...@synerise/ds-code-area@2.1.1) (2026-10-28)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-code-area
package/CLAUDE.md CHANGED
@@ -10,7 +10,7 @@ src/
10
10
  CodeArea.types.ts — all type definitions
11
11
  CodeArea.styles.ts — all styled-components (also re-exported from index.ts)
12
12
  CodeArea.figma.tsx — Figma Code Connect file
13
- constants.ts — MONACO_DEFAULT_OPTIONS, DS_MONACO_THEME, DS_MONACO_THEME_NAME
13
+ constants.ts — MONACO_DEFAULT_OPTIONS, getDsMonacoTheme, DS_MONACO_THEME_NAME, DS_MONACO_THEME (deprecated)
14
14
  index.ts — public exports
15
15
  components/
16
16
  CodeAreaEditor.tsx — forwardRef wrapper; handles label, counter, error, fullscreen header
@@ -131,7 +131,7 @@ type Syntax = 'json' | 'javascript';
131
131
  - **`onFullscreenChange` receives the old state**: `onFullscreenChange && onFullscreenChange(isFullscreen)` is called before `setIsFullscreen` — the callback gets the value *before* the toggle (likely a bug).
132
132
  - **Counter hard-limit**: when `value.length > counter.limit`, `CodeAreaEditorRaw` triggers `'undo'` on the Monaco instance directly. The `onChange` callback is not called for over-limit input.
133
133
  - **`isValid` logic**: `isValid` starts as `true`, is set to `false` when `errorText` is truthy (via `useEffect`), and is also set to `false` when Monaco reports markers (lint/parse errors). Both paths independently drive the error state.
134
- - **Monaco theme**: `DS_MONACO_THEME` (`'DSTheme'`) is registered in `beforeMount` and uses a transparent background so the wrapper's background colour shows through.
134
+ - **Monaco theme**: `getDsMonacoTheme(useTheme().tokens)` builds `'DSTheme'` from the active mode's resolved tokens (Monaco needs hex, not `var()`), with a transparent background so the wrapper's background colour shows through. The base is `'vs-dark'` when `--ds-color-background-base-default` is dark, so syntax colours stay readable. It is defined in `beforeMount` and re-defined + re-applied whenever the tokens change (a `mode` switch). Monaco themes are global, so the last editor to apply one wins page-wide. `DS_MONACO_THEME` is the light-only constant, kept for consumers that import it.
135
135
  - **`loaderConfig` is one-shot**: a `loaderConfigSet` ref prevents calling `loader.config()` more than once per component instance — changing `loaderConfig` after mount has no effect.
136
136
  - **`placeholder` offset**: positioned `left: 62px` to align with the editor text column after Monaco's line-number gutter. Adjust if `options.lineNumbers` is set to `'off'`.
137
137
  - **BottomBar visibility**: shown when at least one of `isSyntaxSelectVisible`, `allowFullscreen && !isFullscreen`, or `renderFooterContent` is truthy.
package/dist/CodeArea.js CHANGED
@@ -7,6 +7,7 @@ import "@synerise/ds-button";
7
7
  import "@synerise/ds-icon";
8
8
  import { CodeAreaEditor } from "./components/CodeAreaEditor.js";
9
9
  import "@monaco-editor/react";
10
+ import "@synerise/ds-core";
10
11
  import "@synerise/ds-inline-edit";
11
12
  import "@synerise/ds-loader";
12
13
  import "./constants.js";
@@ -8,7 +8,7 @@ export declare const EditorWrapper: import('styled-components').StyledComponent<
8
8
  hasError: boolean;
9
9
  noBorder?: boolean;
10
10
  }, never>;
11
- export declare const FullscreenHeaderTitle: import('styled-components').StyledComponent<({ level, withoutMargin, children, className, ellipsis, ...rest }: import('@synerise/ds-typography/dist/Title.types').Props) => React.JSX.Element, any, {}, never>;
11
+ export declare const FullscreenHeaderTitle: import('styled-components').StyledComponent<({ level, withoutMargin, children, className, ellipsis, ...rest }: import('@synerise/ds-typography/dist/Title.types.js').Props) => React.JSX.Element, any, {}, never>;
12
12
  export declare const FullscreenHeader: import('styled-components').StyledComponent<"div", any, {}, never>;
13
13
  export declare const ContentBelow: import('styled-components').StyledComponent<"div", any, {
14
14
  isEmpty?: boolean;
@@ -27,7 +27,7 @@ export declare const AdditionalDescription: import('styled-components').StyledCo
27
27
  export declare const ContentAbove: import('styled-components').StyledComponent<"div", any, {}, never>;
28
28
  export declare const SyntaxTitle: import('styled-components').StyledComponent<({ size, className, children, ellipsis, style, strong, ...dataAttributes }: import('@synerise/ds-utils').DataAttributes & {
29
29
  size?: import('@synerise/ds-typography').TextSize;
30
- ellipsis?: import('@synerise/ds-typography/dist/Ellipsis').EllipsisProps;
30
+ ellipsis?: import('@synerise/ds-typography/dist/Ellipsis.js').EllipsisProps;
31
31
  children?: import('react').ReactNode;
32
32
  className?: string;
33
33
  style?: import('react').CSSProperties;
@@ -23,7 +23,7 @@ const CodeAreaContent = /* @__PURE__ */ styled.div.withConfig({
23
23
  const EditorWrapper = /* @__PURE__ */ styled.div.withConfig({
24
24
  displayName: "CodeAreastyles__EditorWrapper",
25
25
  componentId: "sc-svoej2-5"
26
- })(["border:", ";border-radius:3px;display:flex;flex-direction:column;flex:1 1 100%;min-height:0;padding-top:12px;", ";canvas{opacity:0;}"], (props) => props.noBorder ? "none" : `solid 1px ${props.hasError ? props.theme.palette["red-600"] : props.theme.palette["grey-200"]}`, (props) => props.hasError && css(["background:", ";box-shadow:", ";"], props.theme.palette["red-050"], props.noBorder ? "none" : `inset 0 0 0 1px ${props.theme.palette["red-600"]}`));
26
+ })(["border:", ";border-radius:3px;display:flex;flex-direction:column;flex:1 1 100%;min-height:0;padding-top:12px;", ";canvas{opacity:0;}"], (props) => props.noBorder ? "none" : `solid 1px ${props.hasError ? "var(--ds-form-field-border-validated)" : "var(--ds-form-field-border-default)"}`, (props) => props.hasError && css(["background:var(--ds-form-field-bg-validated);box-shadow:", ";"], props.noBorder ? "none" : `inset 0 0 0 1px var(--ds-form-field-border-validated)`));
27
27
  const FullscreenHeaderTitle = /* @__PURE__ */ styled(Title).withConfig({
28
28
  displayName: "CodeAreastyles__FullscreenHeaderTitle",
29
29
  componentId: "sc-svoej2-6"
@@ -39,16 +39,16 @@ const ContentBelow = /* @__PURE__ */ styled(FlexRow).withConfig({
39
39
  const FullscreenMask = /* @__PURE__ */ styled.div.withConfig({
40
40
  displayName: "CodeAreastyles__FullscreenMask",
41
41
  componentId: "sc-svoej2-9"
42
- })(["position:fixed;top:0;left:0;right:0;bottom:0;z-index:", ";background:", ";opacity:0.2;"], (props) => props.zIndex !== void 0 ? props.zIndex : props.theme.variables["zindex-modal"], (props) => props.theme.palette["grey-800"]);
42
+ })(["position:fixed;top:0;left:0;right:0;bottom:0;z-index:", ";background:var(--ds-color-background-overlay-default);"], (props) => props.zIndex !== void 0 ? props.zIndex : props.theme.variables["zindex-modal"]);
43
43
  const CodeAreaWrapper = /* @__PURE__ */ styled.div.withConfig({
44
44
  displayName: "CodeAreastyles__CodeAreaWrapper",
45
45
  componentId: "sc-svoej2-10"
46
46
  })(["", " ", "{", ";}"], (props) => {
47
47
  if (props.isFullscreen) {
48
- return css(["position:fixed;top:24px;left:24px;right:24px;bottom:24px;z-index:", ";background:", ";border-radius:3px;box-shadow:", ";", "{height:calc(100vh - 48px - ", "px);}", "{padding:0 24px;}", ":not(:empty){padding-bottom:16px;}"], props.zIndex !== void 0 ? props.zIndex : props.theme.variables["zindex-modal"], props.theme.palette.white, props.theme.variables["box-shadow-2"], EditorInnerWrapper, props.requiredSpace, ContentBelow, ContentBelow);
48
+ return css(["position:fixed;top:24px;left:24px;right:24px;bottom:24px;z-index:", ";background:var(--ds-form-field-bg-default);border-radius:3px;box-shadow:var(--ds-shadows-shadow-2);", "{height:calc(100vh - 48px - ", "px);}", "{padding:0 24px;}", ":not(:empty){padding-bottom:16px;}"], props.zIndex !== void 0 ? props.zIndex : props.theme.variables["zindex-modal"], EditorInnerWrapper, props.requiredSpace, ContentBelow, ContentBelow);
49
49
  }
50
50
  return css(["", " display:flex;flex-direction:column;margin-bottom:12px;"], props.customHeight ? css(["", "{flex:1 1 100%;min-height:0;}height:", ";"], EditorInnerWrapper, typeof props.customHeight === "number" ? `${props.customHeight}px` : props.customHeight) : css(["", "{height:295px;}"], EditorInnerWrapper));
51
- }, EditorWrapper, (props) => props.readOnly && css(["background:", ";.monaco-editor .cursors-layer > .cursor{display:none !important;}"], props.theme.palette["grey-050"]));
51
+ }, EditorWrapper, (props) => props.readOnly && css(["background:var(--ds-form-field-bg-disabled);.monaco-editor .cursors-layer > .cursor{display:none !important;}"]));
52
52
  const AdditionalDescription = /* @__PURE__ */ styled.div.withConfig({
53
53
  displayName: "CodeAreastyles__AdditionalDescription",
54
54
  componentId: "sc-svoej2-11"
@@ -64,15 +64,10 @@ const SyntaxTitle = /* @__PURE__ */ styled(Text).withConfig({
64
64
  const BottomBar = /* @__PURE__ */ styled(FlexRow).withConfig({
65
65
  displayName: "CodeAreastyles__BottomBar",
66
66
  componentId: "sc-svoej2-14"
67
- })(["padding:8px;flex:0 0 auto;background:", ";border-top:solid 1px ", ";", ""], ({
68
- theme
69
- }) => theme.palette["white"], ({
70
- theme
71
- }) => theme.palette["grey-200"], ({
67
+ })(["padding:8px;flex:0 0 auto;background:var(--ds-form-field-bg-default);border-top:solid 1px var(--ds-form-field-border-default);", ""], ({
72
68
  hasError,
73
- noBorder,
74
- theme
75
- }) => hasError && css(["background:", ";", ""], theme.palette["red-050"], noBorder ? css(["border:none;border-top:solid 1px ", ";"], theme.palette["grey-200"]) : css(["border:solid 1px ", ";border-top-color:", ";"], theme.palette["red-600"], theme.palette["grey-200"])));
69
+ noBorder
70
+ }) => hasError && css(["background:var(--ds-form-field-bg-validated);", ""], noBorder ? css(["border:none;border-top:solid 1px var(--ds-form-field-border-default);"]) : css(["border:solid 1px var(--ds-form-field-border-validated);border-top-color:var(--ds-form-field-border-default);"])));
76
71
  const LeftSide = /* @__PURE__ */ styled.div.withConfig({
77
72
  displayName: "CodeAreastyles__LeftSide",
78
73
  componentId: "sc-svoej2-15"
@@ -100,7 +95,7 @@ const Counter = /* @__PURE__ */ styled.div.withConfig({
100
95
  const ErrorText = /* @__PURE__ */ styled.div.withConfig({
101
96
  displayName: "CodeAreastyles__ErrorText",
102
97
  componentId: "sc-svoej2-21"
103
- })(["color:", ";margin-bottom:4px;"], (props) => props.theme.palette["red-600"]);
98
+ })(["color:var(--ds-form-error-text-color);margin-bottom:4px;"]);
104
99
  export {
105
100
  AdditionalDescription,
106
101
  AriaContainer,
@@ -2,13 +2,13 @@ import { default as React } from 'react';
2
2
  export declare const CodeAreaEditor: React.ForwardRefExoticComponent<Omit<import('@monaco-editor/react').EditorProps, "height" | "language"> & {
3
3
  label?: React.ReactNode;
4
4
  description?: React.ReactNode;
5
- texts?: Partial<import('../CodeArea.types').CodeAreaTexts>;
5
+ texts?: Partial<import('..').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('..').CodeAreaSyntaxOption<string>[] | undefined;
12
12
  currentSyntax: string;
13
13
  allowFullscreen?: boolean;
14
14
  isFullscreen: boolean;
@@ -1,11 +1,12 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import Editor, { loader } from "@monaco-editor/react";
3
3
  import { useRef, useState, useMemo, useCallback, useEffect } from "react";
4
+ import { useTheme } from "@synerise/ds-core";
4
5
  import { InlineSelect } from "@synerise/ds-inline-edit";
5
6
  import Loader from "@synerise/ds-loader";
6
7
  import { useResizeObserver, NOOP } from "@synerise/ds-utils";
7
8
  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 { getDsMonacoTheme, MONACO_DEFAULT_OPTIONS, DS_MONACO_THEME_NAME, TRIGGER_SOURCE } from "../constants.js";
9
10
  import { getDefaultTexts } from "../utils/getDefaultTexts.js";
10
11
  import { AriaContainer } from "./AriaContainer.js";
11
12
  import { BottomBar } from "./BottomBar.js";
@@ -42,6 +43,12 @@ const CodeAreaEditorRaw = ({
42
43
  const editorRef = useRef(null);
43
44
  const wrapperRef = useRef(null);
44
45
  const [isTouched, setIsTouched] = useState(false);
46
+ const {
47
+ tokens
48
+ } = useTheme();
49
+ const monacoTheme = useMemo(() => getDsMonacoTheme(tokens), [tokens]);
50
+ const monacoThemeRef = useRef(monacoTheme);
51
+ monacoThemeRef.current = monacoTheme;
45
52
  const {
46
53
  height,
47
54
  width
@@ -68,7 +75,7 @@ const CodeAreaEditorRaw = ({
68
75
  const handleBeforeMount = useCallback((monacoInstance) => {
69
76
  monacoRef.current = monacoInstance;
70
77
  monacoInstance.editor.setTheme("vs");
71
- monacoInstance.editor.defineTheme(DS_MONACO_THEME_NAME, DS_MONACO_THEME);
78
+ monacoInstance.editor.defineTheme(DS_MONACO_THEME_NAME, monacoThemeRef.current);
72
79
  monacoInstance.editor.setTheme(DS_MONACO_THEME_NAME);
73
80
  monacoInstance.editor.onDidChangeMarkers(() => {
74
81
  const markers = monacoInstance.editor.getModelMarkers({});
@@ -132,6 +139,13 @@ const CodeAreaEditorRaw = ({
132
139
  isValid
133
140
  }) });
134
141
  }, [renderFooterContent, isFullscreen, count, isValid]);
142
+ useEffect(() => {
143
+ if (!monacoRef.current) {
144
+ return;
145
+ }
146
+ monacoRef.current.editor.defineTheme(DS_MONACO_THEME_NAME, monacoTheme);
147
+ monacoRef.current.editor.setTheme(DS_MONACO_THEME_NAME);
148
+ }, [monacoTheme]);
135
149
  useEffect(() => {
136
150
  if (editorRef.current) {
137
151
  const currentModel = editorRef.current?.getModel();
@@ -2,4 +2,10 @@ import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
2
2
  export declare const MONACO_DEFAULT_OPTIONS: editor.IStandaloneEditorConstructionOptions;
3
3
  export declare const TRIGGER_SOURCE = "ds-code-area";
4
4
  export declare const DS_MONACO_THEME_NAME = "DSTheme";
5
+ type TokenMap = {
6
+ [key: string]: string;
7
+ };
8
+ export declare const getDsMonacoTheme: (tokens: TokenMap) => editor.IStandaloneThemeData;
9
+ /** @deprecated Light mode only — use `getDsMonacoTheme(useTheme().tokens)`. */
5
10
  export declare const DS_MONACO_THEME: editor.IStandaloneThemeData;
11
+ export {};
package/dist/constants.js CHANGED
@@ -19,23 +19,35 @@ const MONACO_DEFAULT_OPTIONS = {
19
19
  const TRIGGER_SOURCE = "ds-code-area";
20
20
  const TRANSPARENT = "#00000000";
21
21
  const DS_MONACO_THEME_NAME = "DSTheme";
22
- const DS_MONACO_THEME = {
23
- base: "vs",
22
+ const getLuminance = (hex) => {
23
+ const [r, g, b] = [1, 3, 5].map((start) => parseInt(hex.slice(start, start + 2), 16) / 255);
24
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
25
+ };
26
+ const getDsMonacoTheme = (tokens) => ({
27
+ // The base supplies the syntax-highlighting rules, so it has to match the
28
+ // surface: 'vs' keywords and strings are unreadable on a dark field.
29
+ base: getLuminance(tokens["--ds-color-background-base-default"]) < 0.5 ? "vs-dark" : "vs",
24
30
  inherit: true,
25
31
  rules: [],
26
32
  colors: {
27
- "editor.foreground": theme.palette["grey-800"],
33
+ // Monaco theme colours must be hex — read resolved token values from the
34
+ // active mode's token map (not var(), which Monaco can't parse). TRANSPARENT
35
+ // stays a hex literal because --ds-color-transparent resolves to rgba(),
36
+ // which Monaco rejects.
37
+ "editor.foreground": tokens["--ds-color-text-base-default"],
28
38
  "editor.background": TRANSPARENT,
29
39
  "editorOverviewRuler.border": TRANSPARENT,
30
- "scrollbarSlider.background": theme.palette["grey-300"],
31
- "scrollbarSlider.hoverBackground": theme.palette["grey-500"],
32
- "scrollbarSlider.activeBackground": theme.palette["grey-500"],
33
- "editorLineNumber.foreground": theme.palette["grey-500"]
40
+ "scrollbarSlider.background": tokens["--ds-color-border-base-strong"],
41
+ "scrollbarSlider.hoverBackground": tokens["--ds-color-background-base-stronghover"],
42
+ "scrollbarSlider.activeBackground": tokens["--ds-color-background-base-stronghover"],
43
+ "editorLineNumber.foreground": tokens["--ds-color-text-neutral-default"]
34
44
  }
35
- };
45
+ });
46
+ const DS_MONACO_THEME = getDsMonacoTheme(theme.tokens);
36
47
  export {
37
48
  DS_MONACO_THEME,
38
49
  DS_MONACO_THEME_NAME,
39
50
  MONACO_DEFAULT_OPTIONS,
40
- TRIGGER_SOURCE
51
+ TRIGGER_SOURCE,
52
+ getDsMonacoTheme
41
53
  };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { default as default2 } from "./CodeArea.js";
2
2
  import { AdditionalDescription, AriaContainer, BottomBar, BottomBarElement, CodeAreaContent, CodeAreaWrapper, ContentAbove, ContentBelow, Counter, Description, EditorInnerWrapper, EditorPlaceholder, EditorWrapper, ErrorText, FullscreenHeader, FullscreenHeaderTitle, FullscreenMask, LeftSide, RightSide, SyntaxSelect, SyntaxTitle } from "./CodeArea.styles.js";
3
- import { DS_MONACO_THEME, DS_MONACO_THEME_NAME, MONACO_DEFAULT_OPTIONS, TRIGGER_SOURCE } from "./constants.js";
3
+ import { DS_MONACO_THEME, DS_MONACO_THEME_NAME, MONACO_DEFAULT_OPTIONS, TRIGGER_SOURCE, getDsMonacoTheme } from "./constants.js";
4
4
  export {
5
5
  AdditionalDescription,
6
6
  AriaContainer,
@@ -27,5 +27,6 @@ export {
27
27
  SyntaxSelect,
28
28
  SyntaxTitle,
29
29
  TRIGGER_SOURCE,
30
- default2 as default
30
+ default2 as default,
31
+ getDsMonacoTheme
31
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-code-area",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "CodeArea UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -43,14 +43,14 @@
43
43
  "types": "dist/index.d.ts",
44
44
  "dependencies": {
45
45
  "@monaco-editor/react": "4.4.6",
46
- "@synerise/ds-button": "^2.1.6",
47
- "@synerise/ds-form-field": "^2.0.11",
48
- "@synerise/ds-icon": "^2.2.3",
49
- "@synerise/ds-inline-edit": "^2.0.12",
50
- "@synerise/ds-loader": "^2.0.3",
51
- "@synerise/ds-tooltip": "^2.0.11",
52
- "@synerise/ds-typography": "^2.0.11",
53
- "@synerise/ds-utils": "^2.2.2"
46
+ "@synerise/ds-button": "^2.2.1",
47
+ "@synerise/ds-form-field": "^2.1.1",
48
+ "@synerise/ds-icon": "^2.3.1",
49
+ "@synerise/ds-inline-edit": "^2.1.1",
50
+ "@synerise/ds-loader": "^2.1.1",
51
+ "@synerise/ds-tooltip": "^2.1.1",
52
+ "@synerise/ds-typography": "^2.1.1",
53
+ "@synerise/ds-utils": "^2.3.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@synerise/ds-core": "*",
@@ -64,5 +64,5 @@
64
64
  "monaco-editor": "0.34.1",
65
65
  "vitest": "4"
66
66
  },
67
- "gitHead": "c356039703d8826bbbdb6dadcb18bb008fea8bc5"
67
+ "gitHead": "2d2a540b35fddf8855da45f0dec2f4612c6d87b6"
68
68
  }