@code0-tech/pictor 0.17.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.
|
@@ -22,9 +22,18 @@ export interface EditorInputProps extends Omit<InputWrapperProps, "onChange" | "
|
|
|
22
22
|
placeholder?: string;
|
|
23
23
|
children?: React.ReactNode;
|
|
24
24
|
}
|
|
25
|
+
export type EditorInputMenuOpenMode = "shortcut" | "focus";
|
|
25
26
|
export type EditorInputValueProps = Component<HTMLDivElement>;
|
|
26
27
|
export type EditorInputTriggerProps = Component<HTMLButtonElement>;
|
|
27
|
-
export type EditorInputMenuProps = MenuContentProps
|
|
28
|
+
export type EditorInputMenuProps = MenuContentProps & {
|
|
29
|
+
/**
|
|
30
|
+
* When the menu opens.
|
|
31
|
+
* - "shortcut" (default): opens only on Ctrl+Space.
|
|
32
|
+
* - "focus": opens as soon as the input is focused and stays open while focused.
|
|
33
|
+
* Positioning stays anchored to the caret in both modes.
|
|
34
|
+
*/
|
|
35
|
+
openOn?: EditorInputMenuOpenMode;
|
|
36
|
+
};
|
|
28
37
|
export type EditorInputMenuItemProps = MenuItemProps & {
|
|
29
38
|
value: any;
|
|
30
39
|
data?: any;
|
|
@@ -1,542 +1,557 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import
|
|
4
|
-
import { createEditor as
|
|
5
|
-
import { withReact as
|
|
6
|
-
import { withHistory as
|
|
7
|
-
import { InputWrapper as
|
|
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";
|
|
8
8
|
import "../../utils/contextStore.js";
|
|
9
|
-
import { mergeComponentProps as
|
|
9
|
+
import { mergeComponentProps as Ee } from "../../utils/component.js";
|
|
10
10
|
import "js-md5";
|
|
11
|
-
import { Menu as
|
|
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
|
-
const
|
|
15
|
-
e.forEach((
|
|
16
|
-
if (!
|
|
17
|
-
const
|
|
18
|
-
let
|
|
19
|
-
for (; (
|
|
20
|
-
|
|
21
|
-
start:
|
|
22
|
-
end:
|
|
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
23
|
ruleIndex: d,
|
|
24
|
-
token:
|
|
25
|
-
match:
|
|
24
|
+
token: f[0],
|
|
25
|
+
match: f
|
|
26
26
|
});
|
|
27
|
-
}),
|
|
27
|
+
}), i.sort((u, d) => u.start - d.start);
|
|
28
28
|
const r = [];
|
|
29
|
-
let
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
text: n.slice(
|
|
34
|
-
}) : r.length &&
|
|
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
35
|
text: ""
|
|
36
36
|
});
|
|
37
37
|
const d = {
|
|
38
38
|
type: "token",
|
|
39
|
-
ruleIndex:
|
|
40
|
-
token:
|
|
41
|
-
match:
|
|
39
|
+
ruleIndex: u.ruleIndex,
|
|
40
|
+
token: u.token,
|
|
41
|
+
match: u.match,
|
|
42
42
|
children: [{
|
|
43
43
|
text: ""
|
|
44
44
|
}]
|
|
45
45
|
};
|
|
46
|
-
r.push(d),
|
|
47
|
-
}),
|
|
48
|
-
text: n.slice(
|
|
49
|
-
}), (!r.length ||
|
|
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
50
|
text: ""
|
|
51
|
-
}),
|
|
51
|
+
}), Z(r[r.length - 1]) && r.push({
|
|
52
52
|
text: ""
|
|
53
53
|
}), r;
|
|
54
|
-
},
|
|
55
|
-
`).map((
|
|
54
|
+
}, Me = (n, e) => (n || "").split(`
|
|
55
|
+
`).map((i) => ({
|
|
56
56
|
type: "paragraph",
|
|
57
|
-
children:
|
|
58
|
-
})),
|
|
59
|
-
`),
|
|
60
|
-
const n =
|
|
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
61
|
if (!n)
|
|
62
62
|
throw new Error("EditorInput.* components must be used inside <EditorInput>");
|
|
63
63
|
return n;
|
|
64
|
-
},
|
|
64
|
+
}, It = (n) => {
|
|
65
65
|
const {
|
|
66
66
|
title: e,
|
|
67
|
-
right:
|
|
67
|
+
right: i,
|
|
68
68
|
left: r,
|
|
69
|
-
rightType:
|
|
70
|
-
leftType:
|
|
69
|
+
rightType: l,
|
|
70
|
+
leftType: u,
|
|
71
71
|
description: d,
|
|
72
|
-
wrapperComponent:
|
|
73
|
-
tokenRules:
|
|
74
|
-
onSelect:
|
|
75
|
-
search:
|
|
76
|
-
formValidation:
|
|
77
|
-
onChange:
|
|
78
|
-
disabled:
|
|
79
|
-
readonly:
|
|
80
|
-
singleLine:
|
|
81
|
-
placeholder:
|
|
82
|
-
value:
|
|
83
|
-
initialValue:
|
|
84
|
-
defaultValue:
|
|
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
85
|
children: B
|
|
86
|
-
} = n,
|
|
87
|
-
const t = Le(
|
|
86
|
+
} = n, L = String(y ?? F ?? E ?? ""), x = g ? L.replace(/\n/g, " ") : L, c = de(() => {
|
|
87
|
+
const t = Be(Le(Ve())), {
|
|
88
88
|
isInline: s,
|
|
89
|
-
isVoid:
|
|
89
|
+
isVoid: T
|
|
90
90
|
} = t;
|
|
91
|
-
return t.isInline = (
|
|
92
|
-
}, []), K =
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
const t =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const s =
|
|
99
|
-
|
|
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, {
|
|
100
100
|
at: [0]
|
|
101
101
|
});
|
|
102
|
-
for (let
|
|
102
|
+
for (let T = 0; T < s; T++) oe.removeNodes(c, {
|
|
103
103
|
at: [t.length]
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
try {
|
|
107
|
-
|
|
107
|
+
oe.select(c, he.end(c, []));
|
|
108
108
|
} catch {
|
|
109
109
|
}
|
|
110
|
-
}, [
|
|
111
|
-
const [
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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;
|
|
115
117
|
try {
|
|
116
|
-
|
|
118
|
+
c.selection && (D = Y.toDOMRange(c, c.selection).getBoundingClientRect());
|
|
117
119
|
} catch {
|
|
118
|
-
|
|
120
|
+
D = null;
|
|
119
121
|
}
|
|
120
|
-
(!
|
|
121
|
-
const
|
|
122
|
-
t.style.left = `${
|
|
123
|
-
}, [
|
|
124
|
-
|
|
125
|
-
const s =
|
|
126
|
-
s !==
|
|
127
|
-
}, [
|
|
128
|
-
|
|
129
|
-
}, [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, [
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
}, []),
|
|
136
|
-
|
|
137
|
-
}, []),
|
|
138
|
-
|
|
139
|
-
}, []), [
|
|
140
|
-
|
|
141
|
-
}, []),
|
|
142
|
-
|
|
143
|
-
}), [
|
|
144
|
-
|
|
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({
|
|
145
147
|
block: "nearest"
|
|
146
148
|
});
|
|
147
|
-
}, [
|
|
148
|
-
const t =
|
|
149
|
+
}, [M]), Ie = O(() => {
|
|
150
|
+
const t = re();
|
|
149
151
|
if (!t.length) return;
|
|
150
|
-
const s =
|
|
151
|
-
|
|
152
|
-
}, [
|
|
153
|
-
const t =
|
|
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();
|
|
154
156
|
if (!t.length) return;
|
|
155
|
-
const s =
|
|
156
|
-
|
|
157
|
-
}, [
|
|
158
|
-
const t =
|
|
159
|
-
t.length &&
|
|
160
|
-
}, [
|
|
161
|
-
|
|
162
|
-
}, [
|
|
163
|
-
const t =
|
|
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;
|
|
164
166
|
if (!t) return !1;
|
|
165
|
-
const s =
|
|
166
|
-
return s ? s.onActivate ? (s.onActivate(), !0) : (setTimeout(() =>
|
|
167
|
-
}, [
|
|
168
|
-
|
|
169
|
-
const s = Array.from(
|
|
170
|
-
s.length &&
|
|
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]);
|
|
171
173
|
}, 20);
|
|
172
|
-
}, [
|
|
173
|
-
const t =
|
|
174
|
-
t !== null && (
|
|
175
|
-
}, [
|
|
176
|
-
const t =
|
|
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;
|
|
177
179
|
if (!t) return !1;
|
|
178
|
-
const s =
|
|
180
|
+
const s = w.current.get(t);
|
|
179
181
|
return s?.onActivate ? (s.onActivate(), !0) : !1;
|
|
180
182
|
}, []);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}, [
|
|
184
|
-
const
|
|
185
|
-
editor:
|
|
186
|
-
tokenRules:
|
|
187
|
-
singleLine:
|
|
188
|
-
disabled:
|
|
189
|
-
readonly:
|
|
190
|
-
placeholder:
|
|
191
|
-
search:
|
|
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,
|
|
192
194
|
documentText: $,
|
|
193
|
-
open:
|
|
194
|
-
setOpen:
|
|
195
|
-
openMenu:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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: {
|
|
215
219
|
position: "relative",
|
|
216
|
-
...
|
|
220
|
+
...h?.style
|
|
217
221
|
}, children: B }) }) }) });
|
|
218
|
-
},
|
|
219
|
-
const e =
|
|
220
|
-
editor:
|
|
222
|
+
}, yt = (n) => {
|
|
223
|
+
const e = ae.c(44), {
|
|
224
|
+
editor: i,
|
|
221
225
|
tokenRules: r,
|
|
222
|
-
singleLine:
|
|
223
|
-
disabled:
|
|
226
|
+
singleLine: l,
|
|
227
|
+
disabled: u,
|
|
224
228
|
readonly: d,
|
|
225
|
-
placeholder:
|
|
226
|
-
open:
|
|
227
|
-
openMenu:
|
|
228
|
-
setOpen:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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;
|
|
245
255
|
const {
|
|
246
|
-
text:
|
|
247
|
-
} =
|
|
248
|
-
return r.forEach((
|
|
249
|
-
if (
|
|
256
|
+
text: w
|
|
257
|
+
} = V;
|
|
258
|
+
return r.forEach((_, fe) => {
|
|
259
|
+
if (_.void)
|
|
250
260
|
return;
|
|
251
|
-
const
|
|
252
|
-
let
|
|
253
|
-
for (; (
|
|
254
|
-
|
|
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({
|
|
255
265
|
anchor: {
|
|
256
|
-
path:
|
|
257
|
-
offset:
|
|
266
|
+
path: A,
|
|
267
|
+
offset: M.index
|
|
258
268
|
},
|
|
259
269
|
focus: {
|
|
260
|
-
path:
|
|
261
|
-
offset:
|
|
270
|
+
path: A,
|
|
271
|
+
offset: M.index + M[0].length
|
|
262
272
|
},
|
|
263
|
-
tokenRuleIndex:
|
|
264
|
-
tokenText:
|
|
265
|
-
tokenMatch:
|
|
273
|
+
tokenRuleIndex: fe,
|
|
274
|
+
tokenText: M[0],
|
|
275
|
+
tokenMatch: M
|
|
266
276
|
});
|
|
267
|
-
}),
|
|
268
|
-
}, e[
|
|
269
|
-
const
|
|
270
|
-
let
|
|
271
|
-
e[
|
|
277
|
+
}), R;
|
|
278
|
+
}, e[4] = r, e[5] = K) : K = e[5];
|
|
279
|
+
const P = K;
|
|
280
|
+
let $;
|
|
281
|
+
e[6] !== r ? ($ = (a) => {
|
|
272
282
|
const {
|
|
273
|
-
attributes:
|
|
274
|
-
children:
|
|
275
|
-
leaf:
|
|
276
|
-
} =
|
|
277
|
-
if (
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
280
|
-
return
|
|
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 }) });
|
|
281
291
|
}
|
|
282
|
-
return /* @__PURE__ */
|
|
283
|
-
}, e[
|
|
284
|
-
const
|
|
285
|
-
let
|
|
286
|
-
e[
|
|
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) => {
|
|
287
297
|
const {
|
|
288
|
-
attributes:
|
|
289
|
-
children:
|
|
290
|
-
element:
|
|
291
|
-
} =
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
return /* @__PURE__ */
|
|
295
|
-
/* @__PURE__ */
|
|
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: {
|
|
296
306
|
userSelect: "none"
|
|
297
|
-
}, children:
|
|
298
|
-
|
|
307
|
+
}, children: _ }),
|
|
308
|
+
A
|
|
299
309
|
] });
|
|
300
310
|
}
|
|
301
|
-
return /* @__PURE__ */
|
|
311
|
+
return /* @__PURE__ */ v("div", { ...V, style: {
|
|
302
312
|
position: "relative"
|
|
303
|
-
}, children:
|
|
304
|
-
}, e[
|
|
305
|
-
const
|
|
306
|
-
let
|
|
307
|
-
e[
|
|
308
|
-
if (
|
|
309
|
-
|
|
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();
|
|
310
320
|
return;
|
|
311
321
|
}
|
|
312
|
-
if (
|
|
313
|
-
if (
|
|
314
|
-
|
|
322
|
+
if (f) {
|
|
323
|
+
if (a.key === "ArrowDown") {
|
|
324
|
+
a.preventDefault(), g();
|
|
315
325
|
return;
|
|
316
326
|
}
|
|
317
|
-
if (
|
|
318
|
-
|
|
327
|
+
if (a.key === "ArrowUp") {
|
|
328
|
+
a.preventDefault(), b();
|
|
319
329
|
return;
|
|
320
330
|
}
|
|
321
|
-
if (
|
|
322
|
-
|
|
331
|
+
if (a.key === "ArrowRight" && L()) {
|
|
332
|
+
a.preventDefault();
|
|
323
333
|
return;
|
|
324
334
|
}
|
|
325
|
-
if (
|
|
326
|
-
|
|
335
|
+
if (a.key === "ArrowLeft" && E !== null) {
|
|
336
|
+
a.preventDefault(), B();
|
|
327
337
|
return;
|
|
328
338
|
}
|
|
329
|
-
if (
|
|
330
|
-
|
|
339
|
+
if (a.key === "Enter") {
|
|
340
|
+
F() && a.preventDefault();
|
|
331
341
|
return;
|
|
332
342
|
}
|
|
333
|
-
if (
|
|
334
|
-
|
|
343
|
+
if (a.key === "Escape") {
|
|
344
|
+
a.preventDefault(), E !== null ? B() : S(!1);
|
|
335
345
|
return;
|
|
336
346
|
}
|
|
337
347
|
}
|
|
338
|
-
if ((
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
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, {
|
|
342
352
|
unit: "offset",
|
|
343
|
-
reverse:
|
|
353
|
+
reverse: V
|
|
344
354
|
});
|
|
345
|
-
const
|
|
346
|
-
if (
|
|
347
|
-
const
|
|
348
|
-
!
|
|
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, {
|
|
349
359
|
unit: "offset",
|
|
350
|
-
reverse:
|
|
360
|
+
reverse: V
|
|
351
361
|
});
|
|
352
362
|
}
|
|
353
363
|
}
|
|
354
|
-
}, e[
|
|
355
|
-
const
|
|
356
|
-
let
|
|
357
|
-
e[
|
|
358
|
-
const
|
|
359
|
-
let
|
|
360
|
-
e[
|
|
361
|
-
|
|
362
|
-
} : void 0, e[
|
|
363
|
-
let
|
|
364
|
-
e[
|
|
365
|
-
let
|
|
366
|
-
return e[
|
|
367
|
-
},
|
|
368
|
-
const e =
|
|
369
|
-
triggerRef:
|
|
370
|
-
} =
|
|
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();
|
|
371
381
|
let r;
|
|
372
|
-
e[0] !== n ? (r =
|
|
373
|
-
let
|
|
374
|
-
return e[2] !== r || e[3] !==
|
|
375
|
-
},
|
|
376
|
-
const e =
|
|
377
|
-
editor:
|
|
378
|
-
editorContainerRef: r
|
|
379
|
-
|
|
380
|
-
|
|
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;
|
|
381
392
|
e[0] !== n ? ({
|
|
382
|
-
children:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
let
|
|
390
|
-
e[
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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 = {
|
|
396
411
|
color: "primary",
|
|
397
412
|
align: "start",
|
|
398
413
|
sideOffset: 8,
|
|
399
|
-
onContextMenuCapture:
|
|
400
|
-
onCloseAutoFocus:
|
|
401
|
-
onOpenAutoFocus:
|
|
402
|
-
onFocusCapture:
|
|
403
|
-
onInteractOutside:
|
|
404
|
-
...
|
|
405
|
-
}, e[
|
|
406
|
-
const
|
|
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;
|
|
407
422
|
let b;
|
|
408
|
-
return e[
|
|
409
|
-
},
|
|
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) => {
|
|
410
425
|
const {
|
|
411
426
|
value: e,
|
|
412
|
-
data:
|
|
427
|
+
data: i,
|
|
413
428
|
children: r,
|
|
414
|
-
onlyOnce:
|
|
415
|
-
aliases:
|
|
429
|
+
onlyOnce: l,
|
|
430
|
+
aliases: u,
|
|
416
431
|
...d
|
|
417
432
|
} = n, {
|
|
418
|
-
editor:
|
|
419
|
-
registerItem:
|
|
420
|
-
activeId:
|
|
421
|
-
setActiveId:
|
|
422
|
-
select:
|
|
423
|
-
search:
|
|
424
|
-
documentText:
|
|
425
|
-
} =
|
|
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({
|
|
426
441
|
value: e,
|
|
427
|
-
data:
|
|
442
|
+
data: i
|
|
428
443
|
});
|
|
429
|
-
|
|
444
|
+
y.current = {
|
|
430
445
|
value: e,
|
|
431
|
-
data:
|
|
446
|
+
data: i
|
|
432
447
|
};
|
|
433
|
-
const
|
|
434
|
-
return
|
|
435
|
-
if (!
|
|
436
|
-
return
|
|
437
|
-
getValue: () =>
|
|
438
|
-
getData: () =>
|
|
439
|
-
el:
|
|
440
|
-
parentId:
|
|
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
|
|
441
456
|
});
|
|
442
|
-
}, [
|
|
443
|
-
|
|
444
|
-
}, textValue: "", "data-focus":
|
|
445
|
-
|
|
446
|
-
}, onPointerMove: (
|
|
447
|
-
|
|
448
|
-
}, onSelect: () => setTimeout(() =>
|
|
449
|
-
},
|
|
450
|
-
const e =
|
|
451
|
-
label:
|
|
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,
|
|
452
467
|
children: r
|
|
453
468
|
} = n, {
|
|
454
|
-
editor:
|
|
455
|
-
registerItem:
|
|
469
|
+
editor: l,
|
|
470
|
+
registerItem: u,
|
|
456
471
|
activeId: d,
|
|
457
|
-
setActiveId:
|
|
458
|
-
openSubId:
|
|
459
|
-
enterSub:
|
|
460
|
-
exitSub:
|
|
461
|
-
} =
|
|
462
|
-
let
|
|
463
|
-
e[0] !==
|
|
464
|
-
getValue:
|
|
465
|
-
getData:
|
|
466
|
-
el:
|
|
467
|
-
parentId:
|
|
468
|
-
onActivate: () =>
|
|
469
|
-
}),
|
|
470
|
-
let
|
|
471
|
-
e[6] !==
|
|
472
|
-
onOpenAutoFocus: (
|
|
473
|
-
|
|
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);
|
|
474
489
|
},
|
|
475
|
-
onFocusCapture: () =>
|
|
476
|
-
onCloseAutoFocus:
|
|
477
|
-
onFocusOutside:
|
|
478
|
-
onInteractOutside:
|
|
479
|
-
}, e[6] =
|
|
480
|
-
const
|
|
481
|
-
let
|
|
482
|
-
e[8] !==
|
|
483
|
-
|
|
484
|
-
}, e[8] =
|
|
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];
|
|
485
500
|
let B;
|
|
486
|
-
e[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (B = (
|
|
487
|
-
|
|
501
|
+
e[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (B = (m) => {
|
|
502
|
+
k.current = m;
|
|
488
503
|
}, e[13] = B) : B = e[13];
|
|
489
|
-
const
|
|
490
|
-
let
|
|
491
|
-
e[14] !==
|
|
492
|
-
|
|
493
|
-
}, e[14] =
|
|
494
|
-
let
|
|
495
|
-
e[18] !== d || e[19] !==
|
|
496
|
-
d !==
|
|
497
|
-
}, e[18] = d, e[19] =
|
|
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];
|
|
498
513
|
let K;
|
|
499
|
-
e[22] !==
|
|
500
|
-
let
|
|
501
|
-
e[27] !== r || e[28] !==
|
|
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];
|
|
502
517
|
let $;
|
|
503
|
-
e[30] !==
|
|
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];
|
|
504
519
|
let U;
|
|
505
|
-
return e[33] !== K || e[34] !== $ || e[35] !==
|
|
520
|
+
return e[33] !== K || e[34] !== $ || e[35] !== F || e[36] !== E ? (U = /* @__PURE__ */ Re(Qe, { open: F, onOpenChange: E, children: [
|
|
506
521
|
K,
|
|
507
522
|
$
|
|
508
|
-
] }), e[33] = K, e[34] = $, e[35] =
|
|
523
|
+
] }), e[33] = K, e[34] = $, e[35] = F, e[36] = E, e[37] = U) : U = e[37], U;
|
|
509
524
|
};
|
|
510
|
-
function
|
|
525
|
+
function Ye(n) {
|
|
511
526
|
return n.void;
|
|
512
527
|
}
|
|
513
|
-
function
|
|
528
|
+
function Ze(n) {
|
|
514
529
|
return n.preventDefault();
|
|
515
530
|
}
|
|
516
|
-
function
|
|
531
|
+
function et(n) {
|
|
517
532
|
return n.stopPropagation();
|
|
518
533
|
}
|
|
519
|
-
function
|
|
534
|
+
function tt(n) {
|
|
520
535
|
return n.preventDefault();
|
|
521
536
|
}
|
|
522
|
-
function
|
|
537
|
+
function nt() {
|
|
523
538
|
}
|
|
524
|
-
function
|
|
539
|
+
function rt() {
|
|
525
540
|
}
|
|
526
|
-
function
|
|
541
|
+
function ot(n) {
|
|
527
542
|
return n.preventDefault();
|
|
528
543
|
}
|
|
529
|
-
function
|
|
544
|
+
function st(n) {
|
|
530
545
|
return n.preventDefault();
|
|
531
546
|
}
|
|
532
|
-
function
|
|
547
|
+
function it(n) {
|
|
533
548
|
return n.preventDefault();
|
|
534
549
|
}
|
|
535
550
|
export {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
551
|
+
It as EditorInput,
|
|
552
|
+
bt as EditorInputMenu,
|
|
553
|
+
wt as EditorInputMenuItem,
|
|
554
|
+
Tt as EditorInputSubMenu,
|
|
555
|
+
Ct as EditorInputTrigger,
|
|
556
|
+
yt as EditorInputValue
|
|
542
557
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { EditorInputMenuProps, EditorInputSubMenuProps, EditorInputTriggerProps, EditorInputValueProps, EditorInputMenuItemProps } from './EditorInput';
|
|
2
|
+
import { EditorInputMenuProps, EditorInputSubMenuProps, EditorInputTriggerProps, EditorInputValueProps, EditorTokenRule, EditorInputMenuItemProps } from './EditorInput';
|
|
3
3
|
import { InputWrapperProps } from './InputWrapper';
|
|
4
4
|
import { ValidationProps } from './useForm';
|
|
5
5
|
export interface TagValue {
|
|
@@ -14,7 +14,14 @@ export interface TagSuggestion {
|
|
|
14
14
|
export interface TagInputProps extends Omit<InputWrapperProps, "onChange">, ValidationProps<any> {
|
|
15
15
|
allowCustomValues?: boolean;
|
|
16
16
|
onChange?: (tags: TagValue[]) => void;
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Defines how a tag is rendered as a chip inside the input. Each rule's
|
|
19
|
+
* `pattern` is matched against the tag's value; the first match decides the
|
|
20
|
+
* chip via its `wrap`/`style`/`className`. Tags with no matching rule fall
|
|
21
|
+
* back to a plain badge. The chip rendering is token-defined only — a menu
|
|
22
|
+
* item's `children` is never reused here.
|
|
23
|
+
*/
|
|
24
|
+
tokenRules?: EditorTokenRule[];
|
|
18
25
|
children?: React.ReactNode;
|
|
19
26
|
}
|
|
20
27
|
export type TagInputTriggerProps = EditorInputTriggerProps;
|
|
@@ -1,117 +1,124 @@
|
|
|
1
|
-
import { jsx as l
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { c as I } from "../../_virtual/compiler-runtime.js";
|
|
3
|
-
import
|
|
4
|
-
import { EditorInput as
|
|
3
|
+
import b, { useState as K, useRef as k, useReducer as j, useCallback as A, useEffect as v, useMemo as B, useContext as L } from "react";
|
|
4
|
+
import { EditorInput as U, EditorInputMenu as q, EditorInputMenuItem as z, EditorInputSubMenu as F, EditorInputTrigger as G, EditorInputValue as H } from "./EditorInput.js";
|
|
5
5
|
import { Badge as J } from "../badge/Badge.js";
|
|
6
|
-
import { Text as
|
|
7
|
-
const
|
|
6
|
+
import { Text as $ } from "../text/Text.js";
|
|
7
|
+
const E = "⟦", d = "⟧", R = new RegExp(`${E}([^${d}]+)${d}`, "g"), Q = new RegExp(`(${E}[^${d}]+${d})|([^${E}${d}]+)`, "g"), V = (t) => `${E}${String(t)}${d}`, W = (t) => t.slice(E.length, -d.length), y = (t) => t.map((e) => V(e.value)).join(""), X = (t) => t.replace(R, "").trim(), Y = (t, e) => {
|
|
8
8
|
let n = !1;
|
|
9
|
-
const r =
|
|
10
|
-
return n ? r : r +
|
|
11
|
-
},
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
9
|
+
const r = t.replace(Q, (a, o, c) => o || (!n && c.trim() ? (n = !0, e) : ""));
|
|
10
|
+
return n ? r : r + e;
|
|
11
|
+
}, _ = b.createContext(null), D = () => {
|
|
12
|
+
const t = L(_);
|
|
13
|
+
if (!t)
|
|
14
14
|
throw new Error("TagInput.* components must be used inside <TagInput>");
|
|
15
|
-
return
|
|
16
|
-
},
|
|
15
|
+
return t;
|
|
16
|
+
}, se = (t) => {
|
|
17
17
|
const {
|
|
18
|
-
allowCustomValues:
|
|
18
|
+
allowCustomValues: e = !1,
|
|
19
19
|
onChange: n,
|
|
20
20
|
formValidation: r,
|
|
21
|
-
|
|
21
|
+
tokenRules: a,
|
|
22
22
|
value: o,
|
|
23
23
|
initialValue: c,
|
|
24
|
-
defaultValue:
|
|
25
|
-
children:
|
|
26
|
-
...
|
|
27
|
-
} =
|
|
28
|
-
|
|
29
|
-
}, []),
|
|
30
|
-
const
|
|
31
|
-
const
|
|
24
|
+
defaultValue: T,
|
|
25
|
+
children: h,
|
|
26
|
+
...p
|
|
27
|
+
} = t, i = o ?? c ?? T, [g, C] = K(() => y(i ?? [])), M = k(/* @__PURE__ */ new Map()), [, N] = j((u) => u + 1, 0), O = A((u, s) => {
|
|
28
|
+
M.current.set(u, s), N();
|
|
29
|
+
}, []), x = k(i), S = (u) => {
|
|
30
|
+
const s = [...u.matchAll(R)].map(([, m]) => {
|
|
31
|
+
const f = M.current.get(m);
|
|
32
32
|
return {
|
|
33
|
-
value:
|
|
34
|
-
valueData:
|
|
33
|
+
value: f ? f.value : m,
|
|
34
|
+
valueData: f?.data
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
x.current = s, C(u), r?.setValue?.(s), n?.(s);
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, [
|
|
39
|
+
v(() => {
|
|
40
|
+
i !== x.current && (x.current = i, C(y(i ?? [])));
|
|
41
|
+
}, [i]);
|
|
42
42
|
const P = B(() => [{
|
|
43
|
-
pattern:
|
|
43
|
+
pattern: R,
|
|
44
44
|
void: !0,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
// The chip (input rendering) is defined by the token alone — the menu
|
|
46
|
+
// item's `children` is menu-only and must NOT be reused here. The tag's
|
|
47
|
+
// value is matched against the consumer's `tokenRules` to pick the chip.
|
|
48
|
+
wrap: (u) => {
|
|
49
|
+
const s = W(u), m = a?.find((f) => new RegExp(f.pattern.source, f.pattern.flags.replace("g", "")).test(s));
|
|
50
|
+
if (m?.wrap) {
|
|
51
|
+
const f = new RegExp(m.pattern.source, m.pattern.flags.replace("g", "")).exec(s);
|
|
52
|
+
return m.wrap(s, /* @__PURE__ */ l($, { children: s }), f ?? [s]);
|
|
53
|
+
}
|
|
54
|
+
return m ? /* @__PURE__ */ l("span", { style: m.style, className: m.className, children: /* @__PURE__ */ l($, { children: s }) }) : /* @__PURE__ */ l(J, { m: 0.01, children: /* @__PURE__ */ l($, { children: s }) });
|
|
48
55
|
}
|
|
49
|
-
}], [
|
|
50
|
-
search:
|
|
51
|
-
allowCustomValues:
|
|
52
|
-
insertToken: (
|
|
56
|
+
}], [a]), w = {
|
|
57
|
+
search: X(g),
|
|
58
|
+
allowCustomValues: e,
|
|
59
|
+
insertToken: (u) => S(Y(g, u)),
|
|
53
60
|
registerTag: O
|
|
54
61
|
};
|
|
55
|
-
return /* @__PURE__ */ l(
|
|
62
|
+
return /* @__PURE__ */ l(_.Provider, { value: w, children: /* @__PURE__ */ l(U, { ...p, value: g, search: w.search, tokenRules: P, formValidation: r && {
|
|
56
63
|
valid: r.valid,
|
|
57
64
|
notValidMessage: r.notValidMessage
|
|
58
|
-
}, onChange: S, onSelect: (
|
|
59
|
-
},
|
|
60
|
-
const
|
|
65
|
+
}, onChange: S, onSelect: (u) => w.insertToken(String(u)), children: h }) });
|
|
66
|
+
}, ae = (t) => {
|
|
67
|
+
const e = I.c(2);
|
|
61
68
|
let n;
|
|
62
|
-
return
|
|
63
|
-
},
|
|
64
|
-
const
|
|
69
|
+
return e[0] !== t ? (n = /* @__PURE__ */ l(q, { ...t }), e[0] = t, e[1] = n) : n = e[1], n;
|
|
70
|
+
}, ce = (t) => {
|
|
71
|
+
const e = I.c(2);
|
|
65
72
|
let n;
|
|
66
|
-
return
|
|
67
|
-
},
|
|
68
|
-
value:
|
|
69
|
-
data:
|
|
73
|
+
return e[0] !== t ? (n = /* @__PURE__ */ l(F, { ...t }), e[0] = t, e[1] = n) : n = e[1], n;
|
|
74
|
+
}, ue = ({
|
|
75
|
+
value: t,
|
|
76
|
+
data: e,
|
|
70
77
|
onlyOnce: n,
|
|
71
78
|
aliases: r,
|
|
72
|
-
children:
|
|
79
|
+
children: a
|
|
73
80
|
}) => {
|
|
74
81
|
const {
|
|
75
82
|
registerTag: o
|
|
76
|
-
} =
|
|
77
|
-
value:
|
|
78
|
-
data:
|
|
79
|
-
children:
|
|
83
|
+
} = D(), c = k({
|
|
84
|
+
value: t,
|
|
85
|
+
data: e,
|
|
86
|
+
children: a
|
|
80
87
|
});
|
|
81
|
-
return c.current.value =
|
|
82
|
-
},
|
|
83
|
-
const
|
|
88
|
+
return c.current.value = t, c.current.data = e, c.current.children = a, v(() => o(String(t), c.current), [t, o]), /* @__PURE__ */ l(z, { value: V(t), data: e, onlyOnce: n, aliases: [String(t), ...r ?? []], children: a });
|
|
89
|
+
}, le = (t) => {
|
|
90
|
+
const e = I.c(14);
|
|
84
91
|
let n, r;
|
|
85
|
-
|
|
92
|
+
e[0] !== t ? ({
|
|
86
93
|
onKeyDown: n,
|
|
87
94
|
...r
|
|
88
|
-
} =
|
|
95
|
+
} = t, e[0] = t, e[1] = n, e[2] = r) : (n = e[1], r = e[2]);
|
|
89
96
|
const {
|
|
90
|
-
search:
|
|
97
|
+
search: a,
|
|
91
98
|
allowCustomValues: o,
|
|
92
99
|
insertToken: c
|
|
93
|
-
} =
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
o &&
|
|
97
|
-
},
|
|
98
|
-
const
|
|
99
|
-
let
|
|
100
|
-
|
|
101
|
-
(
|
|
102
|
-
},
|
|
103
|
-
let
|
|
104
|
-
return
|
|
105
|
-
},
|
|
106
|
-
const
|
|
100
|
+
} = D();
|
|
101
|
+
let T;
|
|
102
|
+
e[3] !== o || e[4] !== c || e[5] !== a ? (T = () => {
|
|
103
|
+
o && a && c(V(a));
|
|
104
|
+
}, e[3] = o, e[4] = c, e[5] = a, e[6] = T) : T = e[6];
|
|
105
|
+
const h = T;
|
|
106
|
+
let p;
|
|
107
|
+
e[7] !== o || e[8] !== h || e[9] !== n ? (p = (g) => {
|
|
108
|
+
(g.key === "Enter" && !g.defaultPrevented || g.key === "," && o) && (g.preventDefault(), h()), n?.(g);
|
|
109
|
+
}, e[7] = o, e[8] = h, e[9] = n, e[10] = p) : p = e[10];
|
|
110
|
+
let i;
|
|
111
|
+
return e[11] !== r || e[12] !== p ? (i = /* @__PURE__ */ l(H, { ...r, onKeyDown: p }), e[11] = r, e[12] = p, e[13] = i) : i = e[13], i;
|
|
112
|
+
}, ie = (t) => {
|
|
113
|
+
const e = I.c(2);
|
|
107
114
|
let n;
|
|
108
|
-
return
|
|
115
|
+
return e[0] !== t ? (n = /* @__PURE__ */ l(G, { ...t }), e[0] = t, e[1] = n) : n = e[1], n;
|
|
109
116
|
};
|
|
110
117
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
se as TagInput,
|
|
119
|
+
ae as TagInputMenu,
|
|
120
|
+
ue as TagInputMenuItem,
|
|
121
|
+
ce as TagInputSubMenu,
|
|
122
|
+
ie as TagInputTrigger,
|
|
123
|
+
le as TagInputValue
|
|
117
124
|
};
|