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