@code0-tech/pictor 0.16.0 → 0.17.1

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 (60) hide show
  1. package/dist/assets/components/alert/Alert.style.css +1 -1
  2. package/dist/assets/components/avatar/Avatar.style.css +1 -1
  3. package/dist/assets/components/badge/Badge.style.css +1 -1
  4. package/dist/assets/components/breadcrumb/Breadcrumb.style.css +1 -1
  5. package/dist/assets/components/button/Button.style.css +1 -1
  6. package/dist/assets/components/button-group/ButtonGroup.style.css +1 -1
  7. package/dist/assets/components/card/Card.style.css +1 -1
  8. package/dist/assets/components/chart/Chart.style.css +1 -1
  9. package/dist/assets/components/command/Command.style.css +1 -1
  10. package/dist/assets/components/context-menu/ContextMenu.style.css +1 -1
  11. package/dist/assets/components/data-table/DataTable.style.css +1 -1
  12. package/dist/assets/components/dialog/Dialog.style.css +1 -1
  13. package/dist/assets/components/editor/Editor.styles.css +1 -1
  14. package/dist/assets/components/file-tabs/FileTabs.style.css +1 -1
  15. package/dist/assets/components/form/ColorInput.style.css +1 -1
  16. package/dist/assets/components/form/DateInput.style.css +1 -1
  17. package/dist/assets/components/form/EditorInput.style.css +1 -1
  18. package/dist/assets/components/form/Input.style.css +1 -1
  19. package/dist/assets/components/form/InputWrapper.style.css +1 -1
  20. package/dist/assets/components/form/SelectInput.style.css +1 -1
  21. package/dist/assets/components/json-view/JsonView.style.css +1 -1
  22. package/dist/assets/components/menu/Menu.style.css +1 -1
  23. package/dist/assets/components/resizable/Resizable.style.css +1 -1
  24. package/dist/assets/components/segmented-control/SegmentedControl.style.css +1 -1
  25. package/dist/assets/components/spacing/Spacing.style.css +1 -1
  26. package/dist/assets/components/tab/Tab.style.css +1 -1
  27. package/dist/assets/components/text/Text.style.css +1 -1
  28. package/dist/assets/components/toast/Toast.style.css +1 -1
  29. package/dist/assets/components/tooltip/Tooltip.style.css +1 -1
  30. package/dist/components/command/Command.js +35 -38
  31. package/dist/components/form/DateInput.js +82 -86
  32. package/dist/components/form/EditorInput.d.ts +35 -10
  33. package/dist/components/form/EditorInput.js +535 -148
  34. package/dist/components/form/EmailInput.js +16 -15
  35. package/dist/components/form/Input.d.ts +0 -20
  36. package/dist/components/form/Input.js +47 -432
  37. package/dist/components/form/InputWrapper.d.ts +0 -1
  38. package/dist/components/form/InputWrapper.js +52 -48
  39. package/dist/components/form/NumberInput.js +17 -16
  40. package/dist/components/form/PasswordInput.js +23 -22
  41. package/dist/components/form/TagInput.d.ts +37 -0
  42. package/dist/components/form/TagInput.js +124 -0
  43. package/dist/components/form/TextInput.js +12 -11
  44. package/dist/components/form/index.d.ts +1 -2
  45. package/dist/components/form/index.js +77 -70
  46. package/dist/components/layout/Layout.js +37 -37
  47. package/dist/components/menu/Menu.d.ts +2 -2
  48. package/dist/components/menu/Menu.js +87 -87
  49. package/dist/components/scroll-area/ScrollArea.js +1 -1
  50. package/dist/index.js +220 -213
  51. package/dist/utils/index.js +11 -11
  52. package/dist/utils/size.d.ts +3 -3
  53. package/dist/utils/size.js +12 -6
  54. package/package.json +1 -1
  55. package/dist/components/form/Input.syntax.hook.d.ts +0 -10
  56. package/dist/components/form/Input.syntax.hook.js +0 -14
  57. package/dist/components/form/InputContentEditable.hook.d.ts +0 -52
  58. package/dist/components/form/InputContentEditable.hook.js +0 -449
  59. package/dist/components/form/InputSuggestion.d.ts +0 -27
  60. package/dist/components/form/InputSuggestion.js +0 -218
@@ -1,170 +1,557 @@
1
- import { jsx as i, jsxs as P } from "react/jsx-runtime";
2
- import R, { useMemo as O, useRef as w, useCallback as f, useState as le } from "react";
3
- import { createEditor as se, Editor as k, Transforms as D, Text as ae, Node as ce } from "slate";
4
- import { withReact as ue, ReactEditor as pe, Editable as fe, Slate as de } from "slate-react";
5
- import { withHistory as ge } from "slate-history";
6
- import { InputWrapper as he } from "./InputWrapper.js";
1
+ import { jsx as v, jsxs as Re } from "react/jsx-runtime";
2
+ import { c as ae } from "../../_virtual/compiler-runtime.js";
3
+ import ee, { useMemo as de, useRef as W, useState as le, useEffect as se, useCallback as O } from "react";
4
+ import { createEditor as Ve, Editor as he, Transforms as oe, Text as ge, Range as ke, Node as Fe } from "slate";
5
+ import { withReact as Le, ReactEditor as Y, Slate as $e, Editable as je } from "slate-react";
6
+ import { withHistory as Be } from "slate-history";
7
+ import { InputWrapper as Ke } from "./InputWrapper.js";
7
8
  import "../../utils/contextStore.js";
8
- import { mergeComponentProps as me } from "../../utils/component.js";
9
+ import { mergeComponentProps as Ee } from "../../utils/component.js";
9
10
  import "js-md5";
10
- import { Menu as xe, MenuTrigger as ye, MenuPortal as we } from "../menu/Menu.js";
11
- import { InputSuggestionMenuContent as Te, InputSuggestionMenuContentItems as ve } from "./InputSuggestion.js";
11
+ import { Menu as Ue, MenuPortal as We, MenuContent as Ge, MenuItem as He, MenuSubContent as qe, MenuTrigger as ze, MenuSubTrigger as Je, MenuSub as Qe } from "../menu/Menu.js";
12
12
  import '../../assets/components/form/EditorInput.style.css';/* empty css */
13
- const B = (g) => (g || "").split(`
14
- `).map((h) => ({
13
+ const Z = (n) => n?.type === "token", Xe = (n, e) => {
14
+ const i = [];
15
+ e.forEach((u, d) => {
16
+ if (!u.void) return;
17
+ const h = new RegExp(u.pattern.source, u.pattern.flags.includes("g") ? u.pattern.flags : u.pattern.flags + "g");
18
+ let f;
19
+ for (; (f = h.exec(n)) !== null && f[0].length; )
20
+ i.push({
21
+ start: f.index,
22
+ end: f.index + f[0].length,
23
+ ruleIndex: d,
24
+ token: f[0],
25
+ match: f
26
+ });
27
+ }), i.sort((u, d) => u.start - d.start);
28
+ const r = [];
29
+ let l = 0;
30
+ return i.forEach((u) => {
31
+ if (u.start < l) return;
32
+ u.start > l ? r.push({
33
+ text: n.slice(l, u.start)
34
+ }) : r.length && Z(r[r.length - 1]) && r.push({
35
+ text: ""
36
+ });
37
+ const d = {
38
+ type: "token",
39
+ ruleIndex: u.ruleIndex,
40
+ token: u.token,
41
+ match: u.match,
42
+ children: [{
43
+ text: ""
44
+ }]
45
+ };
46
+ r.push(d), l = u.end;
47
+ }), l < n.length && r.push({
48
+ text: n.slice(l)
49
+ }), (!r.length || Z(r[0])) && r.unshift({
50
+ text: ""
51
+ }), Z(r[r.length - 1]) && r.push({
52
+ text: ""
53
+ }), r;
54
+ }, Me = (n, e) => (n || "").split(`
55
+ `).map((i) => ({
15
56
  type: "paragraph",
16
- children: [{
17
- text: h
18
- }]
19
- })), F = (g) => g.map((h) => ce.string(h)).join(`
20
- `), Oe = R.memo((g) => {
57
+ children: Xe(i, e)
58
+ })), Ae = (n) => ge.isText(n) ? n.text : Z(n) ? n.token : n.children.map(Ae).join(""), Oe = (n) => n.map(Ae).join(`
59
+ `), _e = ee.createContext(null), me = ee.createContext(null), ce = () => {
60
+ const n = ee.useContext(_e);
61
+ if (!n)
62
+ throw new Error("EditorInput.* components must be used inside <EditorInput>");
63
+ return n;
64
+ }, It = (n) => {
21
65
  const {
22
- title: h,
23
- right: j,
24
- left: A,
25
- rightType: H,
26
- leftType: K,
27
- description: $,
28
- wrapperComponent: v,
29
- tokenRules: m = [],
30
- suggestions: s,
31
- suggestionsEmptyState: L,
32
- onSuggestionSelect: q,
33
- formValidation: E,
34
- onChange: I,
35
- disabled: z = !1,
36
- readonly: U = !1,
37
- singleLine: x = !1,
38
- placeholder: W,
39
- value: G,
40
- initialValue: J,
41
- defaultValue: Q,
42
- required: Ce,
43
- ...X
44
- } = g, S = String(G ?? J ?? Q ?? ""), c = x ? S.replace(/\n/g, " ") : S, r = O(() => ge(ue(se())), []), Y = O(() => B(c), []), T = w(c);
45
- R.useEffect(() => {
46
- if (c === T.current || (T.current = c, F(r.children) === c)) return;
47
- const e = B(c);
48
- k.withoutNormalizing(r, () => {
49
- for (D.delete(r, {
50
- at: {
51
- anchor: k.start(r, []),
52
- focus: k.end(r, [])
53
- }
54
- }), D.insertNodes(r, e, {
66
+ title: e,
67
+ right: i,
68
+ left: r,
69
+ rightType: l,
70
+ leftType: u,
71
+ description: d,
72
+ wrapperComponent: h,
73
+ tokenRules: f = [],
74
+ onSelect: p,
75
+ search: S,
76
+ formValidation: I,
77
+ onChange: o,
78
+ disabled: k = !1,
79
+ readonly: C = !1,
80
+ singleLine: g = !1,
81
+ placeholder: b,
82
+ value: y,
83
+ initialValue: F,
84
+ defaultValue: E,
85
+ children: B
86
+ } = n, L = String(y ?? F ?? E ?? ""), x = g ? L.replace(/\n/g, " ") : L, c = de(() => {
87
+ const t = Be(Le(Ve())), {
88
+ isInline: s,
89
+ isVoid: T
90
+ } = t;
91
+ return t.isInline = (D) => Z(D) || s(D), t.isVoid = (D) => Z(D) || T(D), t;
92
+ }, []), K = de(() => Me(x, f), []), P = W(x), [$, U] = le(x);
93
+ se(() => {
94
+ if (x === P.current || (P.current = x, U(x), Oe(c.children) === x)) return;
95
+ const t = Me(x, f);
96
+ he.withoutNormalizing(c, () => {
97
+ oe.deselect(c);
98
+ const s = c.children.length;
99
+ oe.insertNodes(c, t, {
55
100
  at: [0]
56
- }); r.children.length > e.length; ) D.removeNodes(r, {
57
- at: [r.children.length - 1]
58
101
  });
102
+ for (let T = 0; T < s; T++) oe.removeNodes(c, {
103
+ at: [t.length]
104
+ });
105
+ });
106
+ try {
107
+ oe.select(c, he.end(c, []));
108
+ } catch {
109
+ }
110
+ }, [x, c, f]);
111
+ const [m, G] = le(!1), [H, ie] = le("shortcut"), q = W(H);
112
+ q.current = H;
113
+ const te = W(null), Q = W(null), j = W(void 0), N = O(() => {
114
+ const t = Q.current, s = te.current, T = s?.parentElement;
115
+ if (!t || !s || !T) return;
116
+ let D = null;
117
+ try {
118
+ c.selection && (D = Y.toDOMRange(c, c.selection).getBoundingClientRect());
119
+ } catch {
120
+ D = null;
121
+ }
122
+ (!D || !D.width && !D.height && !D.left && !D.top) && (D = s.getBoundingClientRect());
123
+ const Se = T.getBoundingClientRect();
124
+ t.style.left = `${D.left - Se.left}px`, t.style.top = `${D.top - Se.top}px`, t.style.width = "0px", t.style.height = `${D.height || parseFloat(getComputedStyle(s).lineHeight) || 16}px`;
125
+ }, [c]), X = I?.setValue, a = O((t) => {
126
+ m && N();
127
+ const s = Oe(t);
128
+ s !== P.current && (P.current = s, U(s), X?.(s), o?.(s));
129
+ }, [m, N, X, o]), V = O(() => {
130
+ Q.current && (j.current && clearTimeout(j.current), N(), G(!0));
131
+ }, [N]);
132
+ se(() => {
133
+ m && N();
134
+ }, [m, N]);
135
+ const A = O(() => {
136
+ j.current && clearTimeout(j.current), j.current = setTimeout(() => G(!1), 150);
137
+ }, []), R = O(() => {
138
+ j.current && clearTimeout(j.current);
139
+ }, []), w = W(/* @__PURE__ */ new Map()), [_, fe] = le(null), z = W(null), M = O((t) => {
140
+ z.current = t, fe(t);
141
+ }, []), [xe, Pe] = le(null), pe = W(null), ne = O((t) => {
142
+ pe.current = t, Pe(t);
143
+ }, []), ve = O((t, s) => (w.current.set(t, s), () => {
144
+ w.current.delete(t), z.current === t && M(null);
145
+ }), [M]), re = O(() => Array.from(w.current.entries()).filter(([, t]) => t.el.current && t.parentId === pe.current).sort((t, s) => t[1].el.current.compareDocumentPosition(s[1].el.current) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1).map(([t]) => t), []), J = O((t) => {
146
+ M(t), t && w.current.get(t)?.el.current?.scrollIntoView({
147
+ block: "nearest"
59
148
  });
60
- }, [c, r]);
61
- const Z = f(([e, t]) => {
62
- const l = [];
63
- if (!ae.isText(e) || !m.length) return l;
149
+ }, [M]), Ie = O(() => {
150
+ const t = re();
151
+ if (!t.length) return;
152
+ const s = z.current, T = s === null ? -1 : t.indexOf(s);
153
+ J(t[Math.min(T + 1, t.length - 1)] ?? t[0]);
154
+ }, [re, J]), ye = O(() => {
155
+ const t = re();
156
+ if (!t.length) return;
157
+ const s = z.current, T = s === null ? t.length : t.indexOf(s);
158
+ J(t[Math.max(T - 1, 0)] ?? t[t.length - 1]);
159
+ }, [re, J]), Ce = O(() => {
160
+ const t = re();
161
+ t.length && J(t[0]);
162
+ }, [re, J]), ue = O((t, s) => {
163
+ p?.(t, s), q.current !== "focus" && G(!1);
164
+ }, [p]), be = O(() => {
165
+ const t = z.current;
166
+ if (!t) return !1;
167
+ const s = w.current.get(t);
168
+ return s ? s.onActivate ? (s.onActivate(), !0) : (setTimeout(() => ue(s.getValue(), s.getData()), 0), !0) : !1;
169
+ }, [ue]), we = O((t) => {
170
+ ne(t), setTimeout(() => {
171
+ const s = Array.from(w.current.entries()).filter(([, T]) => T.el.current && T.parentId === t).sort((T, D) => T[1].el.current.compareDocumentPosition(D[1].el.current) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1).map(([T]) => T);
172
+ s.length && J(s[0]);
173
+ }, 20);
174
+ }, [ne, J]), Te = O(() => {
175
+ const t = pe.current;
176
+ t !== null && (ne(null), M(t));
177
+ }, [ne, M]), De = O(() => {
178
+ const t = z.current;
179
+ if (!t) return !1;
180
+ const s = w.current.get(t);
181
+ return s?.onActivate ? (s.onActivate(), !0) : !1;
182
+ }, []);
183
+ se(() => {
184
+ m || (M(null), ne(null));
185
+ }, [m, M, ne]);
186
+ const Ne = de(() => ({
187
+ editor: c,
188
+ tokenRules: f,
189
+ singleLine: g,
190
+ disabled: k,
191
+ readonly: C,
192
+ placeholder: b,
193
+ search: S,
194
+ documentText: $,
195
+ open: m,
196
+ setOpen: G,
197
+ openMenu: V,
198
+ menuOpenMode: H,
199
+ setMenuOpenMode: ie,
200
+ editorContainerRef: te,
201
+ triggerRef: Q,
202
+ updateTriggerPosition: N,
203
+ scheduleClose: A,
204
+ cancelClose: R,
205
+ registerItem: ve,
206
+ activeId: _,
207
+ setActiveId: M,
208
+ highlightNext: Ie,
209
+ highlightPrevious: ye,
210
+ focusFirst: Ce,
211
+ selectActive: be,
212
+ select: ue,
213
+ openSubId: xe,
214
+ enterSub: we,
215
+ exitSub: Te,
216
+ openActiveSub: De
217
+ }), [c, f, g, k, C, b, S, $, m, V, H, N, A, R, ve, _, M, Ie, ye, Ce, be, ue, xe, we, Te, De]);
218
+ return /* @__PURE__ */ v($e, { editor: c, initialValue: K, onChange: a, children: /* @__PURE__ */ v(_e.Provider, { value: Ne, children: /* @__PURE__ */ v(Ue, { open: m, modal: !1, onOpenChange: (t) => !t && G(!1), children: /* @__PURE__ */ v(Ke, { title: e, description: d, right: i, left: r, rightType: l, leftType: u, formValidation: I, ...h ?? {}, style: {
219
+ position: "relative",
220
+ ...h?.style
221
+ }, children: B }) }) }) });
222
+ }, yt = (n) => {
223
+ const e = ae.c(44), {
224
+ editor: i,
225
+ tokenRules: r,
226
+ singleLine: l,
227
+ disabled: u,
228
+ readonly: d,
229
+ placeholder: h,
230
+ open: f,
231
+ openMenu: p,
232
+ setOpen: S,
233
+ menuOpenMode: I,
234
+ editorContainerRef: o,
235
+ scheduleClose: k,
236
+ cancelClose: C,
237
+ highlightNext: g,
238
+ highlightPrevious: b,
239
+ focusFirst: y,
240
+ selectActive: F,
241
+ openSubId: E,
242
+ exitSub: B,
243
+ openActiveSub: L
244
+ } = ce();
245
+ let x;
246
+ e[0] !== C || e[1] !== I || e[2] !== p ? (x = () => {
247
+ C(), I === "focus" && p();
248
+ }, e[0] = C, e[1] = I, e[2] = p, e[3] = x) : x = e[3];
249
+ const c = x;
250
+ let K;
251
+ e[4] !== r ? (K = (a) => {
252
+ const [V, A] = a, R = [];
253
+ if (!ge.isText(V) || !r.length)
254
+ return R;
64
255
  const {
65
- text: n
66
- } = e;
67
- return m.forEach((o, oe) => {
68
- const ie = new RegExp(o.pattern.source, o.pattern.flags.includes("g") ? o.pattern.flags : o.pattern.flags + "g");
69
- let p;
70
- for (; (p = ie.exec(n)) !== null && p[0].length; )
71
- l.push({
256
+ text: w
257
+ } = V;
258
+ return r.forEach((_, fe) => {
259
+ if (_.void)
260
+ return;
261
+ const z = new RegExp(_.pattern.source, _.pattern.flags.includes("g") ? _.pattern.flags : _.pattern.flags + "g");
262
+ let M;
263
+ for (; (M = z.exec(w)) !== null && M[0].length; )
264
+ R.push({
72
265
  anchor: {
73
- path: t,
74
- offset: p.index
266
+ path: A,
267
+ offset: M.index
75
268
  },
76
269
  focus: {
77
- path: t,
78
- offset: p.index + p[0].length
270
+ path: A,
271
+ offset: M.index + M[0].length
79
272
  },
80
- tokenRuleIndex: oe,
81
- tokenText: p[0],
82
- tokenMatch: p
273
+ tokenRuleIndex: fe,
274
+ tokenText: M[0],
275
+ tokenMatch: M
83
276
  });
84
- }), l;
85
- }, [m]), ee = f(({
86
- attributes: e,
87
- children: t,
88
- leaf: l
89
- }) => {
90
- const n = l;
91
- if (n.tokenRuleIndex !== void 0) {
92
- const o = m[n.tokenRuleIndex];
93
- if (o)
94
- return o.wrap ? /* @__PURE__ */ i("span", { ...e, children: o.wrap(n.tokenText ?? "", t, n.tokenMatch ?? []) }) : /* @__PURE__ */ i("span", { ...e, children: /* @__PURE__ */ i("span", { style: o.style, className: o.className, children: t }) });
277
+ }), R;
278
+ }, e[4] = r, e[5] = K) : K = e[5];
279
+ const P = K;
280
+ let $;
281
+ e[6] !== r ? ($ = (a) => {
282
+ const {
283
+ attributes: V,
284
+ children: A,
285
+ leaf: R
286
+ } = a, w = R;
287
+ if (w.tokenRuleIndex !== void 0) {
288
+ const _ = r[w.tokenRuleIndex];
289
+ if (_)
290
+ return _.wrap ? /* @__PURE__ */ v("span", { ...V, children: _.wrap(w.tokenText ?? "", A, w.tokenMatch ?? []) }) : /* @__PURE__ */ v("span", { ...V, children: /* @__PURE__ */ v("span", { style: _.style, className: _.className, children: A }) });
95
291
  }
96
- return /* @__PURE__ */ i("span", { ...e, children: t });
97
- }, [m]), [a, d] = le(!1), M = w(null), C = w(null), _ = w(null), u = w(void 0), y = f(() => {
98
- const e = _.current, t = C.current, l = t?.parentElement;
99
- if (!e || !t || !l) return;
100
- let n = null;
101
- try {
102
- r.selection && (n = pe.toDOMRange(r, r.selection).getBoundingClientRect());
103
- } catch {
104
- n = null;
292
+ return /* @__PURE__ */ v("span", { ...V, children: A });
293
+ }, e[6] = r, e[7] = $) : $ = e[7];
294
+ const U = $;
295
+ let m;
296
+ e[8] !== r ? (m = (a) => {
297
+ const {
298
+ attributes: V,
299
+ children: A,
300
+ element: R
301
+ } = a;
302
+ if (Z(R)) {
303
+ const w = r[R.ruleIndex], _ = w?.wrap ? w.wrap(R.token, null, R.match ?? []) : /* @__PURE__ */ v("span", { style: w?.style, className: w?.className, children: R.token });
304
+ return /* @__PURE__ */ Re("span", { ...V, children: [
305
+ /* @__PURE__ */ v("span", { contentEditable: !1, className: "editor-input__token", style: {
306
+ userSelect: "none"
307
+ }, children: _ }),
308
+ A
309
+ ] });
105
310
  }
106
- (!n || !n.width && !n.height && !n.left && !n.top) && (n = t.getBoundingClientRect());
107
- const o = l.getBoundingClientRect();
108
- e.style.left = `${n.left - o.left}px`, e.style.top = `${n.top - o.top}px`, e.style.width = "0px", e.style.height = `${n.height || parseFloat(getComputedStyle(t).lineHeight) || 16}px`;
109
- }, [r]), N = E?.setValue, te = f((e) => {
110
- a && y();
111
- const t = F(e);
112
- t !== T.current && (T.current = t, N?.(t), I?.(t));
113
- }, [a, y, N, I]), b = f(() => {
114
- u.current && clearTimeout(u.current), s && (y(), d(!0));
115
- }, [s, y]);
116
- R.useEffect(() => {
117
- a && y();
118
- }, [a]);
119
- const ne = f(() => {
120
- u.current && clearTimeout(u.current), u.current = setTimeout(() => d(!1), 150);
121
- }, []), re = f((e) => {
122
- if (x && e.key === "Enter" && e.preventDefault(), !s) return;
123
- const t = M.current;
124
- if (e.ctrlKey && e.code === "Space") {
125
- e.preventDefault(), a ? t?.focusFirstItem() : b();
311
+ return /* @__PURE__ */ v("div", { ...V, style: {
312
+ position: "relative"
313
+ }, children: A });
314
+ }, e[8] = r, e[9] = m) : m = e[9];
315
+ const G = m;
316
+ let H;
317
+ e[10] !== i || e[11] !== B || e[12] !== y || e[13] !== g || e[14] !== b || e[15] !== f || e[16] !== L || e[17] !== p || e[18] !== E || e[19] !== F || e[20] !== S || e[21] !== l || e[22] !== r ? (H = (a) => {
318
+ if (l && a.key === "Enter" && a.preventDefault(), a.ctrlKey && a.code === "Space") {
319
+ a.preventDefault(), f ? y() : p();
126
320
  return;
127
321
  }
128
- !a || !t || (e.key === "ArrowDown" ? (e.preventDefault(), t.highlightNextItem()) : e.key === "ArrowUp" ? (e.preventDefault(), t.highlightPreviousItem()) : e.key === "Enter" ? t.selectActiveItem() && (e.preventDefault(), d(!1)) : e.key === "Escape" && (e.preventDefault(), d(!1)));
129
- }, [s, a, b, x]), V = /* @__PURE__ */ i("div", { ...me("editor-input", X), ref: C, children: /* @__PURE__ */ i(
130
- fe,
131
- {
132
- className: x ? "input-wrapper__control input-wrapper__control--single-line" : "input-wrapper__control",
133
- decorate: Z,
134
- renderLeaf: ee,
135
- readOnly: z || U,
136
- spellCheck: !1,
137
- placeholder: W,
138
- onBlur: ne,
139
- onFocus: () => {
140
- u.current && clearTimeout(u.current);
141
- },
142
- onKeyDown: re,
143
- onPaste: x ? (e) => {
144
- e.preventDefault(), r.insertText(e.clipboardData.getData("text/plain").replace(/\r?\n/g, " "));
145
- } : void 0
322
+ if (f) {
323
+ if (a.key === "ArrowDown") {
324
+ a.preventDefault(), g();
325
+ return;
326
+ }
327
+ if (a.key === "ArrowUp") {
328
+ a.preventDefault(), b();
329
+ return;
330
+ }
331
+ if (a.key === "ArrowRight" && L()) {
332
+ a.preventDefault();
333
+ return;
334
+ }
335
+ if (a.key === "ArrowLeft" && E !== null) {
336
+ a.preventDefault(), B();
337
+ return;
338
+ }
339
+ if (a.key === "Enter") {
340
+ F() && a.preventDefault();
341
+ return;
342
+ }
343
+ if (a.key === "Escape") {
344
+ a.preventDefault(), E !== null ? B() : S(!1);
345
+ return;
346
+ }
146
347
  }
147
- ) });
148
- return /* @__PURE__ */ i(de, { editor: r, initialValue: Y, onChange: te, children: /* @__PURE__ */ i(he, { title: h, description: $, right: j, left: A, rightType: H, leftType: K, formValidation: E, wrapperComponent: s ? {
149
- ...v ?? {},
150
- style: {
151
- position: "relative",
152
- ...v?.style
348
+ if ((a.key === "ArrowLeft" || a.key === "ArrowRight") && !a.shiftKey && r.some(Ye) && i.selection && ke.isCollapsed(i.selection)) {
349
+ a.preventDefault();
350
+ const V = a.key === "ArrowLeft";
351
+ oe.move(i, {
352
+ unit: "offset",
353
+ reverse: V
354
+ });
355
+ const A = i.selection;
356
+ if (A && ke.isCollapsed(A)) {
357
+ const R = Fe.parent(i, A.anchor.path);
358
+ !ge.isText(R) && he.isVoid(i, R) && oe.move(i, {
359
+ unit: "offset",
360
+ reverse: V
361
+ });
362
+ }
153
363
  }
154
- } : v, children: s ? /* @__PURE__ */ P(xe, { open: a, modal: !1, onOpenChange: (e) => !e && d(!1), children: [
155
- V,
156
- /* @__PURE__ */ i(ye, { asChild: !0, children: /* @__PURE__ */ i("button", { ref: _, type: "button", tabIndex: -1, "aria-hidden": !0, onMouseDown: (e) => e.preventDefault(), className: "editor-input__menu-anchor" }) }),
157
- /* @__PURE__ */ i(we, { children: /* @__PURE__ */ P(Te, { color: "primary", onInteractOutside: (e) => {
158
- const t = e.target;
159
- t && C.current?.contains(t) && e.preventDefault();
160
- }, children: [
161
- s.length === 0 && L,
162
- /* @__PURE__ */ i(ve, { ref: M, suggestions: s, onSuggestionSelect: (e) => {
163
- q?.(e), d(!1);
164
- } })
165
- ] }) })
166
- ] }) : V }) });
167
- });
364
+ }, e[10] = i, e[11] = B, e[12] = y, e[13] = g, e[14] = b, e[15] = f, e[16] = L, e[17] = p, e[18] = E, e[19] = F, e[20] = S, e[21] = l, e[22] = r, e[23] = H) : H = e[23];
365
+ const ie = H;
366
+ let q;
367
+ e[24] !== n ? (q = Ee("editor-input", n), e[24] = n, e[25] = q) : q = e[25];
368
+ const te = l ? "input-wrapper__control input-wrapper__control--single-line" : "input-wrapper__control", Q = u || d;
369
+ let j;
370
+ e[26] !== i || e[27] !== l ? (j = l ? (a) => {
371
+ a.preventDefault(), i.insertText(a.clipboardData.getData("text/plain").replace(/\r?\n/g, " "));
372
+ } : void 0, e[26] = i, e[27] = l, e[28] = j) : j = e[28];
373
+ let N;
374
+ e[29] !== P || e[30] !== c || e[31] !== ie || e[32] !== h || e[33] !== G || e[34] !== U || e[35] !== k || e[36] !== te || e[37] !== Q || e[38] !== j ? (N = /* @__PURE__ */ v(je, { className: te, decorate: P, renderLeaf: U, renderElement: G, readOnly: Q, spellCheck: !1, placeholder: h, onBlur: k, onFocus: c, onKeyDown: ie, onPaste: j }), e[29] = P, e[30] = c, e[31] = ie, e[32] = h, e[33] = G, e[34] = U, e[35] = k, e[36] = te, e[37] = Q, e[38] = j, e[39] = N) : N = e[39];
375
+ let X;
376
+ return e[40] !== o || e[41] !== q || e[42] !== N ? (X = /* @__PURE__ */ v("div", { ...q, ref: o, children: N }), e[40] = o, e[41] = q, e[42] = N, e[43] = X) : X = e[43], X;
377
+ }, Ct = (n) => {
378
+ const e = ae.c(5), {
379
+ triggerRef: i
380
+ } = ce();
381
+ let r;
382
+ e[0] !== n ? (r = Ee("editor-input__menu-anchor", n), e[0] = n, e[1] = r) : r = e[1];
383
+ let l;
384
+ return e[2] !== r || e[3] !== i ? (l = /* @__PURE__ */ v(ze, { asChild: !0, children: /* @__PURE__ */ v("button", { ref: i, type: "button", tabIndex: -1, "aria-hidden": !0, onMouseDown: Ze, ...r }) }), e[2] = r, e[3] = i, e[4] = l) : l = e[4], l;
385
+ }, bt = (n) => {
386
+ const e = ae.c(21), {
387
+ editor: i,
388
+ editorContainerRef: r,
389
+ setMenuOpenMode: l
390
+ } = ce();
391
+ let u, d, h;
392
+ e[0] !== n ? ({
393
+ children: u,
394
+ openOn: h,
395
+ ...d
396
+ } = n, e[0] = n, e[1] = u, e[2] = d, e[3] = h) : (u = e[1], d = e[2], h = e[3]);
397
+ const f = h === void 0 ? "shortcut" : h;
398
+ let p, S;
399
+ e[4] !== f || e[5] !== l ? (p = () => l(f), S = [f, l], e[4] = f, e[5] = l, e[6] = p, e[7] = S) : (p = e[6], S = e[7]), se(p, S);
400
+ let I, o;
401
+ e[8] !== i ? (I = (y) => {
402
+ y.preventDefault(), Y.focus(i);
403
+ }, o = () => Y.focus(i), e[8] = i, e[9] = I, e[10] = o) : (I = e[9], o = e[10]);
404
+ let k;
405
+ e[11] !== r ? (k = (y) => {
406
+ const F = y.target;
407
+ F && r.current?.contains(F) && y.preventDefault();
408
+ }, e[11] = r, e[12] = k) : k = e[12];
409
+ let C;
410
+ e[13] !== d || e[14] !== I || e[15] !== o || e[16] !== k ? (C = {
411
+ color: "primary",
412
+ align: "start",
413
+ sideOffset: 8,
414
+ onContextMenuCapture: et,
415
+ onCloseAutoFocus: tt,
416
+ onOpenAutoFocus: I,
417
+ onFocusCapture: o,
418
+ onInteractOutside: k,
419
+ ...d
420
+ }, e[13] = d, e[14] = I, e[15] = o, e[16] = k, e[17] = C) : C = e[17];
421
+ const g = C;
422
+ let b;
423
+ return e[18] !== u || e[19] !== g ? (b = /* @__PURE__ */ v(We, { children: /* @__PURE__ */ v(Ge, { ...g, children: u }) }), e[18] = u, e[19] = g, e[20] = b) : b = e[20], b;
424
+ }, wt = (n) => {
425
+ const {
426
+ value: e,
427
+ data: i,
428
+ children: r,
429
+ onlyOnce: l,
430
+ aliases: u,
431
+ ...d
432
+ } = n, {
433
+ editor: h,
434
+ registerItem: f,
435
+ activeId: p,
436
+ setActiveId: S,
437
+ select: I,
438
+ search: o,
439
+ documentText: k
440
+ } = ce(), C = ee.useContext(me), g = ee.useId(), b = W(null), y = W({
441
+ value: e,
442
+ data: i
443
+ });
444
+ y.current = {
445
+ value: e,
446
+ data: i
447
+ };
448
+ const F = !!l && k.includes(String(e)), E = o?.trim().toLowerCase() ?? "", B = !E || [typeof r == "string" ? r : String(e), ...u ?? []].some((c) => c.toLowerCase().includes(E)), L = F || !B;
449
+ return se(() => {
450
+ if (!L)
451
+ return f(g, {
452
+ getValue: () => y.current.value,
453
+ getData: () => y.current.data,
454
+ el: b,
455
+ parentId: C
456
+ });
457
+ }, [g, f, C, L]), L ? null : /* @__PURE__ */ v(He, { ...d, ref: (c) => {
458
+ b.current = c;
459
+ }, textValue: "", "data-focus": p === g || void 0, onPointerDown: (c) => {
460
+ c.preventDefault(), S(g), Y.focus(h);
461
+ }, onPointerMove: (c) => {
462
+ c.preventDefault(), c.stopPropagation(), p !== g && S(g);
463
+ }, onSelect: () => setTimeout(() => I(y.current.value, y.current.data), 0), children: r });
464
+ }, Tt = (n) => {
465
+ const e = ae.c(38), {
466
+ label: i,
467
+ children: r
468
+ } = n, {
469
+ editor: l,
470
+ registerItem: u,
471
+ activeId: d,
472
+ setActiveId: h,
473
+ openSubId: f,
474
+ enterSub: p,
475
+ exitSub: S
476
+ } = ce(), I = ee.useContext(me), o = ee.useId(), k = W(null);
477
+ let C, g;
478
+ e[0] !== p || e[1] !== o || e[2] !== I || e[3] !== u ? (C = () => u(o, {
479
+ getValue: nt,
480
+ getData: rt,
481
+ el: k,
482
+ parentId: I,
483
+ onActivate: () => p(o)
484
+ }), g = [o, u, I, p], e[0] = p, e[1] = o, e[2] = I, e[3] = u, e[4] = C, e[5] = g) : (C = e[4], g = e[5]), se(C, g);
485
+ let b;
486
+ e[6] !== l ? (b = {
487
+ onOpenAutoFocus: (m) => {
488
+ m.preventDefault(), Y.focus(l);
489
+ },
490
+ onFocusCapture: () => Y.focus(l),
491
+ onCloseAutoFocus: ot,
492
+ onFocusOutside: st,
493
+ onInteractOutside: it
494
+ }, e[6] = l, e[7] = b) : b = e[7];
495
+ const y = b, F = f === o;
496
+ let E;
497
+ e[8] !== p || e[9] !== S || e[10] !== o || e[11] !== f ? (E = (m) => {
498
+ m && f !== o ? p(o) : !m && f === o && S();
499
+ }, e[8] = p, e[9] = S, e[10] = o, e[11] = f, e[12] = E) : E = e[12];
500
+ let B;
501
+ e[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (B = (m) => {
502
+ k.current = m;
503
+ }, e[13] = B) : B = e[13];
504
+ const L = d === o || void 0;
505
+ let x;
506
+ e[14] !== l || e[15] !== o || e[16] !== h ? (x = (m) => {
507
+ m.preventDefault(), h(o), Y.focus(l);
508
+ }, e[14] = l, e[15] = o, e[16] = h, e[17] = x) : x = e[17];
509
+ let c;
510
+ e[18] !== d || e[19] !== o || e[20] !== h ? (c = () => {
511
+ d !== o && h(o);
512
+ }, e[18] = d, e[19] = o, e[20] = h, e[21] = c) : c = e[21];
513
+ let K;
514
+ e[22] !== i || e[23] !== L || e[24] !== x || e[25] !== c ? (K = /* @__PURE__ */ v(Je, { ref: B, "data-focus": L, onPointerDown: x, onPointerMove: c, children: i }), e[22] = i, e[23] = L, e[24] = x, e[25] = c, e[26] = K) : K = e[26];
515
+ let P;
516
+ e[27] !== r || e[28] !== o ? (P = /* @__PURE__ */ v(me.Provider, { value: o, children: r }), e[27] = r, e[28] = o, e[29] = P) : P = e[29];
517
+ let $;
518
+ e[30] !== y || e[31] !== P ? ($ = /* @__PURE__ */ v(qe, { color: "primary", ...y, children: P }), e[30] = y, e[31] = P, e[32] = $) : $ = e[32];
519
+ let U;
520
+ return e[33] !== K || e[34] !== $ || e[35] !== F || e[36] !== E ? (U = /* @__PURE__ */ Re(Qe, { open: F, onOpenChange: E, children: [
521
+ K,
522
+ $
523
+ ] }), e[33] = K, e[34] = $, e[35] = F, e[36] = E, e[37] = U) : U = e[37], U;
524
+ };
525
+ function Ye(n) {
526
+ return n.void;
527
+ }
528
+ function Ze(n) {
529
+ return n.preventDefault();
530
+ }
531
+ function et(n) {
532
+ return n.stopPropagation();
533
+ }
534
+ function tt(n) {
535
+ return n.preventDefault();
536
+ }
537
+ function nt() {
538
+ }
539
+ function rt() {
540
+ }
541
+ function ot(n) {
542
+ return n.preventDefault();
543
+ }
544
+ function st(n) {
545
+ return n.preventDefault();
546
+ }
547
+ function it(n) {
548
+ return n.preventDefault();
549
+ }
168
550
  export {
169
- Oe as EditorInput
551
+ It as EditorInput,
552
+ bt as EditorInputMenu,
553
+ wt as EditorInputMenuItem,
554
+ Tt as EditorInputSubMenu,
555
+ Ct as EditorInputTrigger,
556
+ yt as EditorInputValue
170
557
  };