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