@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.
- package/dist/assets/components/alert/Alert.style.css +1 -1
- package/dist/assets/components/avatar/Avatar.style.css +1 -1
- package/dist/assets/components/badge/Badge.style.css +1 -1
- package/dist/assets/components/breadcrumb/Breadcrumb.style.css +1 -1
- package/dist/assets/components/button/Button.style.css +1 -1
- package/dist/assets/components/button-group/ButtonGroup.style.css +1 -1
- package/dist/assets/components/card/Card.style.css +1 -1
- package/dist/assets/components/chart/Chart.style.css +1 -1
- package/dist/assets/components/command/Command.style.css +1 -1
- package/dist/assets/components/context-menu/ContextMenu.style.css +1 -1
- package/dist/assets/components/data-table/DataTable.style.css +1 -1
- package/dist/assets/components/dialog/Dialog.style.css +1 -1
- package/dist/assets/components/editor/Editor.styles.css +1 -1
- package/dist/assets/components/file-tabs/FileTabs.style.css +1 -1
- package/dist/assets/components/form/ColorInput.style.css +1 -1
- package/dist/assets/components/form/DateInput.style.css +1 -1
- package/dist/assets/components/form/EditorInput.style.css +1 -1
- package/dist/assets/components/form/Input.style.css +1 -1
- package/dist/assets/components/form/InputWrapper.style.css +1 -1
- package/dist/assets/components/form/SelectInput.style.css +1 -1
- package/dist/assets/components/json-view/JsonView.style.css +1 -1
- package/dist/assets/components/menu/Menu.style.css +1 -1
- package/dist/assets/components/resizable/Resizable.style.css +1 -1
- package/dist/assets/components/segmented-control/SegmentedControl.style.css +1 -1
- package/dist/assets/components/spacing/Spacing.style.css +1 -1
- package/dist/assets/components/tab/Tab.style.css +1 -1
- package/dist/assets/components/text/Text.style.css +1 -1
- package/dist/assets/components/toast/Toast.style.css +1 -1
- package/dist/assets/components/tooltip/Tooltip.style.css +1 -1
- package/dist/components/command/Command.js +35 -38
- package/dist/components/form/DateInput.js +82 -86
- package/dist/components/form/EditorInput.d.ts +35 -10
- package/dist/components/form/EditorInput.js +535 -148
- package/dist/components/form/EmailInput.js +16 -15
- package/dist/components/form/Input.d.ts +0 -20
- package/dist/components/form/Input.js +47 -432
- package/dist/components/form/InputWrapper.d.ts +0 -1
- package/dist/components/form/InputWrapper.js +52 -48
- package/dist/components/form/NumberInput.js +17 -16
- package/dist/components/form/PasswordInput.js +23 -22
- package/dist/components/form/TagInput.d.ts +37 -0
- package/dist/components/form/TagInput.js +124 -0
- package/dist/components/form/TextInput.js +12 -11
- package/dist/components/form/index.d.ts +1 -2
- package/dist/components/form/index.js +77 -70
- package/dist/components/layout/Layout.js +37 -37
- package/dist/components/menu/Menu.d.ts +2 -2
- package/dist/components/menu/Menu.js +87 -87
- package/dist/components/scroll-area/ScrollArea.js +1 -1
- package/dist/index.js +220 -213
- package/dist/utils/index.js +11 -11
- package/dist/utils/size.d.ts +3 -3
- package/dist/utils/size.js +12 -6
- package/package.json +1 -1
- package/dist/components/form/Input.syntax.hook.d.ts +0 -10
- package/dist/components/form/Input.syntax.hook.js +0 -14
- package/dist/components/form/InputContentEditable.hook.d.ts +0 -52
- package/dist/components/form/InputContentEditable.hook.js +0 -449
- package/dist/components/form/InputSuggestion.d.ts +0 -27
- package/dist/components/form/InputSuggestion.js +0 -218
|
@@ -1,170 +1,557 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
9
|
+
import { mergeComponentProps as Ee } from "../../utils/component.js";
|
|
9
10
|
import "js-md5";
|
|
10
|
-
import { Menu as
|
|
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
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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:
|
|
23
|
-
right:
|
|
24
|
-
left:
|
|
25
|
-
rightType:
|
|
26
|
-
leftType:
|
|
27
|
-
description:
|
|
28
|
-
wrapperComponent:
|
|
29
|
-
tokenRules:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
}, [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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:
|
|
66
|
-
} =
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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:
|
|
74
|
-
offset:
|
|
266
|
+
path: A,
|
|
267
|
+
offset: M.index
|
|
75
268
|
},
|
|
76
269
|
focus: {
|
|
77
|
-
path:
|
|
78
|
-
offset:
|
|
270
|
+
path: A,
|
|
271
|
+
offset: M.index + M[0].length
|
|
79
272
|
},
|
|
80
|
-
tokenRuleIndex:
|
|
81
|
-
tokenText:
|
|
82
|
-
tokenMatch:
|
|
273
|
+
tokenRuleIndex: fe,
|
|
274
|
+
tokenText: M[0],
|
|
275
|
+
tokenMatch: M
|
|
83
276
|
});
|
|
84
|
-
}),
|
|
85
|
-
}, [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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__ */
|
|
97
|
-
}, [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}, [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
]
|
|
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
|
-
|
|
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
|
};
|