@m4l/components 9.17.0 → 9.17.1-beta-feature-731-m4l-components-code-editor.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.
Files changed (44) 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 +247 -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 +297 -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 +149 -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 +59 -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/index.d.ts +4 -0
  21. package/components/extended/ReactSimpleCodeEditor/index.d.ts.map +1 -0
  22. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.d.ts +18 -0
  23. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.d.ts.map +1 -0
  24. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorEnum.js +4 -0
  25. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.d.ts +84 -0
  26. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.d.ts.map +1 -0
  27. package/components/extended/ReactSimpleCodeEditor/slots/CodeEditorSlots.js +63 -0
  28. package/components/extended/ReactSimpleCodeEditor/slots/index.d.ts +3 -0
  29. package/components/extended/ReactSimpleCodeEditor/slots/index.d.ts.map +1 -0
  30. package/components/extended/ReactSimpleCodeEditor/storybookRuntime.d.ts +15 -0
  31. package/components/extended/ReactSimpleCodeEditor/storybookRuntime.d.ts.map +1 -0
  32. package/components/extended/ReactSimpleCodeEditor/types.d.ts +127 -0
  33. package/components/extended/ReactSimpleCodeEditor/types.d.ts.map +1 -0
  34. package/components/extended/index.d.ts +1 -0
  35. package/components/extended/index.d.ts.map +1 -1
  36. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.d.ts +7 -0
  37. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.d.ts.map +1 -0
  38. package/components/hook-form/RHFCodeEditor/RHFCodeEditor.js +6 -0
  39. package/components/hook-form/RHFCodeEditor/index.d.ts +3 -0
  40. package/components/hook-form/RHFCodeEditor/index.d.ts.map +1 -0
  41. package/components/hook-form/index.d.ts +1 -0
  42. package/components/hook-form/index.d.ts.map +1 -1
  43. package/index.js +561 -548
  44. package/package.json +12 -9
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,oDA8VhD"}
@@ -0,0 +1,247 @@
1
+ import { jsx as a, jsxs as S } from "@emotion/react/jsx-runtime";
2
+ import { useModuleDictionary as be, useModuleSkeleton as Ae } from "@m4l/core";
3
+ import y from "clsx";
4
+ import { useId as Me, useState as $, useRef as Ve, useMemo as E, useEffect as J, useCallback as Q } from "react";
5
+ import { useTheme as Pe } from "@mui/material/styles";
6
+ import { getPropDataTestId as V, getNameDataTestId as ze } from "../../../test/getNameDataTestId.js";
7
+ import { CODE_EDITOR_DEFAULT_MAX_LINES as He, CODE_EDITOR_DEFAULT_MIN_LINES as ke, CODE_EDITOR_DEFAULT_LANGUAGE as we, CODE_EDITOR_LINE_HEIGHT_BY_SIZE as Be, CODE_EDITOR_CLASSES as p, CODE_EDITOR_KEY_COMPONENT as D, CODE_EDITOR_READ_ONLY_LABEL as Ge, CODE_EDITOR_LANGUAGE_CHIP_ICON_INSTANCE_ID as Ue } from "./constants.js";
8
+ import { CODE_EDITOR_DICTIONARY as W } from "./dictionary.js";
9
+ import { resolveCodeEditorLanguageIcon as Ye } from "./helpers/languageIcon.js";
10
+ import { ensureCodeEditorRuntimeDependencies as Fe, getCodeEditorLineCount as je, createCodeEditorPrismTheme as qe, resolveCodeEditorLanguageTemplate as Ke, validateCodeEditorSyntax as Xe, highlightCode as Ze } from "./helpers/highlighting.js";
11
+ import { SkeletonStyled as $e, RootStyled as Je, HeaderStyled as Qe, LanguageChipStyled as We, LanguageChipIconStyled as et, HeaderBadgesStyled as tt, ReadOnlyChipStyled as at, BodyStyled as nt, LineNumbersStyled as rt, LineNumberStyled as lt, EditorScrollerStyled as ot, PlaceholderStyled as it, EditorStyled as st } from "./slots/CodeEditorSlots.js";
12
+ import { CodeEditorSlots as T } from "./slots/CodeEditorEnum.js";
13
+ function dt(C, L) {
14
+ return C.length !== L.length ? !1 : C.every((f, i) => f === L[i]);
15
+ }
16
+ function Dt(C) {
17
+ const {
18
+ className: L,
19
+ customLanguages: f,
20
+ dataTestId: i,
21
+ defaultValue: ee,
22
+ disabled: P = !1,
23
+ editorClassName: te,
24
+ error: ae = !1,
25
+ highlightTheme: z,
26
+ id: ne,
27
+ insertSpaces: re,
28
+ languageIcon: le,
29
+ languageLabel: oe,
30
+ languageTemplate: n,
31
+ languageText: ie,
32
+ maxLines: se = He,
33
+ minLines: _ = ke,
34
+ onBlur: de,
35
+ onChange: O,
36
+ placeholder: v,
37
+ preClassName: ue,
38
+ readOnly: s = !1,
39
+ readOnlyLabel: ce,
40
+ runtimeDependencies: d,
41
+ showLineNumbers: H = !1,
42
+ showPlaceholder: k = !0,
43
+ size: w = "medium",
44
+ syntaxValidator: x,
45
+ skeleton: me = !1,
46
+ textareaClassName: ge,
47
+ validateSyntax: B = !1,
48
+ value: u,
49
+ variant: he = "outlined",
50
+ ...I
51
+ } = C, Ee = Me(), pe = ne || Ee, G = Pe(), { getLabel: Ce } = be(), Le = Ae() || me, c = O === void 0, [R, fe] = $(0), N = Ve([]), [Ie, U] = $(
52
+ u ?? ee ?? ""
53
+ ), Y = E(() => d ? Array.isArray(d) ? d : [d] : [], [d]);
54
+ dt(
55
+ N.current,
56
+ Y
57
+ ) || (N.current = Y);
58
+ const b = N.current;
59
+ J(() => {
60
+ c && u !== void 0 && U(u);
61
+ }, [c, u]), J(() => {
62
+ if (!b.length)
63
+ return;
64
+ let e = !0;
65
+ return Fe(b).catch(() => {
66
+ }).then(() => {
67
+ e && fe((h) => h + 1);
68
+ }), () => {
69
+ e = !1;
70
+ };
71
+ }, [b]);
72
+ const r = c ? Ie : u ?? "", Se = k && r.length === 0 && !!v, ye = Be[w], F = je(r), j = Math.max(F, _), A = Math.max(_, se), De = Math.min(j, A), Te = F >= A, q = E(
73
+ () => z ?? qe(G),
74
+ [z, G]
75
+ ), l = E(
76
+ () => Ke(n),
77
+ [n, R]
78
+ ), m = ie ?? l?.languageText ?? we, K = oe ?? l?.languageLabel, X = !!K, _e = Ye(
79
+ le ?? l?.languageIcon
80
+ ), M = s ? Ce(W.readOnly) : void 0, Oe = ce ?? (M && M !== W.readOnly ? M : Ge), g = E(() => {
81
+ if (x)
82
+ return x({
83
+ code: r,
84
+ languageTemplate: l ?? n,
85
+ languageText: m
86
+ });
87
+ if (B)
88
+ return Xe({
89
+ code: r,
90
+ languageTemplate: l ?? n,
91
+ languageText: m
92
+ });
93
+ }, [
94
+ n,
95
+ l,
96
+ m,
97
+ r,
98
+ R,
99
+ x,
100
+ B
101
+ ]), Z = ae || !!g && !g.isValid, o = g && !g.isValid ? g.errorRange : void 0, ve = E(() => {
102
+ if (!o)
103
+ return /* @__PURE__ */ new Set();
104
+ const e = o.start.line, h = o.end?.line ?? e;
105
+ return new Set(
106
+ Array.from(
107
+ { length: Math.max(h - e + 1, 1) },
108
+ (ut, Ne) => e + Ne
109
+ )
110
+ );
111
+ }, [o]), t = {
112
+ disabled: P,
113
+ error: Z,
114
+ isLineCapped: Te,
115
+ isEmpty: r.length === 0,
116
+ isPlaceholderVisible: Se,
117
+ lineHeight: ye,
118
+ maxLines: A,
119
+ minLines: _,
120
+ readOnly: s,
121
+ showLineNumbers: H,
122
+ size: w,
123
+ variant: he,
124
+ visibleLineCount: De
125
+ }, xe = Q(
126
+ (e) => Ze({
127
+ code: e,
128
+ customLanguages: f,
129
+ languageTemplate: n,
130
+ languageText: m,
131
+ prismTheme: q,
132
+ syntaxErrorRange: o
133
+ }),
134
+ [
135
+ f,
136
+ n,
137
+ q,
138
+ m,
139
+ R,
140
+ o
141
+ ]
142
+ ), Re = Q(
143
+ (e) => {
144
+ c && U(e), O?.(e);
145
+ },
146
+ [O, c]
147
+ );
148
+ return Le ? /* @__PURE__ */ a($e, { ownerState: t }) : /* @__PURE__ */ S(
149
+ Je,
150
+ {
151
+ ownerState: t,
152
+ "aria-disabled": t.disabled || void 0,
153
+ className: y(p.root, L),
154
+ ...V(D, T.root, i),
155
+ children: [
156
+ X || s ? /* @__PURE__ */ S(Qe, { ownerState: t, className: p.header, children: [
157
+ X ? /* @__PURE__ */ a(
158
+ We,
159
+ {
160
+ label: K,
161
+ size: "small",
162
+ variant: "outlined",
163
+ color: "default",
164
+ startIcon: /* @__PURE__ */ a(
165
+ et,
166
+ {
167
+ ...V(
168
+ D,
169
+ T.languageChipIcon,
170
+ Ue
171
+ ),
172
+ children: /* @__PURE__ */ a(_e, { fontSize: "small" })
173
+ }
174
+ )
175
+ }
176
+ ) : null,
177
+ /* @__PURE__ */ a(tt, { ownerState: t, children: s ? /* @__PURE__ */ a(
178
+ at,
179
+ {
180
+ label: Oe,
181
+ size: "small"
182
+ }
183
+ ) : null })
184
+ ] }) : null,
185
+ /* @__PURE__ */ S(nt, { ownerState: t, children: [
186
+ H ? /* @__PURE__ */ a(rt, { ownerState: t, "aria-hidden": "true", children: Array.from({ length: j }, (e, h) => h + 1).map(
187
+ (e) => /* @__PURE__ */ a(
188
+ lt,
189
+ {
190
+ ownerState: t,
191
+ "data-code-editor-error-line": ve.has(e) || void 0,
192
+ children: e
193
+ },
194
+ `code-editor-line-${e}`
195
+ )
196
+ ) }) : null,
197
+ /* @__PURE__ */ S(ot, { ownerState: t, children: [
198
+ k && t.isEmpty && v ? /* @__PURE__ */ a(
199
+ it,
200
+ {
201
+ ownerState: t,
202
+ ...V(
203
+ D,
204
+ T.placeholder,
205
+ i
206
+ ),
207
+ children: v
208
+ }
209
+ ) : null,
210
+ /* @__PURE__ */ a(
211
+ st,
212
+ {
213
+ ...I,
214
+ ownerState: t,
215
+ "aria-label": I["aria-label"] ?? "Code editor",
216
+ "aria-invalid": I["aria-invalid"] ?? (Z || void 0),
217
+ className: y(p.editor, te),
218
+ "data-testid": ze(
219
+ D,
220
+ T.textarea,
221
+ i
222
+ ),
223
+ disabled: P,
224
+ highlight: xe,
225
+ insertSpaces: re,
226
+ onBlur: de,
227
+ onValueChange: Re,
228
+ preClassName: y(p.pre, ue),
229
+ readOnly: s,
230
+ tabSize: I.tabSize,
231
+ textareaClassName: y(
232
+ p.textarea,
233
+ ge
234
+ ),
235
+ textareaId: pe,
236
+ value: r
237
+ }
238
+ )
239
+ ] })
240
+ ] })
241
+ ]
242
+ }
243
+ );
244
+ }
245
+ export {
246
+ Dt as CodeEditor
247
+ };
@@ -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":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,eAAO,MAAM,gBAAgB,EAAE,gBA2U9B,CAAC"}
@@ -0,0 +1,297 @@
1
+ import { getTypographyStyles as d } from "../../../utils/getTypographyStyles.js";
2
+ import { getCodeEditorVSCodeModernPalette as s, CODE_EDITOR_LINE_HEIGHT_BY_SIZE as n, CODE_EDITOR_MONO_FONT_FAMILY as l, 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: r, ownerState: e }) => {
7
+ const o = !e?.disabled && !e?.readOnly, a = e?.disabled ? r.vars.palette.border.disabled : r.vars.palette.border.secondary;
8
+ return {
9
+ width: "100%",
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ minHeight: 0,
13
+ gap: 0,
14
+ border: r.vars.size.borderStroke.container,
15
+ borderColor: e?.variant === "outlined" || e?.error ? a : "transparent",
16
+ borderRadius: r.vars.size.borderRadius["r1-5"],
17
+ ...e?.error && {
18
+ borderColor: r.vars.palette.error.focus
19
+ },
20
+ ...e?.variant === "contained" && {
21
+ backgroundColor: r.vars.palette.default.enabledOpacity
22
+ },
23
+ ...e?.variant === "outlined" && {
24
+ backgroundColor: r.vars.palette.background.default
25
+ },
26
+ ...e?.readOnly && {
27
+ backgroundColor: `${r.vars.palette.default.enabledOpacity}!important`
28
+ },
29
+ overflow: "hidden",
30
+ opacity: e?.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: r.vars.palette.default.hoverOpacity,
37
+ ...e?.error && {
38
+ borderColor: r.vars.palette.error.active
39
+ }
40
+ },
41
+ "&:focus-within": {
42
+ borderColor: r.vars.palette.primary.enabled,
43
+ outline: "3px solid",
44
+ outlineColor: e?.error ? r.vars.palette.error.focusOpacity : r.vars.palette.primary.hoverOpacity,
45
+ ...e?.error && {
46
+ borderColor: r.vars.palette.error.enabled
47
+ },
48
+ ...e?.variant === "contained" && {
49
+ backgroundColor: r.vars.palette.background.default,
50
+ "&&& .M4LCodeEditor-header": {
51
+ backgroundColor: r.vars.palette.default.enabledOpacity
52
+ }
53
+ }
54
+ }
55
+ }
56
+ };
57
+ },
58
+ /** Layout the language badge row above the editing surface. */
59
+ header: ({ theme: r, ownerState: e }) => {
60
+ const o = s(r);
61
+ return {
62
+ display: "flex",
63
+ alignItems: "center",
64
+ justifyContent: "space-between",
65
+ padding: r.vars.size.baseSpacings.sp2,
66
+ gap: r.vars.size.baseSpacings.sp2,
67
+ borderBottom: r.vars.size.borderStroke.container,
68
+ borderColor: r.vars.palette.border.secondary,
69
+ ...e?.variant === "contained" && {
70
+ backgroundColor: "transparent"
71
+ },
72
+ ...e?.variant === "outlined" && {
73
+ backgroundColor: r.vars.palette.background.default
74
+ },
75
+ ...e?.readOnly && {
76
+ backgroundColor: `${r.vars.palette.background.default}!important`
77
+ },
78
+ color: o.surface.headerForeground,
79
+ borderTopLeftRadius: r.vars.size.borderRadius.r2,
80
+ borderTopRightRadius: r.vars.size.borderRadius.r2,
81
+ overflow: "hidden",
82
+ minHeight: "33px"
83
+ };
84
+ },
85
+ /** Align any trailing badges rendered in the header row. */
86
+ headerBadges: ({ theme: r }) => ({
87
+ display: "flex",
88
+ alignItems: "center",
89
+ justifyContent: "flex-end",
90
+ gap: r.vars.size.baseSpacings.sp1,
91
+ minWidth: 0,
92
+ // Keep badges right-aligned even when the language chip is absent and the
93
+ // badges container is the only child of the header row.
94
+ marginLeft: "auto"
95
+ }),
96
+ /** Keep the leading language chip aligned with the editor header layout. */
97
+ languageChip: ({ theme: r, ownerState: e }) => {
98
+ const o = s(r);
99
+ return {
100
+ flexShrink: 0,
101
+ minWidth: 0,
102
+ whiteSpace: "nowrap",
103
+ textTransform: "lowercase",
104
+ paddingTop: 0,
105
+ paddingBottom: 0,
106
+ backgroundColor: "transparent",
107
+ borderColor: r.vars.palette.chips.default.outlined.backgroundActive,
108
+ color: o.surface.languageChipForeground,
109
+ ...p(
110
+ r,
111
+ e?.size || "medium",
112
+ "base",
113
+ (a) => ({ height: a })
114
+ ),
115
+ "&&& .M4LTypography-root": {
116
+ ...d(r.generalSettings.isMobile, e?.size || "medium", "microSlim"),
117
+ color: o.surface.languageChipForeground,
118
+ textTransform: "uppercase"
119
+ }
120
+ };
121
+ },
122
+ /** Keep the language icon aligned while preserving any intrinsic Seti fill colors. */
123
+ languageChipIcon: () => ({
124
+ display: "inline-flex",
125
+ flexShrink: 0,
126
+ width: "16px",
127
+ height: "16px",
128
+ lineHeight: 0,
129
+ "& .MuiSvgIcon-root": {
130
+ display: "block",
131
+ width: "16px",
132
+ height: "16px",
133
+ fontSize: "16px"
134
+ }
135
+ }),
136
+ /** Keep the read-only chip aligned with the trailing header actions. */
137
+ readOnlyChip: ({ theme: r, ownerState: e }) => ({
138
+ "&&&": {
139
+ flexShrink: 0,
140
+ minWidth: 0,
141
+ whiteSpace: "nowrap",
142
+ ...p(
143
+ r,
144
+ e?.size || "medium",
145
+ "base",
146
+ (o) => ({ height: o })
147
+ ),
148
+ "&&& .M4LTypography-root": {
149
+ ...d(r.generalSettings.isMobile, e?.size || "medium", "microSlim"),
150
+ color: r.vars.palette.chips.info.contained.color
151
+ },
152
+ backgroundColor: r.vars.palette.chips.info.contained.backgroundColor,
153
+ borderColor: "transparent"
154
+ }
155
+ }),
156
+ /** Build the two-column layout used by the gutter and editor scroller. */
157
+ body: ({ theme: r, ownerState: e }) => {
158
+ const o = e?.visibleLineCount || e?.minLines || 1, a = e?.lineHeight || n.medium, t = e?.isLineCapped ? i : i * 2;
159
+ return {
160
+ display: "grid",
161
+ gridTemplateColumns: e?.showLineNumbers ? "auto minmax(0, 1fr)" : "minmax(0, 1fr)",
162
+ width: "100%",
163
+ alignItems: "start",
164
+ columnGap: 0,
165
+ maxHeight: `${o * a + t}px`,
166
+ minHeight: 0,
167
+ overflow: "auto",
168
+ pointerEvents: e?.disabled ? "none" : "auto",
169
+ userSelect: e?.disabled ? "none" : "auto",
170
+ gap: r.vars.size.baseSpacings.sp2
171
+ };
172
+ },
173
+ /** Style the optional line-number gutter. */
174
+ lineNumbers: ({ theme: r, ownerState: e }) => {
175
+ const o = s(r);
176
+ return {
177
+ display: "flex",
178
+ flexDirection: "column",
179
+ alignItems: "flex-end",
180
+ padding: `${i}px ${r.vars.size.baseSpacings.sp1} ${e?.isLineCapped ? 0 : i}px ${r.vars.size.baseSpacings.sp2}`,
181
+ backgroundColor: "transparent",
182
+ color: e?.disabled ? o.surface.placeholderForeground : o.surface.lineNumberForeground,
183
+ userSelect: "none",
184
+ ...d(r.generalSettings.isMobile, e?.size || "medium", "bodyStandard"),
185
+ fontFamily: l,
186
+ lineHeight: `${n[e?.size || "medium"]}px`
187
+ };
188
+ },
189
+ /** Keep each rendered line number aligned with the code line height. */
190
+ lineNumber: ({ theme: r, ownerState: e }) => {
191
+ const o = s(r);
192
+ return {
193
+ display: "block",
194
+ minWidth: "2ch",
195
+ height: `${e?.lineHeight || n.medium}px`,
196
+ lineHeight: `${e?.lineHeight || n.medium}px`,
197
+ textAlign: "right",
198
+ '&[data-code-editor-error-line="true"]': {
199
+ color: o.surface.errorBorderColor,
200
+ borderLeft: `1px solid ${o.surface.errorBorderColor}`
201
+ }
202
+ };
203
+ },
204
+ /** Provide horizontal overflow for long code lines without wrapping them. */
205
+ editorScroller: ({ theme: r, ownerState: e }) => ({
206
+ position: "relative",
207
+ width: e?.isPlaceholderVisible ? "100%" : "fit-content",
208
+ paddingTop: r.vars.size.baseSpacings.sp3,
209
+ paddingBottom: r.vars.size.baseSpacings.sp3,
210
+ paddingRight: r.vars.size.baseSpacings.sp2,
211
+ paddingLeft: r.vars.size.baseSpacings.sp2,
212
+ backgroundColor: "transparent"
213
+ }),
214
+ /** Style the underlying react-simple-code-editor surface and its inner elements. */
215
+ editor: ({ theme: r, ownerState: e }) => {
216
+ const o = s(r), a = e?.isLineCapped ? 0 : i, t = i + a;
217
+ return {
218
+ position: "relative",
219
+ zIndex: 0,
220
+ width: "max-content",
221
+ minWidth: "100%",
222
+ minHeight: `calc(${e?.minLines || 1} * ${e?.lineHeight || n.medium}px + ${t}px)`,
223
+ backgroundColor: "transparent",
224
+ fontFamily: l,
225
+ fontSize: "11px",
226
+ lineHeight: `${e?.lineHeight || n.medium}px`,
227
+ fontWeight: 400,
228
+ "& textarea, & pre": {
229
+ ...d(r.generalSettings.isMobile, e?.size || "medium", "bodyStandard"),
230
+ fontFamily: l,
231
+ lineHeight: `${e?.lineHeight || n.medium}px`,
232
+ whiteSpace: "pre !important",
233
+ wordBreak: "normal",
234
+ overflowWrap: "normal",
235
+ margin: 0,
236
+ paddingTop: `${i}px`,
237
+ paddingRight: `${i}px`,
238
+ paddingBottom: `${a}px`,
239
+ paddingLeft: `${i}px`,
240
+ tabSize: 2,
241
+ fontVariantLigatures: "none",
242
+ backgroundColor: "transparent"
243
+ },
244
+ "&&& textarea": {
245
+ ...d(r.generalSettings.isMobile, e?.size || "medium", "microSlim"),
246
+ outline: "none",
247
+ backgroundColor: "transparent",
248
+ caretColor: e?.disabled ? "transparent" : o.surface.caretForeground,
249
+ cursor: e?.disabled ? "not-allowed" : e?.readOnly ? "default" : "text",
250
+ "&::selection": {
251
+ backgroundColor: o.surface.selectionBackground
252
+ }
253
+ },
254
+ "& pre": {
255
+ color: e?.disabled ? o.surface.placeholderForeground : o.surface.editorForeground
256
+ },
257
+ "& .token-line": {
258
+ display: "block",
259
+ width: "100%"
260
+ },
261
+ '& .token-line[data-code-editor-error-line="true"]': {
262
+ backgroundColor: o.surface.errorLineBackground
263
+ },
264
+ '& [data-code-editor-error-token="true"]': {
265
+ backgroundColor: o.surface.errorRangeBackground,
266
+ boxShadow: `inset 0 -1px 0 ${o.surface.errorRangeShadowColor}`
267
+ }
268
+ };
269
+ },
270
+ /** Position the empty-state placeholder above the editor surface. */
271
+ placeholder: ({ theme: r, ownerState: e }) => {
272
+ const o = s(r);
273
+ return {
274
+ position: "absolute",
275
+ zIndex: 1,
276
+ top: `${i}px`,
277
+ left: `${i}px`,
278
+ pointerEvents: "none",
279
+ color: o.surface.placeholderForeground,
280
+ ...d(r.generalSettings.isMobile, e?.size || "medium", "bodyStandard"),
281
+ fontFamily: l,
282
+ lineHeight: `${e?.lineHeight || n.medium}px`,
283
+ whiteSpace: "pre-wrap"
284
+ };
285
+ },
286
+ /** Size the skeleton block to the same footprint as the live editor. */
287
+ skeleton: ({ theme: r }) => ({
288
+ "&&&": {
289
+ borderRadius: r.vars.size.borderRadius.r1,
290
+ width: "100%",
291
+ height: "100px"
292
+ }
293
+ })
294
+ };
295
+ export {
296
+ b as codeEditorStyles
297
+ };
@@ -0,0 +1,82 @@
1
+ import { Theme } from '@mui/material';
2
+ type CodeEditorVSCodeModernSurfacePalette = {
3
+ activeIndentGuideForeground: string;
4
+ borderColor: string;
5
+ bracketMatchBorder: string;
6
+ caretForeground: string;
7
+ dividerColor: string;
8
+ editorBackground: string;
9
+ editorForeground: string;
10
+ errorBorderColor: string;
11
+ errorRangeBackground: string;
12
+ errorRangeShadowColor: string;
13
+ errorLineBackground: string;
14
+ focusBorderColor: string;
15
+ headerBackground: string;
16
+ headerForeground: string;
17
+ inactiveSelectionBackground: string;
18
+ indentGuideForeground: string;
19
+ languageChipBackground: string;
20
+ languageChipBorder: string;
21
+ languageChipForeground: string;
22
+ lineNumberActiveForeground: string;
23
+ lineNumberForeground: string;
24
+ placeholderForeground: string;
25
+ readOnlyChipBackground: string;
26
+ readOnlyChipBorder: string;
27
+ readOnlyChipForeground: string;
28
+ rootBackground: string;
29
+ selectionBackground: string;
30
+ widgetBackground: string;
31
+ };
32
+ type CodeEditorVSCodeModernSyntaxPalette = {
33
+ attributeName: string;
34
+ boolean: string;
35
+ comment: string;
36
+ constant: string;
37
+ escape: string;
38
+ function: string;
39
+ keyword: string;
40
+ number: string;
41
+ operator: string;
42
+ regex: string;
43
+ string: string;
44
+ tag: string;
45
+ type: string;
46
+ variable: string;
47
+ };
48
+ export type CodeEditorVSCodeModernPalette = {
49
+ bracketPalette: readonly string[];
50
+ surface: CodeEditorVSCodeModernSurfacePalette;
51
+ syntax: CodeEditorVSCodeModernSyntaxPalette;
52
+ };
53
+ export declare const CODE_EDITOR_KEY_COMPONENT = "M4LCodeEditor";
54
+ export declare const CODE_EDITOR_DEFAULT_LANGUAGE = "text";
55
+ export declare const CODE_EDITOR_DEFAULT_MIN_LINES = 4;
56
+ export declare const CODE_EDITOR_DEFAULT_MAX_LINES = 10;
57
+ export declare const CODE_EDITOR_PADDING_PX = 12;
58
+ export declare const CODE_EDITOR_LINE_HEIGHT_BY_SIZE: {
59
+ readonly small: 18;
60
+ readonly medium: 20;
61
+ };
62
+ export declare const CODE_EDITOR_MONO_FONT_FAMILY = "\"Geist Mono\", \"JetBrains Mono\", \"Cascadia Code\", \"Liberation Mono\", monospace";
63
+ export declare const CODE_EDITOR_READ_ONLY_LABEL = "Read Only";
64
+ export declare const CODE_EDITOR_AT_LANGUAGE = "at-commands";
65
+ export declare const CODE_EDITOR_AT_TEMPLATE_NAME = "at-basic";
66
+ export declare const CODE_EDITOR_AT_TEMPLATE_LANGUAGE_LABEL = "AT Commands";
67
+ export declare const CODE_EDITOR_LANGUAGE_CHIP_ICON_INSTANCE_ID = "CodeEditorLanguageChipIcon";
68
+ export declare const CODE_EDITOR_AT_TEMPLATE_TOKENS: {
69
+ readonly commandPrefixes: readonly ["AT+", "+"];
70
+ readonly concatenationSeparators: readonly [";"];
71
+ readonly argumentSeparators: readonly [","];
72
+ readonly reservedWords: readonly ["SET", "INFO", "SAVE", "CLEAR"];
73
+ };
74
+ export declare const CODE_EDITOR_LANGUAGE_ALIASES: Record<string, string>;
75
+ export declare const CODE_EDITOR_FALLBACK_LANGUAGE_ICON: import('@mui/material/OverridableComponent').OverridableComponent<import('@mui/material').SvgIconTypeMap<{}, "svg">> & {
76
+ muiName: string;
77
+ };
78
+ /** Resolve the exact VS Code Modern palette for the current light or dark theme mode. */
79
+ export declare function getCodeEditorVSCodeModernPalette(theme: Theme): CodeEditorVSCodeModernPalette;
80
+ export declare const CODE_EDITOR_CLASSES: Record<"body" | "skeleton" | "header" | "pre" | "textarea" | "root" | "placeholder" | "headerBadges" | "languageChip" | "languageChipIcon" | "readOnlyChip" | "lineNumbers" | "lineNumber" | "editorScroller" | "editor", string>;
81
+ export {};
82
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/extended/ReactSimpleCodeEditor/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAS3C,KAAK,oCAAoC,GAAG;IAC1C,2BAA2B,EAAE,MAAM,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAA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