@m4l/components 9.24.0-beta-feature-731-m4l-components-code-editor.4 → 9.24.0-beta-feature-731-m4l-components-code-editor.6
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/components/extended/ReactSimpleCodeEditor/CodeEditor.d.ts.map +1 -1
- package/components/extended/ReactSimpleCodeEditor/CodeEditor.js +104 -100
- package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.d.ts.map +1 -1
- package/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.js +105 -93
- package/components/extended/ReactSimpleCodeEditor/constants.d.ts +2 -2
- package/components/extended/ReactSimpleCodeEditor/constants.d.ts.map +1 -1
- package/components/extended/ReactSimpleCodeEditor/constants.js +28 -29
- package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.d.ts +1 -2
- package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.d.ts.map +1 -1
- package/components/extended/ReactSimpleCodeEditor/helpers/highlighting.js +51 -51
- package/components/extended/ReactSimpleCodeEditor/types.d.ts +325 -0
- package/components/extended/ReactSimpleCodeEditor/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/extended/ReactSimpleCodeEditor/CodeEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/extended/ReactSimpleCodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,SAAS,CAAC;AAyBjB;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,oDAwXhD"}
|
|
@@ -1,103 +1,106 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
1
|
+
import { jsx as a, jsxs as T } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useModuleDictionary as Me, useModuleSkeleton as Ve } from "@m4l/core";
|
|
3
3
|
import _ from "clsx";
|
|
4
|
-
import { useId as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { CODE_EDITOR_DEFAULT_MAX_LINES as He, CODE_EDITOR_DEFAULT_MIN_LINES as we, CODE_EDITOR_DEFAULT_LANGUAGE as Ge, CODE_EDITOR_LINE_HEIGHT_BY_SIZE as Ue, CODE_EDITOR_CLASSES as C, CODE_EDITOR_KEY_COMPONENT as p, CODE_EDITOR_READ_ONLY_LABEL as Ye, CODE_EDITOR_LANGUAGE_CHIP_ICON_INSTANCE_ID as Fe } from "./constants.js";
|
|
4
|
+
import { useId as ke, useState as Q, useRef as Pe, useMemo as E, useEffect as W, useCallback as B } from "react";
|
|
5
|
+
import { getPropDataTestId as x, getNameDataTestId as ze } from "../../../test/getNameDataTestId.js";
|
|
6
|
+
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
7
|
import { CODE_EDITOR_DICTIONARY as ee } from "./dictionary.js";
|
|
9
|
-
import { resolveCodeEditorLanguageIcon as
|
|
10
|
-
import { ensureCodeEditorRuntimeDependencies as
|
|
11
|
-
import { SkeletonStyled as
|
|
8
|
+
import { resolveCodeEditorLanguageIcon as Fe } from "./helpers/languageIcon.js";
|
|
9
|
+
import { ensureCodeEditorRuntimeDependencies as je, getCodeEditorLineCount as qe, createCodeEditorPrismTheme as Ke, resolveCodeEditorLanguageTemplate as Xe, validateCodeEditorSyntax as Ze, highlightCode as $e } from "./helpers/highlighting.js";
|
|
10
|
+
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
11
|
import { CodeEditorSlots as f } from "./slots/CodeEditorEnum.js";
|
|
13
|
-
function
|
|
14
|
-
return
|
|
12
|
+
function ct(o) {
|
|
13
|
+
return o === "dark" ? "dark" : "light";
|
|
15
14
|
}
|
|
16
|
-
function
|
|
15
|
+
function ut(o, L) {
|
|
16
|
+
return o.length !== L.length ? !1 : o.every((O, y) => O === L[y]);
|
|
17
|
+
}
|
|
18
|
+
function Tt(o) {
|
|
17
19
|
const {
|
|
18
|
-
className:
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
className: L,
|
|
21
|
+
colorMode: O = "light",
|
|
22
|
+
customLanguages: y,
|
|
23
|
+
dataTestId: S,
|
|
21
24
|
defaultValue: te,
|
|
22
|
-
disabled:
|
|
25
|
+
disabled: I = !1,
|
|
23
26
|
editorClassName: ae,
|
|
24
27
|
error: ne = !1,
|
|
25
|
-
highlightTheme:
|
|
28
|
+
highlightTheme: H,
|
|
26
29
|
id: re,
|
|
27
30
|
insertSpaces: oe,
|
|
28
31
|
languageIcon: le,
|
|
29
32
|
languageLabel: ie,
|
|
30
33
|
languageTemplate: n,
|
|
31
34
|
languageText: se,
|
|
32
|
-
maxLines: de =
|
|
33
|
-
minLines:
|
|
35
|
+
maxLines: de = Be,
|
|
36
|
+
minLines: v = He,
|
|
34
37
|
onBlur: ce,
|
|
35
|
-
onChange:
|
|
36
|
-
placeholder:
|
|
38
|
+
onChange: R,
|
|
39
|
+
placeholder: N,
|
|
37
40
|
preClassName: ue,
|
|
38
41
|
readOnly: d = !1,
|
|
39
|
-
readOnlyLabel:
|
|
42
|
+
readOnlyLabel: ge,
|
|
40
43
|
runtimeDependencies: c,
|
|
41
|
-
showLineNumbers:
|
|
42
|
-
showPlaceholder:
|
|
43
|
-
size:
|
|
44
|
-
syntaxValidator:
|
|
45
|
-
skeleton:
|
|
44
|
+
showLineNumbers: w = !1,
|
|
45
|
+
showPlaceholder: G = !0,
|
|
46
|
+
size: U = "medium",
|
|
47
|
+
syntaxValidator: b,
|
|
48
|
+
skeleton: me = !1,
|
|
46
49
|
textareaClassName: he,
|
|
47
|
-
validateSyntax:
|
|
50
|
+
validateSyntax: Y = !1,
|
|
48
51
|
value: u,
|
|
49
52
|
variant: Ee = "outlined",
|
|
50
|
-
...
|
|
51
|
-
} =
|
|
53
|
+
...D
|
|
54
|
+
} = o, Ce = ke(), pe = re || Ce, { getLabel: fe } = Me(), Le = Ve() || me, g = R === void 0, [A, ye] = Q(0), M = Pe([]), [Se, F] = Q(
|
|
52
55
|
u ?? te ?? ""
|
|
53
|
-
), j = E(() => c ? Array.isArray(c) ? c : [c] : [], [c]);
|
|
56
|
+
), V = ct(O), j = E(() => c ? Array.isArray(c) ? c : [c] : [], [c]);
|
|
54
57
|
ut(
|
|
55
58
|
M.current,
|
|
56
59
|
j
|
|
57
60
|
) || (M.current = j);
|
|
58
|
-
const
|
|
61
|
+
const k = M.current;
|
|
59
62
|
W(() => {
|
|
60
|
-
|
|
61
|
-
}, [
|
|
62
|
-
if (!
|
|
63
|
+
g && u !== void 0 && F(u);
|
|
64
|
+
}, [g, u]), W(() => {
|
|
65
|
+
if (!k.length)
|
|
63
66
|
return;
|
|
64
67
|
let e = !0;
|
|
65
|
-
return
|
|
68
|
+
return je(k).catch(() => {
|
|
66
69
|
}).then(() => {
|
|
67
70
|
e && ye((s) => s + 1);
|
|
68
71
|
}), () => {
|
|
69
72
|
e = !1;
|
|
70
73
|
};
|
|
71
|
-
}, [
|
|
72
|
-
const r =
|
|
73
|
-
() =>
|
|
74
|
-
[
|
|
74
|
+
}, [k]);
|
|
75
|
+
const r = g ? Se : u ?? "", Ie = G && r.length === 0 && !!N, De = Ge[U], q = qe(r), K = Math.max(q, v), P = Math.max(v, de), Te = Math.min(K, P), _e = q >= P, X = E(
|
|
76
|
+
() => H ?? Ke(V),
|
|
77
|
+
[V, H]
|
|
75
78
|
), l = E(
|
|
76
|
-
() =>
|
|
79
|
+
() => Xe(n),
|
|
77
80
|
[n, A]
|
|
78
|
-
),
|
|
81
|
+
), m = se ?? l?.languageText ?? we, Z = ie ?? l?.languageLabel, $ = !!Z, xe = Fe(
|
|
79
82
|
le ?? l?.languageIcon
|
|
80
|
-
),
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
83
|
+
), z = d ? fe(ee.readOnly) : void 0, Oe = ge ?? (z && z !== ee.readOnly ? z : Ue), h = E(() => {
|
|
84
|
+
if (b)
|
|
85
|
+
return b({
|
|
83
86
|
code: r,
|
|
84
87
|
languageTemplate: l ?? n,
|
|
85
|
-
languageText:
|
|
88
|
+
languageText: m
|
|
86
89
|
});
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
90
|
+
if (Y)
|
|
91
|
+
return Ze({
|
|
89
92
|
code: r,
|
|
90
93
|
languageTemplate: l ?? n,
|
|
91
|
-
languageText:
|
|
94
|
+
languageText: m
|
|
92
95
|
});
|
|
93
96
|
}, [
|
|
94
97
|
n,
|
|
95
98
|
l,
|
|
96
|
-
|
|
99
|
+
m,
|
|
97
100
|
r,
|
|
98
101
|
A,
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
b,
|
|
103
|
+
Y
|
|
101
104
|
]), J = ne || !!h && !h.isValid, i = h && !h.isValid ? h.errorRange : void 0, ve = E(() => {
|
|
102
105
|
if (!i)
|
|
103
106
|
return /* @__PURE__ */ new Set();
|
|
@@ -105,100 +108,101 @@ function _t(L) {
|
|
|
105
108
|
return new Set(
|
|
106
109
|
Array.from(
|
|
107
110
|
{ length: Math.max(s - e + 1, 1) },
|
|
108
|
-
(
|
|
111
|
+
(gt, Ae) => e + Ae
|
|
109
112
|
)
|
|
110
113
|
);
|
|
111
114
|
}, [i]), t = {
|
|
112
|
-
|
|
115
|
+
colorMode: V,
|
|
116
|
+
disabled: I,
|
|
113
117
|
error: J,
|
|
114
118
|
isLineCapped: _e,
|
|
115
119
|
isEmpty: r.length === 0,
|
|
116
|
-
isPlaceholderVisible:
|
|
117
|
-
lineHeight:
|
|
120
|
+
isPlaceholderVisible: Ie,
|
|
121
|
+
lineHeight: De,
|
|
118
122
|
maxLines: P,
|
|
119
|
-
minLines:
|
|
123
|
+
minLines: v,
|
|
120
124
|
readOnly: d,
|
|
121
|
-
showLineNumbers:
|
|
122
|
-
size:
|
|
125
|
+
showLineNumbers: w,
|
|
126
|
+
size: U,
|
|
123
127
|
variant: Ee,
|
|
124
|
-
visibleLineCount:
|
|
125
|
-
}, Re =
|
|
126
|
-
(e) =>
|
|
128
|
+
visibleLineCount: Te
|
|
129
|
+
}, Re = B(
|
|
130
|
+
(e) => $e({
|
|
127
131
|
code: e,
|
|
128
|
-
customLanguages:
|
|
132
|
+
customLanguages: y,
|
|
129
133
|
languageTemplate: n,
|
|
130
|
-
languageText:
|
|
134
|
+
languageText: m,
|
|
131
135
|
prismTheme: X,
|
|
132
136
|
syntaxErrorRange: i
|
|
133
137
|
}),
|
|
134
138
|
[
|
|
135
|
-
|
|
139
|
+
y,
|
|
136
140
|
n,
|
|
137
141
|
X,
|
|
138
|
-
|
|
142
|
+
m,
|
|
139
143
|
A,
|
|
140
144
|
i
|
|
141
145
|
]
|
|
142
|
-
), Ne =
|
|
146
|
+
), Ne = B(
|
|
143
147
|
(e) => {
|
|
144
|
-
|
|
148
|
+
g && F(e), R?.(e);
|
|
145
149
|
},
|
|
146
|
-
[
|
|
147
|
-
), be =
|
|
150
|
+
[R, g]
|
|
151
|
+
), be = B(
|
|
148
152
|
(e) => {
|
|
149
|
-
if (
|
|
153
|
+
if (I || e.target instanceof Element && e.target.closest("textarea"))
|
|
150
154
|
return;
|
|
151
155
|
e.currentTarget.querySelector("textarea")?.focus();
|
|
152
156
|
},
|
|
153
|
-
[
|
|
157
|
+
[I]
|
|
154
158
|
);
|
|
155
|
-
return Le ? /* @__PURE__ */ a(
|
|
156
|
-
|
|
159
|
+
return Le ? /* @__PURE__ */ a(Je, { ownerState: t }) : /* @__PURE__ */ T(
|
|
160
|
+
Qe,
|
|
157
161
|
{
|
|
158
162
|
ownerState: t,
|
|
159
163
|
"aria-disabled": t.disabled || void 0,
|
|
160
|
-
className: _(C.root,
|
|
161
|
-
...x(p, f.root,
|
|
164
|
+
className: _(C.root, L),
|
|
165
|
+
...x(p, f.root, S),
|
|
162
166
|
children: [
|
|
163
|
-
$ || d ? /* @__PURE__ */
|
|
167
|
+
$ || d ? /* @__PURE__ */ T(We, { ownerState: t, className: C.header, children: [
|
|
164
168
|
$ ? /* @__PURE__ */ a(
|
|
165
|
-
|
|
169
|
+
et,
|
|
166
170
|
{
|
|
167
171
|
label: Z,
|
|
168
172
|
size: "small",
|
|
169
173
|
variant: "outlined",
|
|
170
174
|
color: "default",
|
|
171
175
|
startIcon: /* @__PURE__ */ a(
|
|
172
|
-
|
|
176
|
+
tt,
|
|
173
177
|
{
|
|
174
178
|
...x(
|
|
175
179
|
p,
|
|
176
180
|
f.languageChipIcon,
|
|
177
|
-
|
|
181
|
+
Ye
|
|
178
182
|
),
|
|
179
183
|
children: /* @__PURE__ */ a(xe, { fontSize: "small" })
|
|
180
184
|
}
|
|
181
185
|
)
|
|
182
186
|
}
|
|
183
187
|
) : null,
|
|
184
|
-
/* @__PURE__ */ a(
|
|
185
|
-
|
|
188
|
+
/* @__PURE__ */ a(at, { ownerState: t, children: d ? /* @__PURE__ */ a(
|
|
189
|
+
nt,
|
|
186
190
|
{
|
|
187
191
|
label: Oe,
|
|
188
192
|
size: "small"
|
|
189
193
|
}
|
|
190
194
|
) : null })
|
|
191
195
|
] }) : null,
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
196
|
+
/* @__PURE__ */ T(
|
|
197
|
+
rt,
|
|
194
198
|
{
|
|
195
199
|
ownerState: t,
|
|
196
200
|
onClick: be,
|
|
197
|
-
...x(p, f.body,
|
|
201
|
+
...x(p, f.body, S),
|
|
198
202
|
children: [
|
|
199
|
-
|
|
203
|
+
w ? /* @__PURE__ */ a(ot, { ownerState: t, "aria-hidden": "true", children: Array.from({ length: K }, (e, s) => s + 1).map(
|
|
200
204
|
(e) => /* @__PURE__ */ a(
|
|
201
|
-
|
|
205
|
+
lt,
|
|
202
206
|
{
|
|
203
207
|
ownerState: t,
|
|
204
208
|
"data-code-editor-error-line": ve.has(e) || void 0,
|
|
@@ -207,40 +211,40 @@ function _t(L) {
|
|
|
207
211
|
`code-editor-line-${e}`
|
|
208
212
|
)
|
|
209
213
|
) }) : null,
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
|
|
212
|
-
|
|
214
|
+
/* @__PURE__ */ T(it, { ownerState: t, children: [
|
|
215
|
+
G && t.isEmpty && N ? /* @__PURE__ */ a(
|
|
216
|
+
st,
|
|
213
217
|
{
|
|
214
218
|
ownerState: t,
|
|
215
219
|
...x(
|
|
216
220
|
p,
|
|
217
221
|
f.placeholder,
|
|
218
|
-
|
|
222
|
+
S
|
|
219
223
|
),
|
|
220
|
-
children:
|
|
224
|
+
children: N
|
|
221
225
|
}
|
|
222
226
|
) : null,
|
|
223
227
|
/* @__PURE__ */ a(
|
|
224
|
-
|
|
228
|
+
dt,
|
|
225
229
|
{
|
|
226
|
-
...
|
|
230
|
+
...D,
|
|
227
231
|
ownerState: t,
|
|
228
|
-
"aria-label":
|
|
229
|
-
"aria-invalid":
|
|
232
|
+
"aria-label": D["aria-label"] ?? "Code editor",
|
|
233
|
+
"aria-invalid": D["aria-invalid"] ?? (J || void 0),
|
|
230
234
|
className: _(C.editor, ae),
|
|
231
|
-
"data-testid":
|
|
235
|
+
"data-testid": ze(
|
|
232
236
|
p,
|
|
233
237
|
f.textarea,
|
|
234
|
-
|
|
238
|
+
S
|
|
235
239
|
),
|
|
236
|
-
disabled:
|
|
240
|
+
disabled: I,
|
|
237
241
|
highlight: Re,
|
|
238
242
|
insertSpaces: oe,
|
|
239
243
|
onBlur: ce,
|
|
240
244
|
onValueChange: Ne,
|
|
241
245
|
preClassName: _(C.pre, ue),
|
|
242
246
|
readOnly: d,
|
|
243
|
-
tabSize:
|
|
247
|
+
tabSize: D.tabSize,
|
|
244
248
|
textareaClassName: _(
|
|
245
249
|
C.textarea,
|
|
246
250
|
he
|
|
@@ -258,5 +262,5 @@ function _t(L) {
|
|
|
258
262
|
);
|
|
259
263
|
}
|
|
260
264
|
export {
|
|
261
|
-
|
|
265
|
+
Tt as CodeEditor
|
|
262
266
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.styles.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/extended/ReactSimpleCodeEditor/CodeEditor.styles.ts"],"names":[],"mappings":"
|
|
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"}
|