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