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