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