@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.
@@ -1 +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"}
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 D } from "@emotion/react/jsx-runtime";
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 Pe, useState as Q, useRef as ke, useMemo as E, useEffect as W, useCallback as z } from "react";
5
- import { useTheme as ze } from "@mui/material/styles";
6
- import { getPropDataTestId as x, getNameDataTestId as Be } from "../../../test/getNameDataTestId.js";
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 je } from "./helpers/languageIcon.js";
10
- import { ensureCodeEditorRuntimeDependencies as qe, getCodeEditorLineCount as Ke, createCodeEditorPrismTheme as Xe, resolveCodeEditorLanguageTemplate as Ze, validateCodeEditorSyntax as $e, highlightCode as Je } from "./helpers/highlighting.js";
11
- import { SkeletonStyled as Qe, RootStyled as We, HeaderStyled as et, LanguageChipStyled as tt, LanguageChipIconStyled as at, HeaderBadgesStyled as nt, ReadOnlyChipStyled as rt, BodyStyled as ot, LineNumbersStyled as lt, LineNumberStyled as it, EditorScrollerStyled as st, PlaceholderStyled as dt, EditorStyled as ct } from "./slots/CodeEditorSlots.js";
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 ut(L, y) {
14
- return L.length !== y.length ? !1 : L.every((S, o) => S === y[o]);
12
+ function ct(o) {
13
+ return o === "dark" ? "dark" : "light";
15
14
  }
16
- function _t(L) {
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: y,
19
- customLanguages: S,
20
- dataTestId: o,
20
+ className: L,
21
+ colorMode: O = "light",
22
+ customLanguages: y,
23
+ dataTestId: S,
21
24
  defaultValue: te,
22
- disabled: T = !1,
25
+ disabled: I = !1,
23
26
  editorClassName: ae,
24
27
  error: ne = !1,
25
- highlightTheme: B,
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 = He,
33
- minLines: O = we,
35
+ maxLines: de = Be,
36
+ minLines: v = He,
34
37
  onBlur: ce,
35
- onChange: v,
36
- placeholder: R,
38
+ onChange: R,
39
+ placeholder: N,
37
40
  preClassName: ue,
38
41
  readOnly: d = !1,
39
- readOnlyLabel: me,
42
+ readOnlyLabel: ge,
40
43
  runtimeDependencies: c,
41
- showLineNumbers: H = !1,
42
- showPlaceholder: w = !0,
43
- size: G = "medium",
44
- syntaxValidator: N,
45
- skeleton: ge = !1,
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: U = !1,
50
+ validateSyntax: Y = !1,
48
51
  value: u,
49
52
  variant: Ee = "outlined",
50
- ...I
51
- } = L, Ce = Pe(), pe = re || Ce, b = ze(), Y = b.palette.mode, { getLabel: fe } = Me(), Le = Ve() || ge, m = v === void 0, [A, ye] = Q(0), M = ke([]), [Se, F] = Q(
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 V = M.current;
61
+ const k = M.current;
59
62
  W(() => {
60
- m && u !== void 0 && F(u);
61
- }, [m, u]), W(() => {
62
- if (!V.length)
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 qe(V).catch(() => {
68
+ return je(k).catch(() => {
66
69
  }).then(() => {
67
70
  e && ye((s) => s + 1);
68
71
  }), () => {
69
72
  e = !1;
70
73
  };
71
- }, [V]);
72
- const r = m ? Se : u ?? "", Te = w && r.length === 0 && !!R, Ie = Ue[G], q = Ke(r), K = Math.max(q, O), P = Math.max(O, de), De = Math.min(K, P), _e = q >= P, X = E(
73
- () => B ?? Xe(b, Y),
74
- [B, Y, b]
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
- () => Ze(n),
79
+ () => Xe(n),
77
80
  [n, A]
78
- ), g = se ?? l?.languageText ?? Ge, Z = ie ?? l?.languageLabel, $ = !!Z, xe = je(
81
+ ), m = se ?? l?.languageText ?? we, Z = ie ?? l?.languageLabel, $ = !!Z, xe = Fe(
79
82
  le ?? l?.languageIcon
80
- ), k = d ? fe(ee.readOnly) : void 0, Oe = me ?? (k && k !== ee.readOnly ? k : Ye), h = E(() => {
81
- if (N)
82
- return N({
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: g
88
+ languageText: m
86
89
  });
87
- if (U)
88
- return $e({
90
+ if (Y)
91
+ return Ze({
89
92
  code: r,
90
93
  languageTemplate: l ?? n,
91
- languageText: g
94
+ languageText: m
92
95
  });
93
96
  }, [
94
97
  n,
95
98
  l,
96
- g,
99
+ m,
97
100
  r,
98
101
  A,
99
- N,
100
- U
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
- (mt, Ae) => e + Ae
111
+ (gt, Ae) => e + Ae
109
112
  )
110
113
  );
111
114
  }, [i]), t = {
112
- disabled: T,
115
+ colorMode: V,
116
+ disabled: I,
113
117
  error: J,
114
118
  isLineCapped: _e,
115
119
  isEmpty: r.length === 0,
116
- isPlaceholderVisible: Te,
117
- lineHeight: Ie,
120
+ isPlaceholderVisible: Ie,
121
+ lineHeight: De,
118
122
  maxLines: P,
119
- minLines: O,
123
+ minLines: v,
120
124
  readOnly: d,
121
- showLineNumbers: H,
122
- size: G,
125
+ showLineNumbers: w,
126
+ size: U,
123
127
  variant: Ee,
124
- visibleLineCount: De
125
- }, Re = z(
126
- (e) => Je({
128
+ visibleLineCount: Te
129
+ }, Re = B(
130
+ (e) => $e({
127
131
  code: e,
128
- customLanguages: S,
132
+ customLanguages: y,
129
133
  languageTemplate: n,
130
- languageText: g,
134
+ languageText: m,
131
135
  prismTheme: X,
132
136
  syntaxErrorRange: i
133
137
  }),
134
138
  [
135
- S,
139
+ y,
136
140
  n,
137
141
  X,
138
- g,
142
+ m,
139
143
  A,
140
144
  i
141
145
  ]
142
- ), Ne = z(
146
+ ), Ne = B(
143
147
  (e) => {
144
- m && F(e), v?.(e);
148
+ g && F(e), R?.(e);
145
149
  },
146
- [v, m]
147
- ), be = z(
150
+ [R, g]
151
+ ), be = B(
148
152
  (e) => {
149
- if (T || e.target instanceof Element && e.target.closest("textarea"))
153
+ if (I || e.target instanceof Element && e.target.closest("textarea"))
150
154
  return;
151
155
  e.currentTarget.querySelector("textarea")?.focus();
152
156
  },
153
- [T]
157
+ [I]
154
158
  );
155
- return Le ? /* @__PURE__ */ a(Qe, { ownerState: t }) : /* @__PURE__ */ D(
156
- We,
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, y),
161
- ...x(p, f.root, o),
164
+ className: _(C.root, L),
165
+ ...x(p, f.root, S),
162
166
  children: [
163
- $ || d ? /* @__PURE__ */ D(et, { ownerState: t, className: C.header, children: [
167
+ $ || d ? /* @__PURE__ */ T(We, { ownerState: t, className: C.header, children: [
164
168
  $ ? /* @__PURE__ */ a(
165
- tt,
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
- at,
176
+ tt,
173
177
  {
174
178
  ...x(
175
179
  p,
176
180
  f.languageChipIcon,
177
- Fe
181
+ Ye
178
182
  ),
179
183
  children: /* @__PURE__ */ a(xe, { fontSize: "small" })
180
184
  }
181
185
  )
182
186
  }
183
187
  ) : null,
184
- /* @__PURE__ */ a(nt, { ownerState: t, children: d ? /* @__PURE__ */ a(
185
- rt,
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__ */ D(
193
- ot,
196
+ /* @__PURE__ */ T(
197
+ rt,
194
198
  {
195
199
  ownerState: t,
196
200
  onClick: be,
197
- ...x(p, f.body, o),
201
+ ...x(p, f.body, S),
198
202
  children: [
199
- H ? /* @__PURE__ */ a(lt, { ownerState: t, "aria-hidden": "true", children: Array.from({ length: K }, (e, s) => s + 1).map(
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
- it,
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__ */ D(st, { ownerState: t, children: [
211
- w && t.isEmpty && R ? /* @__PURE__ */ a(
212
- dt,
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
- o
222
+ S
219
223
  ),
220
- children: R
224
+ children: N
221
225
  }
222
226
  ) : null,
223
227
  /* @__PURE__ */ a(
224
- ct,
228
+ dt,
225
229
  {
226
- ...I,
230
+ ...D,
227
231
  ownerState: t,
228
- "aria-label": I["aria-label"] ?? "Code editor",
229
- "aria-invalid": I["aria-invalid"] ?? (J || void 0),
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": Be(
235
+ "data-testid": ze(
232
236
  p,
233
237
  f.textarea,
234
- o
238
+ S
235
239
  ),
236
- disabled: T,
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: I.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
- _t as CodeEditor
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":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,eAAO,MAAM,gBAAgB,EAAE,gBA6U9B,CAAC"}
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"}