@m4l/components 9.24.0-beta-feature-724-add-icons.0 → 9.24.0-beta-feature-731-m4l-components-code-editor.7

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.
Files changed (45) hide show
  1. package/@types/types.d.ts +11 -0
  2. package/components/extended/ReactSimpleCodeEditor/CodeEditor.d.ts +6 -0
  3. package/components/extended/ReactSimpleCodeEditor/CodeEditor.d.ts.map +1 -0
  4. package/components/extended/ReactSimpleCodeEditor/CodeEditor.js +263 -0
  5. package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.d.ts +3 -0
  6. package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.d.ts.map +1 -0
  7. package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.js +311 -0
  8. package/components/extended/ReactSimpleCodeEditor/constants.d.ts +82 -0
  9. package/components/extended/ReactSimpleCodeEditor/constants.d.ts.map +1 -0
  10. package/components/extended/ReactSimpleCodeEditor/constants.js +148 -0
  11. package/components/extended/ReactSimpleCodeEditor/dictionary.d.ts +11 -0
  12. package/components/extended/ReactSimpleCodeEditor/dictionary.d.ts.map +1 -0
  13. package/components/extended/ReactSimpleCodeEditor/dictionary.js +7 -0
  14. package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.d.ts +58 -0
  15. package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.d.ts.map +1 -0
  16. package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.js +1063 -0
  17. package/components/extended/ReactSimpleCodeEditor/helpers/languageIcon.d.ts +6 -0
  18. package/components/extended/ReactSimpleCodeEditor/helpers/languageIcon.d.ts.map +1 -0
  19. package/components/extended/ReactSimpleCodeEditor/helpers/languageIcon.js +7 -0
  20. package/components/extended/ReactSimpleCodeEditor/helpers/resolveEditorComponent.d.ts +6 -0
  21. package/components/extended/ReactSimpleCodeEditor/helpers/resolveEditorComponent.d.ts.map +1 -0
  22. package/components/extended/ReactSimpleCodeEditor/helpers/resolveEditorComponent.js +9 -0
  23. package/components/extended/ReactSimpleCodeEditor/index.d.ts +4 -0
  24. package/components/extended/ReactSimpleCodeEditor/index.d.ts.map +1 -0
  25. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.d.ts +18 -0
  26. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.d.ts.map +1 -0
  27. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.js +4 -0
  28. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.d.ts +84 -0
  29. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.d.ts.map +1 -0
  30. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.js +64 -0
  31. package/components/extended/ReactSimpleCodeEditor/slots/index.d.ts +3 -0
  32. package/components/extended/ReactSimpleCodeEditor/slots/index.d.ts.map +1 -0
  33. package/components/extended/ReactSimpleCodeEditor/types.d.ts +446 -0
  34. package/components/extended/ReactSimpleCodeEditor/types.d.ts.map +1 -0
  35. package/components/extended/index.d.ts +1 -0
  36. package/components/extended/index.d.ts.map +1 -1
  37. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.d.ts +7 -0
  38. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.d.ts.map +1 -0
  39. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.js +6 -0
  40. package/components/hook-form/RHFCodeEditor/index.d.ts +3 -0
  41. package/components/hook-form/RHFCodeEditor/index.d.ts.map +1 -0
  42. package/components/hook-form/index.d.ts +1 -0
  43. package/components/hook-form/index.d.ts.map +1 -1
  44. package/index.js +572 -559
  45. package/package.json +9 -6
package/@types/types.d.ts CHANGED
@@ -373,6 +373,10 @@ import {
373
373
  ReactJsonViewerOwnerState,
374
374
  ReactJsonViewerSlotsType,
375
375
  } from '../components/extended/React-Json-Viewer/types';
376
+ import {
377
+ CodeEditorOwnerState,
378
+ CodeEditorSlotsType,
379
+ } from '../components/extended/ReactSimpleCodeEditor/types';
376
380
  import {
377
381
  ResizableOwnerState as ReactResizableOwnerState,
378
382
  ResizableSlotsType,
@@ -499,6 +503,7 @@ declare module '@mui/material/styles' {
499
503
  M4LFixedSizeList: FixedSizeListSlotsType;
500
504
  M4LVariableSizeList: VariableSizeListSlotsType;
501
505
  M4LReactJsonViewer: ReactJsonViewerSlotsType;
506
+ M4LCodeEditor: CodeEditorSlotsType;
502
507
  M4LResizable: ResizableSlotsType;
503
508
  M4LResizableBox: ResizableBoxSlotsType;
504
509
  M4LImageSelector: ImageSelectorSlotsType;
@@ -614,6 +619,7 @@ declare module '@mui/material/styles' {
614
619
  M4LFixedSizeList: Partial<FixedSizeListOwnerState>;
615
620
  M4LVariableSizeList: Partial<VariableSizeListOwnerState>;
616
621
  M4LReactJsonViewer: Partial<ReactJsonViewerOwnerState>;
622
+ M4LCodeEditor: Partial<CodeEditorOwnerState>;
617
623
  M4LResizable: Partial<ReactResizableOwnerState>;
618
624
  M4LResizableBox: Partial<ResizableBoxOwnerState>;
619
625
  M4LImageSelector: Partial<ImageSelectorOwnerState>;
@@ -1168,6 +1174,11 @@ declare module '@mui/material/styles' {
1168
1174
  styleOverrides?: ComponentsOverrides<Theme>['M4LReactJsonViewer'];
1169
1175
  variants?: ComponentsVariants['M4LReactJsonViewer'];
1170
1176
  };
1177
+ M4LCodeEditor?: {
1178
+ defaultProps?: ComponentsPropsList['M4LCodeEditor'];
1179
+ styleOverrides?: ComponentsOverrides<Theme>['M4LCodeEditor'];
1180
+ variants?: ComponentsVariants['M4LCodeEditor'];
1181
+ };
1171
1182
  M4LResizable?: {
1172
1183
  defaultProps?: ComponentsPropsList['M4LResizable'];
1173
1184
  styleOverrides?: ComponentsOverrides<Theme>['M4LResizable'];
@@ -0,0 +1,6 @@
1
+ import { CodeEditorProps } from './types';
2
+ /**
3
+ * Render a syntax-highlighted code editor with optional self-managed fallback state.
4
+ */
5
+ export declare function CodeEditor(props: CodeEditorProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=CodeEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/extended/ReactSimpleCodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,SAAS,CAAC;AAgBjB;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,oDAuXhD"}
@@ -0,0 +1,263 @@
1
+ import { jsx as a, jsxs as D } from "@emotion/react/jsx-runtime";
2
+ import { useModuleDictionary as Ae, useModuleSkeleton as Me } from "@m4l/core";
3
+ import { useThemeMode as Ve } from "@m4l/graphics";
4
+ import _ from "clsx";
5
+ import { useId as Pe, useState as J, useRef as ke, useMemo as E, useEffect as Q, useCallback as z } from "react";
6
+ import { getPropDataTestId as x, getNameDataTestId as ze } from "../../../test/getNameDataTestId.js";
7
+ import { CODE_EDITOR_DEFAULT_MAX_LINES as Be, CODE_EDITOR_DEFAULT_MIN_LINES as He, CODE_EDITOR_DEFAULT_LANGUAGE as we, CODE_EDITOR_LINE_HEIGHT_BY_SIZE as Ge, CODE_EDITOR_CLASSES as C, CODE_EDITOR_KEY_COMPONENT as p, CODE_EDITOR_READ_ONLY_LABEL as Ue, CODE_EDITOR_LANGUAGE_CHIP_ICON_INSTANCE_ID as Ye } from "./constants.js";
8
+ import { CODE_EDITOR_DICTIONARY as W } from "./dictionary.js";
9
+ import { resolveCodeEditorLanguageIcon as Fe } from "./helpers/languageIcon.js";
10
+ import { ensureCodeEditorRuntimeDependencies as je, getCodeEditorLineCount as qe, createCodeEditorPrismTheme as Ke, resolveCodeEditorLanguageTemplate as Xe, validateCodeEditorSyntax as Ze, highlightCode as $e } from "./helpers/highlighting.js";
11
+ import { SkeletonStyled as Je, RootStyled as Qe, HeaderStyled as We, LanguageChipStyled as et, LanguageChipIconStyled as tt, HeaderBadgesStyled as at, ReadOnlyChipStyled as nt, BodyStyled as rt, LineNumbersStyled as ot, LineNumberStyled as lt, EditorScrollerStyled as it, PlaceholderStyled as st, EditorStyled as dt } from "./slots/CodeEditorSlots.js";
12
+ import { CodeEditorSlots as f } from "./slots/CodeEditorEnum.js";
13
+ function ct(L, y) {
14
+ return L.length !== y.length ? !1 : L.every((S, o) => S === y[o]);
15
+ }
16
+ function Dt(L) {
17
+ const {
18
+ className: y,
19
+ customLanguages: S,
20
+ dataTestId: o,
21
+ defaultValue: ee,
22
+ disabled: I = !1,
23
+ editorClassName: te,
24
+ error: ae = !1,
25
+ highlightTheme: B,
26
+ id: ne,
27
+ insertSpaces: re,
28
+ languageIcon: oe,
29
+ languageLabel: le,
30
+ languageTemplate: n,
31
+ languageText: ie,
32
+ maxLines: se = Be,
33
+ minLines: O = He,
34
+ onBlur: de,
35
+ onChange: v,
36
+ placeholder: R,
37
+ preClassName: ce,
38
+ readOnly: d = !1,
39
+ readOnlyLabel: ue,
40
+ runtimeDependencies: c,
41
+ showLineNumbers: H = !1,
42
+ showPlaceholder: w = !0,
43
+ size: G = "medium",
44
+ syntaxValidator: N,
45
+ skeleton: me = !1,
46
+ textareaClassName: ge,
47
+ validateSyntax: U = !1,
48
+ value: u,
49
+ variant: he = "outlined",
50
+ ...T
51
+ } = L, Ee = Pe(), Ce = ne || Ee, { getLabel: pe } = Ae(), fe = Me() || me, b = Ve(), m = v === void 0, [A, Le] = J(0), M = ke([]), [ye, Y] = J(
52
+ u ?? ee ?? ""
53
+ ), F = E(() => c ? Array.isArray(c) ? c : [c] : [], [c]);
54
+ ct(
55
+ M.current,
56
+ F
57
+ ) || (M.current = F);
58
+ const V = M.current;
59
+ Q(() => {
60
+ m && u !== void 0 && Y(u);
61
+ }, [m, u]), Q(() => {
62
+ if (!V.length)
63
+ return;
64
+ let e = !0;
65
+ return je(V).catch(() => {
66
+ }).then(() => {
67
+ e && Le((s) => s + 1);
68
+ }), () => {
69
+ e = !1;
70
+ };
71
+ }, [V]);
72
+ const r = m ? ye : u ?? "", Se = w && r.length === 0 && !!R, Ie = Ge[G], j = qe(r), q = Math.max(j, O), P = Math.max(O, se), Te = Math.min(q, P), De = j >= P, K = E(
73
+ () => B ?? Ke(b),
74
+ [b, B]
75
+ ), l = E(
76
+ () => Xe(n),
77
+ [n, A]
78
+ ), g = ie ?? l?.languageText ?? we, X = le ?? l?.languageLabel, Z = !!X, _e = Fe(
79
+ oe ?? l?.languageIcon
80
+ ), k = d ? pe(W.readOnly) : void 0, xe = ue ?? (k && k !== W.readOnly ? k : Ue), h = E(() => {
81
+ if (N)
82
+ return N({
83
+ code: r,
84
+ languageTemplate: l ?? n,
85
+ languageText: g
86
+ });
87
+ if (U)
88
+ return Ze({
89
+ code: r,
90
+ languageTemplate: l ?? n,
91
+ languageText: g
92
+ });
93
+ }, [
94
+ n,
95
+ l,
96
+ g,
97
+ r,
98
+ A,
99
+ N,
100
+ U
101
+ ]), $ = ae || !!h && !h.isValid, i = h && !h.isValid ? h.errorRange : void 0, Oe = E(() => {
102
+ if (!i)
103
+ return /* @__PURE__ */ new Set();
104
+ const e = i.start.line, s = i.end?.line ?? e;
105
+ return new Set(
106
+ Array.from(
107
+ { length: Math.max(s - e + 1, 1) },
108
+ (ut, be) => e + be
109
+ )
110
+ );
111
+ }, [i]), t = {
112
+ colorMode: b,
113
+ disabled: I,
114
+ error: $,
115
+ isLineCapped: De,
116
+ isEmpty: r.length === 0,
117
+ isPlaceholderVisible: Se,
118
+ lineHeight: Ie,
119
+ maxLines: P,
120
+ minLines: O,
121
+ readOnly: d,
122
+ showLineNumbers: H,
123
+ size: G,
124
+ variant: he,
125
+ visibleLineCount: Te
126
+ }, ve = z(
127
+ (e) => $e({
128
+ code: e,
129
+ customLanguages: S,
130
+ languageTemplate: n,
131
+ languageText: g,
132
+ prismTheme: K,
133
+ syntaxErrorRange: i
134
+ }),
135
+ [
136
+ S,
137
+ n,
138
+ K,
139
+ g,
140
+ A,
141
+ i
142
+ ]
143
+ ), Re = z(
144
+ (e) => {
145
+ m && Y(e), v?.(e);
146
+ },
147
+ [v, m]
148
+ ), Ne = z(
149
+ (e) => {
150
+ if (I || e.target instanceof Element && e.target.closest("textarea"))
151
+ return;
152
+ e.currentTarget.querySelector("textarea")?.focus();
153
+ },
154
+ [I]
155
+ );
156
+ return fe ? /* @__PURE__ */ a(Je, { ownerState: t }) : /* @__PURE__ */ D(
157
+ Qe,
158
+ {
159
+ ownerState: t,
160
+ "aria-disabled": t.disabled || void 0,
161
+ className: _(C.root, y),
162
+ ...x(p, f.root, o),
163
+ children: [
164
+ Z || d ? /* @__PURE__ */ D(We, { ownerState: t, className: C.header, children: [
165
+ Z ? /* @__PURE__ */ a(
166
+ et,
167
+ {
168
+ label: X,
169
+ size: "small",
170
+ variant: "outlined",
171
+ color: "default",
172
+ startIcon: /* @__PURE__ */ a(
173
+ tt,
174
+ {
175
+ ...x(
176
+ p,
177
+ f.languageChipIcon,
178
+ Ye
179
+ ),
180
+ children: /* @__PURE__ */ a(_e, { fontSize: "small" })
181
+ }
182
+ )
183
+ }
184
+ ) : null,
185
+ /* @__PURE__ */ a(at, { ownerState: t, children: d ? /* @__PURE__ */ a(
186
+ nt,
187
+ {
188
+ label: xe,
189
+ size: "small"
190
+ }
191
+ ) : null })
192
+ ] }) : null,
193
+ /* @__PURE__ */ D(
194
+ rt,
195
+ {
196
+ ownerState: t,
197
+ onClick: Ne,
198
+ ...x(p, f.body, o),
199
+ children: [
200
+ H ? /* @__PURE__ */ a(ot, { ownerState: t, "aria-hidden": "true", children: Array.from({ length: q }, (e, s) => s + 1).map(
201
+ (e) => /* @__PURE__ */ a(
202
+ lt,
203
+ {
204
+ ownerState: t,
205
+ "data-code-editor-error-line": Oe.has(e) || void 0,
206
+ children: e
207
+ },
208
+ `code-editor-line-${e}`
209
+ )
210
+ ) }) : null,
211
+ /* @__PURE__ */ D(it, { ownerState: t, children: [
212
+ w && t.isEmpty && R ? /* @__PURE__ */ a(
213
+ st,
214
+ {
215
+ ownerState: t,
216
+ ...x(
217
+ p,
218
+ f.placeholder,
219
+ o
220
+ ),
221
+ children: R
222
+ }
223
+ ) : null,
224
+ /* @__PURE__ */ a(
225
+ dt,
226
+ {
227
+ ...T,
228
+ ownerState: t,
229
+ "aria-label": T["aria-label"] ?? "Code editor",
230
+ "aria-invalid": T["aria-invalid"] ?? ($ || void 0),
231
+ className: _(C.editor, te),
232
+ "data-testid": ze(
233
+ p,
234
+ f.textarea,
235
+ o
236
+ ),
237
+ disabled: I,
238
+ highlight: ve,
239
+ insertSpaces: re,
240
+ onBlur: de,
241
+ onValueChange: Re,
242
+ preClassName: _(C.pre, ce),
243
+ readOnly: d,
244
+ tabSize: T.tabSize,
245
+ textareaClassName: _(
246
+ C.textarea,
247
+ ge
248
+ ),
249
+ textareaId: Ce,
250
+ value: r
251
+ }
252
+ )
253
+ ] })
254
+ ]
255
+ }
256
+ )
257
+ ]
258
+ }
259
+ );
260
+ }
261
+ export {
262
+ Dt as CodeEditor
263
+ };
@@ -0,0 +1,3 @@
1
+ import { CodeEditorStyles } from './types';
2
+ export declare const codeEditorStyles: CodeEditorStyles;
3
+ //# sourceMappingURL=CodeEditor.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditor.styles.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,eAAO,MAAM,gBAAgB,EAAE,gBAyV9B,CAAC"}
@@ -0,0 +1,311 @@
1
+ import { getTypographyStyles as d } from "../../../utils/getTypographyStyles.js";
2
+ import { getCodeEditorVSCodeModernPalette as l, CODE_EDITOR_LINE_HEIGHT_BY_SIZE as n, CODE_EDITOR_MONO_FONT_FAMILY as s, CODE_EDITOR_PADDING_PX as i } from "./constants.js";
3
+ import { getSizeStyles as p } from "../../../utils/getSizeStyles/getSizeStyles.js";
4
+ const b = {
5
+ /** Resolve the interactive shell colors and focus treatment for the editor root. */
6
+ root: ({ theme: e, ownerState: r }) => {
7
+ const o = !r?.disabled && !r?.readOnly, a = r?.disabled ? e.vars.palette.border.disabled : e.vars.palette.border.secondary;
8
+ return {
9
+ width: "100%",
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ minHeight: 0,
13
+ gap: 0,
14
+ border: e.vars.size.borderStroke.container,
15
+ borderColor: r?.variant === "outlined" || r?.error ? a : "transparent",
16
+ borderRadius: e.vars.size.borderRadius["r1-5"],
17
+ ...r?.error && {
18
+ borderColor: e.vars.palette.error.focus
19
+ },
20
+ ...r?.variant === "contained" && {
21
+ backgroundColor: e.vars.palette.default.enabledOpacity
22
+ },
23
+ ...r?.variant === "outlined" && {
24
+ backgroundColor: e.vars.palette.background.default
25
+ },
26
+ ...r?.readOnly && {
27
+ backgroundColor: `${e.vars.palette.default.enabledOpacity}!important`
28
+ },
29
+ overflow: "hidden",
30
+ opacity: r?.disabled ? 0.72 : 1,
31
+ outline: "3px solid",
32
+ outlineColor: "transparent",
33
+ transition: "border-color 120ms ease, outline 120ms ease, opacity 120ms ease, background-color 120ms ease",
34
+ ...o && {
35
+ "&:hover": {
36
+ backgroundColor: e.vars.palette.default.hoverOpacity,
37
+ ...r?.error && {
38
+ borderColor: e.vars.palette.error.active
39
+ }
40
+ },
41
+ "&:focus-within": {
42
+ borderColor: e.vars.palette.primary.enabled,
43
+ outline: "3px solid",
44
+ outlineColor: r?.error ? e.vars.palette.error.focusOpacity : e.vars.palette.primary.hoverOpacity,
45
+ ...r?.error && {
46
+ borderColor: e.vars.palette.error.enabled
47
+ },
48
+ ...r?.variant === "contained" && {
49
+ backgroundColor: e.vars.palette.background.default,
50
+ "&&& .M4LCodeEditor-header": {
51
+ backgroundColor: e.vars.palette.default.enabledOpacity
52
+ }
53
+ }
54
+ }
55
+ }
56
+ };
57
+ },
58
+ /** Layout the language badge row above the editing surface. */
59
+ header: ({ theme: e, ownerState: r }) => {
60
+ const o = l(
61
+ r?.colorMode
62
+ );
63
+ return {
64
+ display: "flex",
65
+ alignItems: "center",
66
+ justifyContent: "space-between",
67
+ padding: e.vars.size.baseSpacings.sp2,
68
+ gap: e.vars.size.baseSpacings.sp2,
69
+ borderBottom: e.vars.size.borderStroke.container,
70
+ borderColor: e.vars.palette.border.secondary,
71
+ ...r?.variant === "contained" && {
72
+ backgroundColor: "transparent"
73
+ },
74
+ ...r?.variant === "outlined" && {
75
+ backgroundColor: e.vars.palette.background.default
76
+ },
77
+ ...r?.readOnly && {
78
+ backgroundColor: `${e.vars.palette.background.default}!important`
79
+ },
80
+ color: o.surface.headerForeground,
81
+ borderTopLeftRadius: e.vars.size.borderRadius.r2,
82
+ borderTopRightRadius: e.vars.size.borderRadius.r2,
83
+ overflow: "hidden",
84
+ minHeight: "33px"
85
+ };
86
+ },
87
+ /** Align any trailing badges rendered in the header row. */
88
+ headerBadges: ({ theme: e }) => ({
89
+ display: "flex",
90
+ alignItems: "center",
91
+ justifyContent: "flex-end",
92
+ gap: e.vars.size.baseSpacings.sp1,
93
+ minWidth: 0,
94
+ // Keep badges right-aligned even when the language chip is absent and the
95
+ // badges container is the only child of the header row.
96
+ marginLeft: "auto"
97
+ }),
98
+ /** Keep the leading language chip aligned with the editor header layout. */
99
+ languageChip: ({ theme: e, ownerState: r }) => {
100
+ const o = l(
101
+ r?.colorMode
102
+ );
103
+ return {
104
+ flexShrink: 0,
105
+ minWidth: 0,
106
+ whiteSpace: "nowrap",
107
+ textTransform: "lowercase",
108
+ paddingTop: 0,
109
+ paddingBottom: 0,
110
+ backgroundColor: "transparent",
111
+ borderColor: e.vars.palette.chips.default.outlined.backgroundActive,
112
+ color: o.surface.languageChipForeground,
113
+ ...p(
114
+ e,
115
+ r?.size || "medium",
116
+ "base",
117
+ (a) => ({ height: a })
118
+ ),
119
+ "&&& .M4LTypography-root": {
120
+ ...d(e.generalSettings.isMobile, r?.size || "medium", "microSlim"),
121
+ color: o.surface.languageChipForeground,
122
+ lineHeight: "normal",
123
+ textTransform: "uppercase"
124
+ }
125
+ };
126
+ },
127
+ /** Keep the language icon aligned while preserving any intrinsic Seti fill colors. */
128
+ languageChipIcon: () => ({
129
+ display: "inline-flex",
130
+ flexShrink: 0,
131
+ width: "16px",
132
+ height: "16px",
133
+ lineHeight: 0,
134
+ "& .MuiSvgIcon-root": {
135
+ display: "block",
136
+ width: "16px",
137
+ height: "16px",
138
+ fontSize: "16px"
139
+ }
140
+ }),
141
+ /** Keep the read-only chip aligned with the trailing header actions. */
142
+ readOnlyChip: ({ theme: e, ownerState: r }) => ({
143
+ "&&&": {
144
+ flexShrink: 0,
145
+ minWidth: 0,
146
+ whiteSpace: "nowrap",
147
+ ...p(
148
+ e,
149
+ r?.size || "medium",
150
+ "base",
151
+ (o) => ({ height: o })
152
+ ),
153
+ "&&& .M4LTypography-root": {
154
+ ...d(e.generalSettings.isMobile, r?.size || "medium", "microSlim"),
155
+ color: e.vars.palette.chips.info.contained.color
156
+ },
157
+ backgroundColor: e.vars.palette.chips.info.contained.backgroundColor,
158
+ borderColor: "transparent"
159
+ }
160
+ }),
161
+ /** Build the two-column layout used by the gutter and editor scroller. */
162
+ body: ({ theme: e, ownerState: r }) => {
163
+ const o = r?.visibleLineCount || r?.minLines || 1, a = r?.lineHeight || n.medium, t = r?.isLineCapped ? i : i * 2;
164
+ return {
165
+ display: "grid",
166
+ gridTemplateColumns: r?.showLineNumbers ? "auto minmax(0, 1fr)" : "minmax(0, 1fr)",
167
+ width: "100%",
168
+ alignItems: "start",
169
+ columnGap: 0,
170
+ maxHeight: `${o * a + t}px`,
171
+ minHeight: 0,
172
+ overflow: "auto",
173
+ pointerEvents: r?.disabled ? "none" : "auto",
174
+ userSelect: r?.disabled ? "none" : "auto",
175
+ gap: e.vars.size.baseSpacings.sp2
176
+ };
177
+ },
178
+ /** Style the optional line-number gutter. */
179
+ lineNumbers: ({ theme: e, ownerState: r }) => {
180
+ const o = l(
181
+ r?.colorMode
182
+ );
183
+ return {
184
+ display: "flex",
185
+ flexDirection: "column",
186
+ alignItems: "flex-end",
187
+ padding: `${i}px ${e.vars.size.baseSpacings.sp1} ${r?.isLineCapped ? 0 : i}px ${e.vars.size.baseSpacings.sp2}`,
188
+ backgroundColor: "transparent",
189
+ color: r?.disabled ? o.surface.placeholderForeground : o.surface.lineNumberForeground,
190
+ userSelect: "none",
191
+ ...d(e.generalSettings.isMobile, r?.size || "medium", "bodyStandard"),
192
+ fontFamily: s,
193
+ lineHeight: `${n[r?.size || "medium"]}px`
194
+ };
195
+ },
196
+ /** Keep each rendered line number aligned with the code line height. */
197
+ lineNumber: ({ theme: e, ownerState: r }) => {
198
+ const o = l(
199
+ r?.colorMode
200
+ );
201
+ return {
202
+ display: "block",
203
+ minWidth: "2ch",
204
+ height: `${r?.lineHeight || n.medium}px`,
205
+ lineHeight: `${r?.lineHeight || n.medium}px`,
206
+ textAlign: "right",
207
+ '&[data-code-editor-error-line="true"]': {
208
+ color: o.surface.errorBorderColor,
209
+ borderLeft: `1px solid ${o.surface.errorBorderColor}`
210
+ }
211
+ };
212
+ },
213
+ /** Provide horizontal overflow for long code lines without wrapping them. */
214
+ editorScroller: ({ theme: e }) => ({
215
+ position: "relative",
216
+ width: "fit-content",
217
+ minWidth: "100%",
218
+ paddingTop: e.vars.size.baseSpacings.sp3,
219
+ paddingBottom: e.vars.size.baseSpacings.sp3,
220
+ paddingRight: e.vars.size.baseSpacings.sp2,
221
+ paddingLeft: e.vars.size.baseSpacings.sp2,
222
+ backgroundColor: "transparent"
223
+ }),
224
+ /** Style the underlying react-simple-code-editor surface and its inner elements. */
225
+ editor: ({ theme: e, ownerState: r }) => {
226
+ const o = l(
227
+ r?.colorMode
228
+ ), a = r?.isLineCapped ? 0 : i, t = i + a;
229
+ return {
230
+ position: "relative",
231
+ zIndex: 0,
232
+ width: "max-content",
233
+ minWidth: "100%",
234
+ minHeight: `calc(${r?.minLines || 1} * ${r?.lineHeight || n.medium}px + ${t}px)`,
235
+ backgroundColor: "transparent",
236
+ fontFamily: s,
237
+ fontSize: "11px",
238
+ lineHeight: `${r?.lineHeight || n.medium}px`,
239
+ fontWeight: 400,
240
+ "& textarea, & pre": {
241
+ ...d(e.generalSettings.isMobile, r?.size || "medium", "bodyStandard"),
242
+ fontFamily: s,
243
+ lineHeight: `${r?.lineHeight || n.medium}px`,
244
+ whiteSpace: "pre !important",
245
+ wordBreak: "normal",
246
+ overflowWrap: "normal",
247
+ margin: 0,
248
+ paddingTop: `${i}px`,
249
+ paddingRight: `${i}px`,
250
+ paddingBottom: `${a}px`,
251
+ paddingLeft: `${i}px`,
252
+ tabSize: 2,
253
+ fontVariantLigatures: "none",
254
+ backgroundColor: "transparent"
255
+ },
256
+ "&&& textarea": {
257
+ ...d(e.generalSettings.isMobile, r?.size || "medium", "microSlim"),
258
+ outline: "none",
259
+ backgroundColor: "transparent",
260
+ caretColor: r?.disabled ? "transparent" : o.surface.caretForeground,
261
+ cursor: r?.disabled ? "not-allowed" : r?.readOnly ? "default" : "text",
262
+ "&::selection": {
263
+ backgroundColor: o.surface.selectionBackground
264
+ }
265
+ },
266
+ "& pre": {
267
+ color: r?.disabled ? o.surface.placeholderForeground : o.surface.editorForeground
268
+ },
269
+ "& .token-line": {
270
+ display: "block",
271
+ width: "100%"
272
+ },
273
+ '& .token-line[data-code-editor-error-line="true"]': {
274
+ backgroundColor: o.surface.errorLineBackground
275
+ },
276
+ '& [data-code-editor-error-token="true"]': {
277
+ backgroundColor: o.surface.errorRangeBackground,
278
+ boxShadow: `inset 0 -1px 0 ${o.surface.errorRangeShadowColor}`
279
+ }
280
+ };
281
+ },
282
+ /** Position the empty-state placeholder above the editor surface. */
283
+ placeholder: ({ theme: e, ownerState: r }) => {
284
+ const o = l(
285
+ r?.colorMode
286
+ );
287
+ return {
288
+ position: "absolute",
289
+ zIndex: 1,
290
+ top: `${i}px`,
291
+ left: `${i}px`,
292
+ pointerEvents: "none",
293
+ color: o.surface.placeholderForeground,
294
+ ...d(e.generalSettings.isMobile, r?.size || "medium", "bodyStandard"),
295
+ fontFamily: s,
296
+ lineHeight: `${r?.lineHeight || n.medium}px`,
297
+ whiteSpace: "pre-wrap"
298
+ };
299
+ },
300
+ /** Size the skeleton block to the same footprint as the live editor. */
301
+ skeleton: ({ theme: e }) => ({
302
+ "&&&": {
303
+ borderRadius: e.vars.size.borderRadius.r1,
304
+ width: "100%",
305
+ height: "100px"
306
+ }
307
+ })
308
+ };
309
+ export {
310
+ b as codeEditorStyles
311
+ };