cosmic-ai-input 1.0.13 → 1.0.15
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/index.cjs.js +6 -6
- package/dist/index.es.js +380 -363
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
// Generated at: 2026-
|
|
2
|
-
import { jsx as u, jsxs as
|
|
3
|
-
import { forwardRef as j, useState as L, useRef as
|
|
4
|
-
import
|
|
5
|
-
import { createPortal as
|
|
1
|
+
// Generated at: 2026-04-03T02:03:21.169Z
|
|
2
|
+
import { jsx as u, jsxs as te } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as j, useState as L, useRef as O, useEffect as M, useCallback as Pe, useImperativeHandle as ot } from "react";
|
|
4
|
+
import De from "classnames";
|
|
5
|
+
import { createPortal as st } from "react-dom";
|
|
6
6
|
var h = /* @__PURE__ */ ((r) => (r.INPUT = "input", r.SELECT = "select", r.MULTIPLE_SELECT = "multiple-select", r.DATE_PICKER = "date-picker", r.LABEL = "label", r))(h || {});
|
|
7
7
|
const $e = j(
|
|
8
8
|
({ value: r, position: s, id: o, onChange: f }, k) => {
|
|
9
|
-
const [
|
|
9
|
+
const [C, E] = L(!0), $ = O(null), N = O(null);
|
|
10
10
|
M(() => {
|
|
11
11
|
typeof k == "function" ? k($.current) : k && (k.current = $.current);
|
|
12
12
|
}, [k]);
|
|
13
13
|
const T = (p) => {
|
|
14
|
-
const
|
|
15
|
-
f == null || f(
|
|
14
|
+
const g = p.target.value;
|
|
15
|
+
f == null || f(g, h.DATE_PICKER);
|
|
16
16
|
};
|
|
17
17
|
M(() => {
|
|
18
|
-
if (
|
|
18
|
+
if (N.current)
|
|
19
19
|
try {
|
|
20
20
|
setTimeout(() => {
|
|
21
|
-
|
|
21
|
+
S();
|
|
22
22
|
}, 100);
|
|
23
23
|
} catch {
|
|
24
24
|
}
|
|
25
25
|
}, []);
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
26
|
+
const S = () => {
|
|
27
|
+
if (N.current)
|
|
28
28
|
try {
|
|
29
|
-
|
|
29
|
+
N.current.showPicker();
|
|
30
30
|
} catch {
|
|
31
31
|
}
|
|
32
32
|
}, A = (p) => {
|
|
33
33
|
p.stopPropagation();
|
|
34
34
|
};
|
|
35
|
-
return
|
|
35
|
+
return C ? /* @__PURE__ */ u(
|
|
36
36
|
"div",
|
|
37
37
|
{
|
|
38
38
|
ref: $,
|
|
@@ -46,7 +46,7 @@ const $e = j(
|
|
|
46
46
|
children: /* @__PURE__ */ u(
|
|
47
47
|
"input",
|
|
48
48
|
{
|
|
49
|
-
ref:
|
|
49
|
+
ref: N,
|
|
50
50
|
type: "date",
|
|
51
51
|
value: r || "",
|
|
52
52
|
onChange: T,
|
|
@@ -58,11 +58,11 @@ const $e = j(
|
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
$e.displayName = "DatePicker";
|
|
61
|
-
function
|
|
61
|
+
function he(r) {
|
|
62
62
|
const s = r.textContent || "", o = r.nextSibling;
|
|
63
63
|
s.length ? (o == null || o.setAttribute("style", "display: none"), r.style.padding = "2px 4px", r.style.borderTopLeftRadius = "2px", r.style.borderBottomLeftRadius = "2px", r.style.borderTopRightRadius = "2px", r.style.borderBottomRightRadius = "2px") : (o == null || o.setAttribute("style", "display: inline"), r.style.padding = "2px 0 2px 4px", r.style.borderTopLeftRadius = "2px", r.style.borderBottomLeftRadius = "2px", r.style.borderTopRightRadius = "0", r.style.borderBottomRightRadius = "0");
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function q(r) {
|
|
66
66
|
if (r && r.getAttribute("data-set-type") === "input") {
|
|
67
67
|
const s = r.children[0];
|
|
68
68
|
s.setAttribute("contenteditable", "true"), requestAnimationFrame(() => {
|
|
@@ -70,7 +70,7 @@ function V(r) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function Se(r) {
|
|
74
74
|
r && r.getAttribute("data-set-type") === "input" && r.children[0].setAttribute("contenteditable", "false");
|
|
75
75
|
}
|
|
76
76
|
function _(r) {
|
|
@@ -82,16 +82,16 @@ const Be = j(({
|
|
|
82
82
|
position: o,
|
|
83
83
|
id: f,
|
|
84
84
|
height: k = 37,
|
|
85
|
-
onChange:
|
|
86
|
-
},
|
|
87
|
-
const [$,
|
|
85
|
+
onChange: C
|
|
86
|
+
}, E) => {
|
|
87
|
+
const [$, N] = L(s || ""), T = O(null);
|
|
88
88
|
M(() => {
|
|
89
|
-
typeof
|
|
90
|
-
}, [
|
|
91
|
-
const
|
|
92
|
-
const
|
|
89
|
+
typeof E == "function" ? E(T.current) : E && (E.current = T.current);
|
|
90
|
+
}, [E]);
|
|
91
|
+
const S = (p) => {
|
|
92
|
+
const g = $.split(",").filter((y) => y) || [];
|
|
93
93
|
let b = "";
|
|
94
|
-
|
|
94
|
+
g.includes(p) ? b = g.filter((y) => y !== p).join(",") : g.length ? b = `${g.join(",")},${p}` : b = p, N(b), C == null || C(b, h.MULTIPLE_SELECT);
|
|
95
95
|
}, A = $.split(",") || [];
|
|
96
96
|
return /* @__PURE__ */ u(
|
|
97
97
|
"div",
|
|
@@ -106,14 +106,14 @@ const Be = j(({
|
|
|
106
106
|
zIndex: 5e3,
|
|
107
107
|
maxHeight: `${k}px`
|
|
108
108
|
},
|
|
109
|
-
children: r.map((p,
|
|
109
|
+
children: r.map((p, g) => /* @__PURE__ */ u(
|
|
110
110
|
"div",
|
|
111
111
|
{
|
|
112
112
|
className: `selectOption ${A.includes(p) ? "selected" : ""}`,
|
|
113
|
-
onClick: () =>
|
|
113
|
+
onClick: () => S(p),
|
|
114
114
|
children: p
|
|
115
115
|
},
|
|
116
|
-
|
|
116
|
+
g
|
|
117
117
|
))
|
|
118
118
|
}
|
|
119
119
|
);
|
|
@@ -125,14 +125,14 @@ const Me = j(({
|
|
|
125
125
|
position: o,
|
|
126
126
|
id: f,
|
|
127
127
|
height: k = 120,
|
|
128
|
-
onChange:
|
|
129
|
-
},
|
|
130
|
-
const [$,
|
|
128
|
+
onChange: C
|
|
129
|
+
}, E) => {
|
|
130
|
+
const [$, N] = L(s || ""), T = O(null);
|
|
131
131
|
M(() => {
|
|
132
|
-
typeof
|
|
133
|
-
}, [
|
|
134
|
-
const
|
|
135
|
-
|
|
132
|
+
typeof E == "function" ? E(T.current) : E && (E.current = T.current);
|
|
133
|
+
}, [E]);
|
|
134
|
+
const S = (A) => {
|
|
135
|
+
N(A), C == null || C(A, h.SELECT);
|
|
136
136
|
};
|
|
137
137
|
return /* @__PURE__ */ u(
|
|
138
138
|
"div",
|
|
@@ -151,7 +151,7 @@ const Me = j(({
|
|
|
151
151
|
"div",
|
|
152
152
|
{
|
|
153
153
|
className: `selectOption ${$ === A ? "selected" : ""}`,
|
|
154
|
-
onClick: () =>
|
|
154
|
+
onClick: () => S(A),
|
|
155
155
|
children: A
|
|
156
156
|
},
|
|
157
157
|
p
|
|
@@ -160,23 +160,23 @@ const Me = j(({
|
|
|
160
160
|
);
|
|
161
161
|
});
|
|
162
162
|
Me.displayName = "Select";
|
|
163
|
-
function
|
|
163
|
+
function Ne(r) {
|
|
164
164
|
const s = r instanceof Element ? r : document.getElementById(r);
|
|
165
165
|
return s && s.children[0].textContent || "";
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function ct(r, s) {
|
|
168
168
|
const o = r instanceof Element ? r : document.getElementById(r);
|
|
169
169
|
o && (o.children[0].textContent = s);
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function ne(r) {
|
|
172
172
|
const s = document.createRange(), o = window.getSelection();
|
|
173
173
|
o && (!r || !(r instanceof Node) || (s.selectNodeContents(r), s.collapse(!0), o.removeAllRanges(), o.addRange(s)));
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function v(r) {
|
|
176
176
|
const s = document.createRange(), o = window.getSelection();
|
|
177
177
|
o && (!r || !(r instanceof Node) || (s.selectNodeContents(r), s.collapse(!1), o.removeAllRanges(), o.addRange(s)));
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function ge(r) {
|
|
180
180
|
const s = window.getSelection();
|
|
181
181
|
if (!s || s.rangeCount === 0)
|
|
182
182
|
return 0;
|
|
@@ -185,37 +185,37 @@ function pe(r) {
|
|
|
185
185
|
const o = s.getRangeAt(0), f = o.cloneRange();
|
|
186
186
|
return f.selectNodeContents(r), f.setEnd(o.startContainer, o.startOffset), f.toString().length;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function at() {
|
|
189
189
|
const r = window.getSelection();
|
|
190
190
|
if (!r || r.rangeCount === 0)
|
|
191
191
|
return null;
|
|
192
192
|
const o = r.getRangeAt(0).startContainer;
|
|
193
193
|
return o.nodeType === Node.TEXT_NODE ? o.parentElement : o.nodeType === Node.ELEMENT_NODE ? o : null;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function dt() {
|
|
196
196
|
const r = window.getSelection();
|
|
197
197
|
return !r || r.rangeCount === 0 ? null : r.getRangeAt(0).getBoundingClientRect();
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function ut() {
|
|
200
200
|
return new Promise((r) => {
|
|
201
201
|
requestAnimationFrame(() => {
|
|
202
|
-
r(
|
|
202
|
+
r(dt());
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function ft() {
|
|
207
207
|
const r = window.getSelection();
|
|
208
208
|
if (!r || r.rangeCount === 0) return null;
|
|
209
209
|
const s = r.getRangeAt(0), o = s.startContainer, f = s.startOffset;
|
|
210
210
|
return o.nodeType === Node.TEXT_NODE ? f > 0 ? o : o.previousSibling : o.nodeType === Node.ELEMENT_NODE ? f > 0 ? o.childNodes[f - 1] : o.previousSibling : null;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function pt() {
|
|
213
213
|
const r = window.getSelection();
|
|
214
214
|
if (!r || r.rangeCount === 0) return null;
|
|
215
215
|
const s = r.getRangeAt(0), o = s.startContainer, f = s.startOffset;
|
|
216
216
|
return o.nodeType === Node.TEXT_NODE ? f < o.length ? o : o.nextSibling : o.nodeType === Node.ELEMENT_NODE ? f < o.childNodes.length ? o.childNodes[f] : o.nextSibling : null;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function ht(r) {
|
|
219
219
|
return r && !r.getAttribute("data-set-type");
|
|
220
220
|
}
|
|
221
221
|
function ke() {
|
|
@@ -227,28 +227,28 @@ const He = j(({
|
|
|
227
227
|
position: o,
|
|
228
228
|
id: f,
|
|
229
229
|
height: k = 120,
|
|
230
|
-
onChange:
|
|
231
|
-
},
|
|
232
|
-
const [$,
|
|
233
|
-
|
|
234
|
-
}, [
|
|
230
|
+
onChange: C
|
|
231
|
+
}, E) => {
|
|
232
|
+
const [$, N] = L(s || ""), [T, S] = L(0), A = O(null), p = O(T), g = Pe((b) => {
|
|
233
|
+
N(b), C == null || C(b, h.LABEL);
|
|
234
|
+
}, [C]);
|
|
235
235
|
return M(() => {
|
|
236
|
-
typeof
|
|
237
|
-
}, [
|
|
236
|
+
typeof E == "function" ? E(A.current) : E && (E.current = A.current);
|
|
237
|
+
}, [E]), M(() => {
|
|
238
238
|
p.current = T;
|
|
239
239
|
}, [T]), M(() => {
|
|
240
|
-
|
|
240
|
+
S(0);
|
|
241
241
|
}, [r]), M(() => {
|
|
242
|
-
const b = (
|
|
243
|
-
r.length !== 0 && (
|
|
244
|
-
const
|
|
245
|
-
|
|
242
|
+
const b = (y) => {
|
|
243
|
+
r.length !== 0 && (y.key === "ArrowDown" ? (y.preventDefault(), S((m) => m < r.length - 1 ? m + 1 : m)) : y.key === "ArrowUp" ? (y.preventDefault(), S((m) => m > 0 ? m - 1 : m)) : y.key === "Enter" && (y.preventDefault(), setTimeout(() => {
|
|
244
|
+
const m = p.current;
|
|
245
|
+
m >= 0 && r[m] && g(r[m]);
|
|
246
246
|
}, 0)));
|
|
247
247
|
};
|
|
248
248
|
return document.addEventListener("keydown", b), () => {
|
|
249
249
|
document.removeEventListener("keydown", b);
|
|
250
250
|
};
|
|
251
|
-
}, [r,
|
|
251
|
+
}, [r, g]), /* @__PURE__ */ u(
|
|
252
252
|
"div",
|
|
253
253
|
{
|
|
254
254
|
ref: A,
|
|
@@ -261,56 +261,56 @@ const He = j(({
|
|
|
261
261
|
zIndex: 5e3,
|
|
262
262
|
maxHeight: `${k}px`
|
|
263
263
|
},
|
|
264
|
-
children: r.length > 0 && r.map((b,
|
|
264
|
+
children: r.length > 0 && r.map((b, y) => /* @__PURE__ */ u(
|
|
265
265
|
"div",
|
|
266
266
|
{
|
|
267
|
-
className: `selectOption ${$ === b ? "selected" : ""} ${T ===
|
|
268
|
-
onClick: () =>
|
|
269
|
-
onMouseEnter: () =>
|
|
267
|
+
className: `selectOption ${$ === b ? "selected" : ""} ${T === y ? "highlighted" : ""}`,
|
|
268
|
+
onClick: () => g(b),
|
|
269
|
+
onMouseEnter: () => S(y),
|
|
270
270
|
children: b
|
|
271
271
|
},
|
|
272
|
-
|
|
272
|
+
y
|
|
273
273
|
))
|
|
274
274
|
}
|
|
275
275
|
);
|
|
276
276
|
});
|
|
277
277
|
He.displayName = "Mention";
|
|
278
|
-
const
|
|
278
|
+
const gt = j((r, s) => {
|
|
279
279
|
const {
|
|
280
280
|
value: o = "",
|
|
281
281
|
varList: f,
|
|
282
282
|
placeholder: k = "",
|
|
283
|
-
maxLength:
|
|
284
|
-
defaultRows:
|
|
283
|
+
maxLength: C,
|
|
284
|
+
defaultRows: E = 3,
|
|
285
285
|
disabled: $ = !1,
|
|
286
|
-
defaultFocus:
|
|
286
|
+
defaultFocus: N = !1,
|
|
287
287
|
textIndex: T = 0,
|
|
288
|
-
mentions:
|
|
288
|
+
mentions: S = [],
|
|
289
289
|
onFocus: A,
|
|
290
290
|
onBlur: p,
|
|
291
|
-
onChange:
|
|
291
|
+
onChange: g,
|
|
292
292
|
onClick: b,
|
|
293
|
-
onSend:
|
|
294
|
-
onKeyDown:
|
|
293
|
+
onSend: y,
|
|
294
|
+
onKeyDown: m,
|
|
295
295
|
onKeyUp: K,
|
|
296
|
-
onMaxLengthExceeded:
|
|
297
|
-
} = r, [
|
|
298
|
-
var i,
|
|
299
|
-
let
|
|
300
|
-
return
|
|
301
|
-
` && (
|
|
302
|
-
},
|
|
296
|
+
onMaxLengthExceeded: ie
|
|
297
|
+
} = r, [Et, yt] = L(o || ""), [re, X] = L(""), [bt, le] = L(""), [U, F] = L(!1), [G, W] = L({ top: 0, left: 0 }), [oe, se] = L([]), [J, Ee] = L(""), [w, ce] = L(null), [ae, Q] = L(120), [ye, be] = L(N), we = 240, Ce = 240, Ae = 240, me = 276, x = O(null), R = O(null), B = O(null), Z = O(!1), V = () => {
|
|
298
|
+
var i, t;
|
|
299
|
+
let e = ((t = (i = x.current) == null ? void 0 : i.innerText) == null ? void 0 : t.replace(/\u200B/g, "")) || "";
|
|
300
|
+
return e === `
|
|
301
|
+
` && (e = ""), e;
|
|
302
|
+
}, de = () => {
|
|
303
303
|
var i;
|
|
304
|
-
let
|
|
305
|
-
return
|
|
306
|
-
},
|
|
304
|
+
let e = ((i = x.current) == null ? void 0 : i.innerHTML) || "";
|
|
305
|
+
return e === "<br>" && (e = ""), e;
|
|
306
|
+
}, Oe = (e) => {
|
|
307
307
|
const i = [];
|
|
308
|
-
let
|
|
308
|
+
let t = 0;
|
|
309
309
|
const l = /\[([^\]]+)\]/g;
|
|
310
310
|
let c;
|
|
311
311
|
const a = ke();
|
|
312
312
|
let d = 0;
|
|
313
|
-
if (
|
|
313
|
+
if (e === "" || !e || e === `
|
|
314
314
|
`)
|
|
315
315
|
return [
|
|
316
316
|
{
|
|
@@ -319,429 +319,445 @@ const ht = j((r, s) => {
|
|
|
319
319
|
id: `text-${d++}-${a}`
|
|
320
320
|
}
|
|
321
321
|
];
|
|
322
|
-
const P = new Set((f || []).map((
|
|
323
|
-
for (; (c = l.exec(
|
|
324
|
-
if (c.index >
|
|
325
|
-
const H =
|
|
322
|
+
const P = new Set((f || []).map((D) => D.name));
|
|
323
|
+
for (; (c = l.exec(e)) !== null; ) {
|
|
324
|
+
if (c.index > t) {
|
|
325
|
+
const H = e.substring(t, c.index).split(`
|
|
326
326
|
`);
|
|
327
|
-
H.forEach((
|
|
328
|
-
|
|
327
|
+
H.forEach((ee, lt) => {
|
|
328
|
+
ee && i.push({
|
|
329
329
|
type: "text",
|
|
330
|
-
content:
|
|
330
|
+
content: ee,
|
|
331
331
|
id: `text-${d++}-${a}`
|
|
332
|
-
}),
|
|
332
|
+
}), lt < H.length - 1 && i.push({
|
|
333
333
|
type: "newline",
|
|
334
334
|
id: `newline-${d++}-${a}`
|
|
335
335
|
});
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
|
-
const
|
|
339
|
-
if (P.has(
|
|
340
|
-
const
|
|
341
|
-
(
|
|
338
|
+
const D = c[1];
|
|
339
|
+
if (P.has(D)) {
|
|
340
|
+
const n = f.find((H) => H.name === D);
|
|
341
|
+
(n == null ? void 0 : n.type) === "input" ? i.push({
|
|
342
342
|
type: "input",
|
|
343
|
-
name:
|
|
344
|
-
content: (
|
|
345
|
-
placeholder: (
|
|
343
|
+
name: n == null ? void 0 : n.name,
|
|
344
|
+
content: (n == null ? void 0 : n.content) || "",
|
|
345
|
+
placeholder: (n == null ? void 0 : n.placeholder) || D,
|
|
346
346
|
id: `input-${d++}-${a}`
|
|
347
|
-
}) : (
|
|
347
|
+
}) : (n == null ? void 0 : n.type) === "label" ? i.push({
|
|
348
348
|
type: "label",
|
|
349
|
-
name:
|
|
350
|
-
content: (
|
|
349
|
+
name: n == null ? void 0 : n.name,
|
|
350
|
+
content: (n == null ? void 0 : n.content) || "",
|
|
351
351
|
id: `label-${d++}-${a}`
|
|
352
|
-
}) : (
|
|
352
|
+
}) : (n == null ? void 0 : n.type) === "select" ? i.push({
|
|
353
353
|
type: "select",
|
|
354
|
-
name:
|
|
355
|
-
content: (
|
|
356
|
-
placeholder: (
|
|
357
|
-
options: (
|
|
354
|
+
name: n == null ? void 0 : n.name,
|
|
355
|
+
content: (n == null ? void 0 : n.content) || "",
|
|
356
|
+
placeholder: (n == null ? void 0 : n.placeholder) || D,
|
|
357
|
+
options: (n == null ? void 0 : n.options) || [],
|
|
358
358
|
id: `select-${d++}-${a}`
|
|
359
|
-
}) : (
|
|
359
|
+
}) : (n == null ? void 0 : n.type) === "multiple-select" ? i.push({
|
|
360
360
|
type: "multiple-select",
|
|
361
|
-
name:
|
|
362
|
-
content: (
|
|
363
|
-
placeholder: (
|
|
364
|
-
options: (
|
|
361
|
+
name: n == null ? void 0 : n.name,
|
|
362
|
+
content: (n == null ? void 0 : n.content) || "",
|
|
363
|
+
placeholder: (n == null ? void 0 : n.placeholder) || D,
|
|
364
|
+
options: (n == null ? void 0 : n.options) || [],
|
|
365
365
|
id: `multiple-select-${d++}-${a}`
|
|
366
|
-
}) : (
|
|
366
|
+
}) : (n == null ? void 0 : n.type) === "date-picker" && i.push({
|
|
367
367
|
type: "date-picker",
|
|
368
|
-
name:
|
|
369
|
-
content: (
|
|
370
|
-
placeholder: (
|
|
368
|
+
name: n == null ? void 0 : n.name,
|
|
369
|
+
content: (n == null ? void 0 : n.content) || "",
|
|
370
|
+
placeholder: (n == null ? void 0 : n.placeholder) || D,
|
|
371
371
|
id: `date-picker-${d++}-${a}`
|
|
372
372
|
});
|
|
373
373
|
} else
|
|
374
374
|
i.push({
|
|
375
375
|
type: "text",
|
|
376
|
-
content: `[${
|
|
376
|
+
content: `[${D}]`,
|
|
377
377
|
id: `text-${d++}-${a}`
|
|
378
378
|
});
|
|
379
|
-
|
|
379
|
+
t = l.lastIndex;
|
|
380
380
|
}
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
381
|
+
if (t < e.length) {
|
|
382
|
+
const n = e.substring(t).split(`
|
|
383
383
|
`);
|
|
384
|
-
|
|
384
|
+
n.forEach((H, ee) => {
|
|
385
385
|
H && i.push({
|
|
386
386
|
type: "text",
|
|
387
387
|
content: H,
|
|
388
388
|
id: `text-${d++}`
|
|
389
|
-
}),
|
|
389
|
+
}), ee < n.length - 1 && i.push({
|
|
390
390
|
type: "newline",
|
|
391
391
|
id: `newline-${d++}`
|
|
392
392
|
});
|
|
393
393
|
});
|
|
394
394
|
}
|
|
395
395
|
return i;
|
|
396
|
-
},
|
|
397
|
-
var
|
|
398
|
-
(
|
|
396
|
+
}, ue = () => {
|
|
397
|
+
var e;
|
|
398
|
+
(e = x.current) == null || e.setAttribute("contenteditable", "true"), R.current && (_(R.current) && R.current.children[0].setAttribute(
|
|
399
399
|
"contenteditable",
|
|
400
400
|
"false"
|
|
401
|
-
), R.current = null),
|
|
402
|
-
},
|
|
403
|
-
b == null || b(
|
|
404
|
-
}, Ve = (
|
|
405
|
-
|
|
406
|
-
}, z = (
|
|
407
|
-
|
|
408
|
-
}, qe = (
|
|
401
|
+
), R.current = null), v(x.current);
|
|
402
|
+
}, Fe = (e) => {
|
|
403
|
+
b == null || b(e);
|
|
404
|
+
}, Ve = (e) => {
|
|
405
|
+
ue();
|
|
406
|
+
}, z = (e) => {
|
|
407
|
+
Z.current || (X(V()), le(de()), g == null || g(V()), tt(e));
|
|
408
|
+
}, qe = (e) => {
|
|
409
409
|
var i;
|
|
410
|
-
if (!
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
if (
|
|
410
|
+
if (!Z.current && e.code === "Enter" && !e.shiftKey) {
|
|
411
|
+
e.preventDefault();
|
|
412
|
+
const t = V();
|
|
413
|
+
if (t.length === 0 || (i = x.current) != null && i.innerHTML.match(
|
|
414
414
|
/^<span>[\s\u200B]*(<br\s*\/?>[\s\u200B]*)+<\/span>$/
|
|
415
415
|
))
|
|
416
416
|
return;
|
|
417
|
-
|
|
417
|
+
C ? t.length <= C ? y == null || y(t) : ie == null || ie(t, C) : y == null || y(t);
|
|
418
418
|
}
|
|
419
|
-
},
|
|
420
|
-
var
|
|
421
|
-
if (U && (
|
|
422
|
-
|
|
419
|
+
}, ve = (e) => {
|
|
420
|
+
var t;
|
|
421
|
+
if (U && (w == null ? void 0 : w.type) === h.LABEL && (e.code === "ArrowUp" || e.code === "ArrowDown" || e.code === "Enter")) {
|
|
422
|
+
e.preventDefault();
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
|
|
426
|
-
const i =
|
|
427
|
-
if (i &&
|
|
428
|
-
if (
|
|
429
|
-
const l = i == null ? void 0 : i.previousElementSibling, c =
|
|
430
|
-
l && c === 0 && _(l) && l.children[0] && (R.current = l,
|
|
431
|
-
|
|
425
|
+
F(!1), m == null || m(e);
|
|
426
|
+
const i = at();
|
|
427
|
+
if (i && ht(i)) {
|
|
428
|
+
if (e.code === "ArrowLeft") {
|
|
429
|
+
const l = i == null ? void 0 : i.previousElementSibling, c = ge(i);
|
|
430
|
+
l && c === 0 && _(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
|
|
431
|
+
v(l.children[0]);
|
|
432
432
|
}));
|
|
433
433
|
}
|
|
434
|
-
if (
|
|
435
|
-
const l = i == null ? void 0 : i.nextElementSibling, c =
|
|
436
|
-
l && c === ((
|
|
437
|
-
|
|
434
|
+
if (e.code === "ArrowRight") {
|
|
435
|
+
const l = i == null ? void 0 : i.nextElementSibling, c = ge(i);
|
|
436
|
+
l && c === ((t = i.textContent) == null ? void 0 : t.length) && _(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
|
|
437
|
+
ne(l.children[0]);
|
|
438
438
|
}));
|
|
439
439
|
}
|
|
440
|
-
|
|
440
|
+
e.code === "Backspace" && (i.innerHTML === "" && e.preventDefault(), i.innerHTML === "<br>" && (e.preventDefault(), i.innerHTML = ""));
|
|
441
|
+
}
|
|
442
|
+
if (e.code === "Backspace" && e.target) {
|
|
443
|
+
const l = e.target;
|
|
444
|
+
if (l.childElementCount === 1 && l.children[0].tagName === "SPAN") {
|
|
445
|
+
const c = l.children[0];
|
|
446
|
+
l.childNodes.length === 1 && (c.innerHTML === "" && e.preventDefault(), c.innerHTML === "<br>" && (e.preventDefault(), c.innerHTML = ""));
|
|
447
|
+
}
|
|
441
448
|
}
|
|
442
449
|
if (i && i.getAttribute("data-set-type") === "container") {
|
|
443
|
-
if (
|
|
444
|
-
const l =
|
|
445
|
-
_(l) && l.children[0] && (R.current = l,
|
|
446
|
-
|
|
450
|
+
if (e.code === "ArrowLeft") {
|
|
451
|
+
const l = ft();
|
|
452
|
+
_(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
|
|
453
|
+
v(l.children[0]);
|
|
447
454
|
}));
|
|
448
455
|
}
|
|
449
|
-
if (
|
|
450
|
-
const l =
|
|
451
|
-
_(l) && l.children[0] && (R.current = l,
|
|
452
|
-
|
|
456
|
+
if (e.code === "ArrowRight") {
|
|
457
|
+
const l = pt();
|
|
458
|
+
_(l) && l.children[0] && (R.current = l, q(l), requestAnimationFrame(() => {
|
|
459
|
+
ne(l.children[0]);
|
|
453
460
|
}));
|
|
454
461
|
}
|
|
455
462
|
}
|
|
456
|
-
qe(
|
|
457
|
-
},
|
|
458
|
-
if (U && (
|
|
459
|
-
|
|
463
|
+
qe(e);
|
|
464
|
+
}, _e = (e) => {
|
|
465
|
+
if (U && (w == null ? void 0 : w.type) === h.LABEL && (e.code === "ArrowUp" || e.code === "ArrowDown" || e.code === "Enter")) {
|
|
466
|
+
e.preventDefault();
|
|
460
467
|
return;
|
|
461
468
|
}
|
|
462
|
-
K == null || K(
|
|
463
|
-
},
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
469
|
+
K == null || K(e);
|
|
470
|
+
}, Ke = (e) => {
|
|
471
|
+
const t = e.clipboardData.items;
|
|
472
|
+
for (let l = 0; l < t.length; l++)
|
|
473
|
+
if (t[l].type.indexOf("image") !== -1) {
|
|
474
|
+
e.preventDefault();
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
}, Ue = (e) => {
|
|
478
|
+
e.preventDefault();
|
|
479
|
+
const t = window.getSelection().toString();
|
|
480
|
+
if (!t) return;
|
|
481
|
+
const l = t.replace(/\u200B/g, "") || "", c = t.replace(/\u200B/g, "") || "";
|
|
482
|
+
e.clipboardData.setData("text/plain", l), e.clipboardData.setData("text/html", c);
|
|
483
|
+
}, We = (e) => {
|
|
484
|
+
A == null || A(e);
|
|
473
485
|
}, ze = () => {
|
|
474
|
-
|
|
475
|
-
}, je = (
|
|
486
|
+
Z.current = !0;
|
|
487
|
+
}, je = () => {
|
|
488
|
+
setTimeout(() => {
|
|
489
|
+
Z.current = !1, X(V()), le(de()), g == null || g(V());
|
|
490
|
+
}, 0);
|
|
491
|
+
}, Xe = (e, i) => {
|
|
476
492
|
i.stopPropagation();
|
|
477
|
-
},
|
|
493
|
+
}, Ge = (e, i) => {
|
|
478
494
|
var l;
|
|
479
|
-
i.stopPropagation(), R.current &&
|
|
480
|
-
const
|
|
481
|
-
R.current =
|
|
482
|
-
|
|
495
|
+
i.stopPropagation(), R.current && Se(R.current), (l = x.current) == null || l.setAttribute("contenteditable", "false");
|
|
496
|
+
const t = document.getElementById(e.id);
|
|
497
|
+
R.current = t, requestAnimationFrame(() => {
|
|
498
|
+
q(t);
|
|
483
499
|
});
|
|
484
|
-
},
|
|
485
|
-
var c, a, d, P,
|
|
486
|
-
|
|
487
|
-
const
|
|
500
|
+
}, Je = (e, i) => {
|
|
501
|
+
var c, a, d, P, D;
|
|
502
|
+
m == null || m(i), i.stopPropagation();
|
|
503
|
+
const t = i.target, l = ge(t);
|
|
488
504
|
if (i.code === "Backspace" && l === 0) {
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
})) : (
|
|
505
|
+
const n = (c = t.parentElement) == null ? void 0 : c.previousElementSibling;
|
|
506
|
+
n && (_(n) && n.children[0] && ((a = n.children[0].textContent) != null && a.length) ? (R.current = n, q(n), v(n.children[0]), requestAnimationFrame(() => {
|
|
507
|
+
he(n.children[0]);
|
|
508
|
+
})) : (ue(), v(n)));
|
|
493
509
|
}
|
|
494
|
-
if (i.code === "ArrowRight" && l === ((d =
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
})) : (
|
|
510
|
+
if (i.code === "ArrowRight" && l === ((d = t.textContent) == null ? void 0 : d.length)) {
|
|
511
|
+
const n = (P = t.parentElement) == null ? void 0 : P.nextElementSibling;
|
|
512
|
+
n && (_(n) && n.children[0] && ((D = n.children[0].textContent) != null && D.length) ? (R.current = n, q(n), ne(n.children[0]), requestAnimationFrame(() => {
|
|
513
|
+
he(n.children[0]);
|
|
514
|
+
})) : (ue(), ne(n)));
|
|
499
515
|
}
|
|
500
516
|
i.code === "Enter" && i.shiftKey && i.preventDefault();
|
|
501
|
-
},
|
|
517
|
+
}, Qe = (e, i) => {
|
|
502
518
|
K == null || K(i);
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
},
|
|
519
|
+
const t = i.target;
|
|
520
|
+
he(t);
|
|
521
|
+
}, Ze = (e, i) => {
|
|
506
522
|
var l;
|
|
507
|
-
i.stopPropagation(), R.current &&
|
|
508
|
-
const
|
|
509
|
-
R.current =
|
|
510
|
-
|
|
523
|
+
i.stopPropagation(), R.current && Se(R.current), (l = x.current) == null || l.setAttribute("contenteditable", "false");
|
|
524
|
+
const t = document.getElementById(e.id);
|
|
525
|
+
R.current = t, requestAnimationFrame(() => {
|
|
526
|
+
q(t);
|
|
511
527
|
});
|
|
512
|
-
},
|
|
513
|
-
|
|
514
|
-
},
|
|
528
|
+
}, Ie = (e, i) => {
|
|
529
|
+
X(V()), le(de()), g == null || g(V());
|
|
530
|
+
}, Ye = (e, i) => {
|
|
515
531
|
};
|
|
516
532
|
M(() => {
|
|
517
533
|
if (!U) return;
|
|
518
|
-
const
|
|
519
|
-
B.current && !B.current.contains(l.target) &&
|
|
534
|
+
const e = (l) => {
|
|
535
|
+
B.current && !B.current.contains(l.target) && F(!1);
|
|
520
536
|
}, i = (l) => {
|
|
521
|
-
B.current && !B.current.contains(l.target) &&
|
|
522
|
-
},
|
|
523
|
-
|
|
537
|
+
B.current && !B.current.contains(l.target) && F(!1);
|
|
538
|
+
}, t = () => {
|
|
539
|
+
F(!1);
|
|
524
540
|
};
|
|
525
|
-
return document.addEventListener("mousedown",
|
|
526
|
-
document.removeEventListener("mousedown",
|
|
541
|
+
return document.addEventListener("mousedown", e), document.addEventListener("scroll", i, !0), window.addEventListener("resize", t), () => {
|
|
542
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("scroll", i, !0), window.removeEventListener("resize", t);
|
|
527
543
|
};
|
|
528
544
|
}, [U]);
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
const
|
|
532
|
-
|
|
545
|
+
const I = (e, i) => {
|
|
546
|
+
if (w && i !== h.LABEL && ct(w.id, e), i === h.SELECT && (F(!1), z({})), i === h.LABEL && (pe(), F(!1), requestAnimationFrame(() => {
|
|
547
|
+
const t = window.getSelection();
|
|
548
|
+
t && Y.current && (t.removeAllRanges(), t.addRange(Y.current), setTimeout(() => {
|
|
533
549
|
var d;
|
|
534
550
|
const l = document.createElement("span");
|
|
535
|
-
l.contentEditable = "false", l.setAttribute("data-set-type", "label"), l.id =
|
|
551
|
+
l.contentEditable = "false", l.setAttribute("data-set-type", "label"), l.id = w.id;
|
|
536
552
|
const c = document.createElement("span");
|
|
537
|
-
c.contentEditable = "false", c.textContent =
|
|
538
|
-
const a = (d =
|
|
553
|
+
c.contentEditable = "false", c.textContent = e, l.appendChild(c);
|
|
554
|
+
const a = (d = x.current) == null ? void 0 : d.children;
|
|
539
555
|
if ((a == null ? void 0 : a.length) === 1 && a[0].tagName === "SPAN" && a[0].innerHTML === "[")
|
|
540
|
-
|
|
541
|
-
z({}),
|
|
556
|
+
x.current.innerHTML = "", x.current.appendChild(l), setTimeout(() => {
|
|
557
|
+
z({}), pe();
|
|
542
558
|
}, 0);
|
|
543
559
|
else {
|
|
544
560
|
document.execCommand("delete", !1, void 0);
|
|
545
|
-
const P =
|
|
546
|
-
P.insertNode(l), P.setStartAfter(l), P.setEndAfter(l),
|
|
561
|
+
const P = Y.current;
|
|
562
|
+
P.insertNode(l), P.setStartAfter(l), P.setEndAfter(l), t.removeAllRanges(), t.addRange(P), setTimeout(() => {
|
|
547
563
|
z({});
|
|
548
564
|
}, 0);
|
|
549
565
|
}
|
|
550
566
|
}, 0));
|
|
551
567
|
})), i === h.MULTIPLE_SELECT || i === h.DATE_PICKER) {
|
|
552
|
-
const
|
|
553
|
-
|
|
568
|
+
const t = document.getElementById(
|
|
569
|
+
w.id
|
|
554
570
|
);
|
|
555
|
-
|
|
571
|
+
t && t.children[0] && t.children[1] && (e.length > 0 ? (t.children[0].setAttribute("style", "display: inline"), t.children[0].setAttribute("contenteditable", "false"), t.children[1].setAttribute("style", "display: none"), t.children[1].setAttribute("contenteditable", "true")) : (t.children[0].setAttribute("style", "display: none"), t.children[0].setAttribute("contenteditable", "true"), t.children[1].setAttribute("style", "display: inline"), t.children[1].setAttribute("contenteditable", "true"))), z({});
|
|
556
572
|
}
|
|
557
|
-
},
|
|
558
|
-
const i =
|
|
559
|
-
|
|
573
|
+
}, Y = O(null), et = (S == null ? void 0 : S.map((e) => e.prefix)) || [], tt = (e) => {
|
|
574
|
+
const i = e == null ? void 0 : e.nativeEvent, t = i == null ? void 0 : i.data;
|
|
575
|
+
et.includes(t) && ut().then((l) => {
|
|
560
576
|
var a;
|
|
561
577
|
const c = window.getSelection();
|
|
562
|
-
c && c.rangeCount > 0 && (
|
|
563
|
-
options: ((a =
|
|
578
|
+
c && c.rangeCount > 0 && (Y.current = c.getRangeAt(0)), nt({
|
|
579
|
+
options: ((a = S.find((d) => d.prefix === t)) == null ? void 0 : a.options) || [],
|
|
564
580
|
value: "",
|
|
565
581
|
type: h.LABEL,
|
|
566
582
|
id: "label-" + ke()
|
|
567
583
|
}, l);
|
|
568
584
|
});
|
|
569
|
-
},
|
|
570
|
-
|
|
585
|
+
}, nt = (e, i) => {
|
|
586
|
+
se(e.options), W({ top: -999999, left: -999999999 }), ce(e), Q(Ce), F(!0), requestAnimationFrame(() => {
|
|
571
587
|
if (B.current) {
|
|
572
|
-
const
|
|
588
|
+
const t = B.current.getBoundingClientRect();
|
|
573
589
|
let l = i.left, c = i.top + i.height;
|
|
574
|
-
window.innerWidth - i.right <
|
|
590
|
+
window.innerWidth - i.right < we && i.width < t.width && (l = i.right - t.width), i.top < t.height && (c = i.top + i.height), W({ top: c, left: l }), Q(t.height);
|
|
575
591
|
}
|
|
576
592
|
});
|
|
577
|
-
},
|
|
593
|
+
}, xe = (e, i) => {
|
|
578
594
|
const l = i.target.getBoundingClientRect();
|
|
579
|
-
|
|
595
|
+
se(e.options), Ee(e.value || Ne(e.id)), W({ top: -999999, left: -999999999 }), ce(e), Q(Ce), F(!0), requestAnimationFrame(() => {
|
|
580
596
|
if (B.current) {
|
|
581
597
|
const c = B.current.getBoundingClientRect();
|
|
582
598
|
let a = l.left, d = l.top + l.height;
|
|
583
|
-
window.innerWidth - l.right <
|
|
599
|
+
window.innerWidth - l.right < we && l.width < c.width && (a = l.right - c.width), l.top < c.height && (d = l.top + l.height), W({ top: d, left: a }), Q(c.height);
|
|
584
600
|
}
|
|
585
601
|
});
|
|
586
|
-
},
|
|
602
|
+
}, it = (e, i) => {
|
|
587
603
|
const l = i.target.getBoundingClientRect();
|
|
588
|
-
let c = l.left, a = l.top -
|
|
589
|
-
window.innerWidth - l.right <
|
|
590
|
-
}, [
|
|
604
|
+
let c = l.left, a = l.top - me;
|
|
605
|
+
window.innerWidth - l.right < Ae && (c = c - Ae + l.width), l.top < me && (a = l.top + l.height), se(e.options), Ee(e.value || Ne(e.id)), W({ top: a, left: c }), ce(e), F(!0);
|
|
606
|
+
}, [rt, Le] = L([]), [fe, Te] = L(!0), Re = Pe(() => {
|
|
591
607
|
Te(!1);
|
|
592
|
-
const
|
|
593
|
-
return
|
|
594
|
-
var l, c, a, d, P,
|
|
595
|
-
if (
|
|
608
|
+
const e = Oe(o), i = [];
|
|
609
|
+
return e.forEach((t) => {
|
|
610
|
+
var l, c, a, d, P, D;
|
|
611
|
+
if (t.type === "text")
|
|
596
612
|
i.push(
|
|
597
|
-
/* @__PURE__ */ u("span", { onKeyDown: (
|
|
613
|
+
/* @__PURE__ */ u("span", { onKeyDown: (n) => Ye(), children: t.content }, t.id)
|
|
598
614
|
);
|
|
599
|
-
else if (
|
|
600
|
-
i.push(/* @__PURE__ */ u("br", {},
|
|
601
|
-
else if (
|
|
615
|
+
else if (t.type === "newline")
|
|
616
|
+
i.push(/* @__PURE__ */ u("br", {}, t.id));
|
|
617
|
+
else if (t.type === "label")
|
|
602
618
|
i.push(
|
|
603
619
|
/* @__PURE__ */ u(
|
|
604
620
|
"span",
|
|
605
621
|
{
|
|
606
|
-
id:
|
|
622
|
+
id: t.id,
|
|
607
623
|
"data-set-type": "label",
|
|
608
624
|
contentEditable: !1,
|
|
609
625
|
children: /* @__PURE__ */ u(
|
|
610
626
|
"span",
|
|
611
627
|
{
|
|
612
628
|
contentEditable: !1,
|
|
613
|
-
children:
|
|
629
|
+
children: t.name
|
|
614
630
|
}
|
|
615
631
|
)
|
|
616
632
|
},
|
|
617
|
-
|
|
633
|
+
t.id
|
|
618
634
|
)
|
|
619
635
|
);
|
|
620
|
-
else if (
|
|
636
|
+
else if (t.type === "input")
|
|
621
637
|
i.push(
|
|
622
|
-
/* @__PURE__ */
|
|
638
|
+
/* @__PURE__ */ te(
|
|
623
639
|
"span",
|
|
624
640
|
{
|
|
625
|
-
id:
|
|
641
|
+
id: t.id,
|
|
626
642
|
"data-set-type": "input",
|
|
627
643
|
contentEditable: !1,
|
|
628
644
|
suppressContentEditableWarning: !0,
|
|
629
|
-
onInput: (
|
|
630
|
-
onClick: (
|
|
631
|
-
onMouseDown: (
|
|
632
|
-
"data-cosmic-ai-input-placeholder":
|
|
645
|
+
onInput: (n) => Ie(),
|
|
646
|
+
onClick: (n) => Xe(t, n),
|
|
647
|
+
onMouseDown: (n) => Ge(t, n),
|
|
648
|
+
"data-cosmic-ai-input-placeholder": t.placeholder,
|
|
633
649
|
children: [
|
|
634
650
|
/* @__PURE__ */ u(
|
|
635
651
|
"span",
|
|
636
652
|
{
|
|
637
653
|
className: "cosmic-ai-input-inputContent",
|
|
638
654
|
style: {
|
|
639
|
-
padding: (l =
|
|
655
|
+
padding: (l = t.content) != null && l.length ? "2px 4px" : "2px 0 2px 4px"
|
|
640
656
|
},
|
|
641
657
|
contentEditable: !1,
|
|
642
|
-
onKeyDown: (
|
|
643
|
-
onKeyUp: (
|
|
644
|
-
children:
|
|
658
|
+
onKeyDown: (n) => Je(t, n),
|
|
659
|
+
onKeyUp: (n) => Qe(t, n),
|
|
660
|
+
children: t.content
|
|
645
661
|
}
|
|
646
662
|
),
|
|
647
663
|
/* @__PURE__ */ u(
|
|
648
664
|
"span",
|
|
649
665
|
{
|
|
650
666
|
contentEditable: !1,
|
|
651
|
-
style: { display: (c =
|
|
667
|
+
style: { display: (c = t.content) != null && c.length ? "none" : "inline" },
|
|
652
668
|
className: "cosmic-ai-input-placeholder",
|
|
653
|
-
onMouseDown: (
|
|
654
|
-
children:
|
|
669
|
+
onMouseDown: (n) => Ze(t, n),
|
|
670
|
+
children: t.placeholder
|
|
655
671
|
}
|
|
656
672
|
)
|
|
657
673
|
]
|
|
658
674
|
},
|
|
659
|
-
|
|
675
|
+
t.id
|
|
660
676
|
)
|
|
661
677
|
);
|
|
662
|
-
else if (
|
|
663
|
-
const
|
|
678
|
+
else if (t.type === h.SELECT) {
|
|
679
|
+
const n = t.content || ((a = t.options) == null ? void 0 : a[0]) || t.placeholder;
|
|
664
680
|
i.push(
|
|
665
681
|
/* @__PURE__ */ u(
|
|
666
682
|
"span",
|
|
667
683
|
{
|
|
668
|
-
id:
|
|
684
|
+
id: t.id,
|
|
669
685
|
"data-set-type": "select",
|
|
670
686
|
contentEditable: !1,
|
|
671
687
|
suppressContentEditableWarning: !0,
|
|
672
|
-
onClick: (H) =>
|
|
673
|
-
"data-cosmic-ai-input-placeholder":
|
|
674
|
-
children: /* @__PURE__ */ u("span", { contentEditable: !1, children:
|
|
688
|
+
onClick: (H) => xe(t, H),
|
|
689
|
+
"data-cosmic-ai-input-placeholder": t.placeholder,
|
|
690
|
+
children: /* @__PURE__ */ u("span", { contentEditable: !1, children: n })
|
|
675
691
|
},
|
|
676
|
-
|
|
692
|
+
t.id
|
|
677
693
|
)
|
|
678
694
|
);
|
|
679
|
-
} else if (
|
|
680
|
-
const
|
|
695
|
+
} else if (t.type === h.MULTIPLE_SELECT) {
|
|
696
|
+
const n = t.content || ((d = t.options) == null ? void 0 : d[0]);
|
|
681
697
|
i.push(
|
|
682
|
-
/* @__PURE__ */
|
|
698
|
+
/* @__PURE__ */ te(
|
|
683
699
|
"span",
|
|
684
700
|
{
|
|
685
|
-
id:
|
|
701
|
+
id: t.id,
|
|
686
702
|
"data-set-type": "multiple-select",
|
|
687
703
|
contentEditable: !1,
|
|
688
704
|
suppressContentEditableWarning: !0,
|
|
689
|
-
onClick: (H) =>
|
|
690
|
-
"data-cosmic-ai-input-placeholder":
|
|
705
|
+
onClick: (H) => xe(t, H),
|
|
706
|
+
"data-cosmic-ai-input-placeholder": t.placeholder,
|
|
691
707
|
children: [
|
|
692
708
|
/* @__PURE__ */ u(
|
|
693
709
|
"span",
|
|
694
710
|
{
|
|
695
|
-
style: { display:
|
|
711
|
+
style: { display: n != null && n.length ? "inline" : "none" },
|
|
696
712
|
contentEditable: !1,
|
|
697
|
-
children:
|
|
713
|
+
children: n
|
|
698
714
|
}
|
|
699
715
|
),
|
|
700
716
|
/* @__PURE__ */ u(
|
|
701
717
|
"span",
|
|
702
718
|
{
|
|
703
|
-
style: { display:
|
|
719
|
+
style: { display: n != null && n.length ? "none" : "inline" },
|
|
704
720
|
className: "cosmic-ai-input-selectPlaceholder",
|
|
705
721
|
contentEditable: !1,
|
|
706
|
-
children:
|
|
722
|
+
children: t.placeholder
|
|
707
723
|
}
|
|
708
724
|
)
|
|
709
725
|
]
|
|
710
726
|
},
|
|
711
|
-
|
|
727
|
+
t.id
|
|
712
728
|
)
|
|
713
729
|
);
|
|
714
|
-
} else
|
|
715
|
-
/* @__PURE__ */
|
|
730
|
+
} else t.type === h.DATE_PICKER && i.push(
|
|
731
|
+
/* @__PURE__ */ te(
|
|
716
732
|
"span",
|
|
717
733
|
{
|
|
718
|
-
id:
|
|
734
|
+
id: t.id,
|
|
719
735
|
"data-set-type": "date-picker",
|
|
720
736
|
contentEditable: !1,
|
|
721
737
|
suppressContentEditableWarning: !0,
|
|
722
|
-
onClick: (
|
|
723
|
-
"data-cosmic-ai-input-placeholder":
|
|
738
|
+
onClick: (n) => it(t, n),
|
|
739
|
+
"data-cosmic-ai-input-placeholder": t.placeholder,
|
|
724
740
|
children: [
|
|
725
741
|
/* @__PURE__ */ u(
|
|
726
742
|
"span",
|
|
727
743
|
{
|
|
728
|
-
style: { display: (P =
|
|
744
|
+
style: { display: (P = t.content) != null && P.length ? "inline" : "none" },
|
|
729
745
|
contentEditable: !1,
|
|
730
|
-
children:
|
|
746
|
+
children: t.content
|
|
731
747
|
}
|
|
732
748
|
),
|
|
733
749
|
/* @__PURE__ */ u(
|
|
734
750
|
"span",
|
|
735
751
|
{
|
|
736
|
-
style: { display: (
|
|
752
|
+
style: { display: (D = t.content) != null && D.length ? "none" : "inline" },
|
|
737
753
|
className: "cosmic-ai-input-datePickerPlaceholder",
|
|
738
754
|
contentEditable: !1,
|
|
739
|
-
children:
|
|
755
|
+
children: t.placeholder
|
|
740
756
|
}
|
|
741
757
|
)
|
|
742
758
|
]
|
|
743
759
|
},
|
|
744
|
-
|
|
760
|
+
t.id
|
|
745
761
|
)
|
|
746
762
|
);
|
|
747
763
|
}), setTimeout(() => {
|
|
@@ -749,102 +765,103 @@ const ht = j((r, s) => {
|
|
|
749
765
|
}, 0), i;
|
|
750
766
|
}, [o]);
|
|
751
767
|
M(() => {
|
|
752
|
-
|
|
753
|
-
|
|
768
|
+
fe && setTimeout(() => {
|
|
769
|
+
v(x.current);
|
|
754
770
|
}, 0);
|
|
755
|
-
}, [
|
|
756
|
-
o !==
|
|
757
|
-
}, [o,
|
|
758
|
-
if (!
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}),
|
|
771
|
+
}, [fe]), M(() => {
|
|
772
|
+
o !== re ? (Le(Re()), X(o), be(!0)) : (o === "" || !o) && Le(Re());
|
|
773
|
+
}, [o, re]), M(() => {
|
|
774
|
+
if (!N && !ye) return;
|
|
775
|
+
const e = new MutationObserver(() => {
|
|
776
|
+
x.current && document.contains(x.current) && (requestAnimationFrame(() => {
|
|
777
|
+
v(x.current), be(!1);
|
|
778
|
+
}), e.disconnect());
|
|
763
779
|
});
|
|
764
|
-
return
|
|
765
|
-
}, [
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
780
|
+
return x.current && e.observe(document.body, { childList: !0, subtree: !0 }), () => e.disconnect();
|
|
781
|
+
}, [N, ye]);
|
|
782
|
+
const pe = () => {
|
|
783
|
+
x.current && requestAnimationFrame(() => {
|
|
784
|
+
v(x.current);
|
|
769
785
|
});
|
|
770
786
|
};
|
|
771
|
-
return
|
|
772
|
-
getCurrentValue:
|
|
773
|
-
focus:
|
|
787
|
+
return ot(s, () => ({
|
|
788
|
+
getCurrentValue: V,
|
|
789
|
+
focus: pe
|
|
774
790
|
})), // 最外层的防止renderContainer为false的时候样式坍塌
|
|
775
|
-
/* @__PURE__ */
|
|
776
|
-
|
|
791
|
+
/* @__PURE__ */ te("div", { className: De(`cosmic-ai-input-rows${E}`), style: { textIndent: T + "px" }, children: [
|
|
792
|
+
fe && /* @__PURE__ */ u(
|
|
777
793
|
"div",
|
|
778
794
|
{
|
|
779
795
|
"data-set-type": "container",
|
|
780
796
|
"data-cosmic-ai-input-placeholder": k,
|
|
781
|
-
className:
|
|
797
|
+
className: De(
|
|
782
798
|
"cosmic-ai-input",
|
|
783
|
-
`cosmic-ai-input-rows${
|
|
799
|
+
`cosmic-ai-input-rows${E}`,
|
|
784
800
|
{ "is-disabled": $ },
|
|
785
|
-
{ "is-empty":
|
|
801
|
+
{ "is-empty": re.length === 0 }
|
|
786
802
|
),
|
|
787
|
-
ref:
|
|
803
|
+
ref: x,
|
|
788
804
|
contentEditable: !0,
|
|
789
805
|
suppressContentEditableWarning: !0,
|
|
790
|
-
onClick: (
|
|
791
|
-
onFocus: (
|
|
792
|
-
|
|
806
|
+
onClick: (e) => Fe(e),
|
|
807
|
+
onFocus: (e) => {
|
|
808
|
+
We(e);
|
|
793
809
|
},
|
|
794
|
-
onBlur: (
|
|
795
|
-
p == null || p(
|
|
810
|
+
onBlur: (e) => {
|
|
811
|
+
p == null || p(e);
|
|
796
812
|
},
|
|
797
|
-
onMouseDown: (
|
|
798
|
-
onKeyDown: (
|
|
799
|
-
onKeyUp: (
|
|
800
|
-
onInput: (
|
|
801
|
-
onCopy: (
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
813
|
+
onMouseDown: (e) => Ve(),
|
|
814
|
+
onKeyDown: (e) => ve(e),
|
|
815
|
+
onKeyUp: (e) => _e(e),
|
|
816
|
+
onInput: (e) => z(e),
|
|
817
|
+
onCopy: (e) => Ue(e),
|
|
818
|
+
onPaste: (e) => Ke(e),
|
|
819
|
+
onCompositionStart: ze,
|
|
820
|
+
onCompositionEnd: je,
|
|
821
|
+
children: rt
|
|
805
822
|
}
|
|
806
823
|
),
|
|
807
|
-
U &&
|
|
808
|
-
(
|
|
824
|
+
U && st(
|
|
825
|
+
(w == null ? void 0 : w.type) === h.MULTIPLE_SELECT ? /* @__PURE__ */ u(
|
|
809
826
|
Be,
|
|
810
827
|
{
|
|
811
828
|
ref: B,
|
|
812
|
-
options:
|
|
813
|
-
value:
|
|
814
|
-
position:
|
|
815
|
-
height:
|
|
816
|
-
onChange:
|
|
829
|
+
options: oe,
|
|
830
|
+
value: J,
|
|
831
|
+
position: G,
|
|
832
|
+
height: ae,
|
|
833
|
+
onChange: I
|
|
817
834
|
},
|
|
818
835
|
h.MULTIPLE_SELECT
|
|
819
|
-
) : (
|
|
836
|
+
) : (w == null ? void 0 : w.type) === h.DATE_PICKER ? /* @__PURE__ */ u(
|
|
820
837
|
$e,
|
|
821
838
|
{
|
|
822
839
|
ref: B,
|
|
823
|
-
value:
|
|
824
|
-
position:
|
|
825
|
-
onChange:
|
|
840
|
+
value: J,
|
|
841
|
+
position: G,
|
|
842
|
+
onChange: I
|
|
826
843
|
},
|
|
827
844
|
h.DATE_PICKER
|
|
828
|
-
) : (
|
|
845
|
+
) : (w == null ? void 0 : w.type) === h.LABEL ? /* @__PURE__ */ u(
|
|
829
846
|
He,
|
|
830
847
|
{
|
|
831
848
|
ref: B,
|
|
832
|
-
options:
|
|
833
|
-
value:
|
|
834
|
-
position:
|
|
835
|
-
height:
|
|
836
|
-
onChange:
|
|
849
|
+
options: oe,
|
|
850
|
+
value: J,
|
|
851
|
+
position: G,
|
|
852
|
+
height: ae,
|
|
853
|
+
onChange: I
|
|
837
854
|
},
|
|
838
855
|
h.LABEL
|
|
839
856
|
) : /* @__PURE__ */ u(
|
|
840
857
|
Me,
|
|
841
858
|
{
|
|
842
859
|
ref: B,
|
|
843
|
-
options:
|
|
844
|
-
value:
|
|
845
|
-
position:
|
|
846
|
-
height:
|
|
847
|
-
onChange:
|
|
860
|
+
options: oe,
|
|
861
|
+
value: J,
|
|
862
|
+
position: G,
|
|
863
|
+
height: ae,
|
|
864
|
+
onChange: I
|
|
848
865
|
},
|
|
849
866
|
h.SELECT
|
|
850
867
|
),
|
|
@@ -852,7 +869,7 @@ const ht = j((r, s) => {
|
|
|
852
869
|
)
|
|
853
870
|
] });
|
|
854
871
|
});
|
|
855
|
-
|
|
872
|
+
gt.displayName = "AiInput";
|
|
856
873
|
export {
|
|
857
|
-
|
|
874
|
+
gt as default
|
|
858
875
|
};
|