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