cosmic-ai-input 1.0.21 → 1.0.23

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