react-input-emoji 5.8.1 → 5.9.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -37,479 +37,10 @@ function styleInject(css, ref) {
37
37
  var css_248z = ".react-input-emoji--container {\n color: #4b4b4b;\n text-rendering: optimizeLegibility;\n background-color: #fff;\n border: 1px solid #fff;\n border-radius: 21px;\n margin: 5px 10px;\n box-sizing: border-box;\n flex: 1 1 auto;\n font-size: 15px;\n font-family: sans-serif;\n font-weight: 400;\n line-height: 20px;\n min-height: 20px;\n min-width: 0;\n outline: none;\n width: inherit;\n will-change: width;\n vertical-align: baseline;\n border: 1px solid #eaeaea;\n margin-right: 0;\n}\n\n.react-input-emoji--wrapper {\n display: flex;\n overflow: hidden;\n flex: 1;\n position: relative;\n padding-right: 0;\n vertical-align: baseline;\n outline: none;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n.react-input-emoji--input {\n font-weight: 400;\n max-height: 100px;\n min-height: 20px;\n outline: none;\n overflow-x: hidden;\n overflow-y: auto;\n position: relative;\n white-space: pre-wrap;\n word-wrap: break-word;\n z-index: 1;\n width: 100%;\n user-select: text;\n padding: 9px 12px 11px;\n text-align: left;\n}\n\n.react-input-emoji--input img {\n vertical-align: middle;\n width: 18px !important;\n height: 18px !important;\n display: inline !important;\n margin-left: 1px;\n margin-right: 1px;\n}\n\n.react-input-emoji--overlay {\n position: fixed;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n z-index: 9;\n}\n\n.react-input-emoji--placeholder {\n color: #a0a0a0;\n pointer-events: none;\n position: absolute;\n user-select: none;\n z-index: 2;\n left: 16px;\n top: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n width: calc(100% - 22px);\n}\n\n.react-input-emoji--button {\n position: relative;\n display: block;\n text-align: center;\n padding: 0 10px;\n overflow: hidden;\n transition: color 0.1s ease-out;\n margin: 0;\n box-shadow: none;\n background: none;\n border: none;\n outline: none;\n cursor: pointer;\n flex-shrink: 0;\n}\n\n.react-input-emoji--button svg {\n fill: #858585;\n}\n\n.react-input-emoji--button__show svg {\n fill: #128b7e;\n}\n\n.react-emoji {\n display: flex;\n align-items: center;\n position: relative;\n width: 100%;\n}\n\n.react-emoji-picker--container {\n position: absolute;\n top: 0;\n width: 100%;\n}\n\n.react-emoji-picker--wrapper {\n position: absolute;\n bottom: 0;\n right: 0;\n height: 435px;\n width: 352px;\n overflow: hidden;\n z-index: 10;\n}\n\n.react-emoji-picker {\n position: absolute;\n top: 0;\n left: 0;\n animation: slidein 0.1s ease-in-out;\n}\n\n.react-emoji-picker__show {\n top: 0;\n}\n\n.react-input-emoji--mention--container {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n z-index: 10;\n}\n\n.react-input-emoji--mention--list {\n background-color: #fafafa;\n border: 1px solid #eaeaea;\n border-radius: 4px;\n margin: 0;\n padding: 0;\n list-style: none;\n display: flex;\n gap: 5px;\n flex-direction: column;\n position: absolute;\n bottom: 0;\n width: 100%;\n left: 0;\n}\n\n.react-input-emoji--mention--item {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 5px 10px;\n background-color: transparent;\n width: 100%;\n margin: 0;\n border: 0;\n}\n\n.react-input-emoji--mention--item__selected {\n background-color: #eeeeee;\n}\n\n.react-input-emoji--mention--item--img {\n width: 34px;\n height: 34px;\n border-radius: 50%;\n}\n\n.react-input-emoji--mention--item--name {\n font-size: 16px;\n color: #333;\n}\n\n.react-input-emoji--mention--item--name__selected {\n color: green;\n}\n\n.react-input-emoji--mention--text {\n color: #039be5;\n}\n\n.react-input-emoji--mention--loading {\n background-color: #fafafa;\n border: 1px solid #eaeaea;\n border-radius: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 10px 0;\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n}\n\n.react-input-emoji--mention--loading--spinner,\n.react-input-emoji--mention--loading--spinner::after {\n border-radius: 50%;\n width: 10em;\n height: 10em;\n}\n\n.react-input-emoji--mention--loading--spinner {\n margin: 1px auto;\n font-size: 2px;\n position: relative;\n text-indent: -9999em;\n border-top: 1.1em solid rgba(0, 0, 0, 0.1);\n border-right: 1.1em solid rgba(0, 0, 0, 0.1);\n border-bottom: 1.1em solid rgba(0, 0, 0, 0.1);\n border-left: 1.1em solid rgba(0, 0, 0, 0.4);\n transform: translateZ(0);\n animation: load8 1.1s infinite linear;\n}\n\n@keyframes load8 {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n@keyframes slidein {\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n}\n";
38
38
  styleInject(css_248z);
39
39
 
40
- function _iterableToArrayLimit(r, l) {
41
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
42
- if (null != t) {
43
- var e,
44
- n,
45
- i,
46
- u,
47
- a = [],
48
- f = !0,
49
- o = !1;
50
- try {
51
- if (i = (t = t.call(r)).next, 0 === l) {
52
- if (Object(t) !== t) return;
53
- f = !1;
54
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
55
- } catch (r) {
56
- o = !0, n = r;
57
- } finally {
58
- try {
59
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
60
- } finally {
61
- if (o) throw n;
62
- }
63
- }
64
- return a;
65
- }
66
- }
67
- function ownKeys(e, r) {
68
- var t = Object.keys(e);
69
- if (Object.getOwnPropertySymbols) {
70
- var o = Object.getOwnPropertySymbols(e);
71
- r && (o = o.filter(function (r) {
72
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
73
- })), t.push.apply(t, o);
74
- }
75
- return t;
76
- }
77
- function _objectSpread2(e) {
78
- for (var r = 1; r < arguments.length; r++) {
79
- var t = null != arguments[r] ? arguments[r] : {};
80
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
81
- _defineProperty(e, r, t[r]);
82
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
83
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
84
- });
85
- }
86
- return e;
87
- }
88
- function _regeneratorRuntime() {
89
- _regeneratorRuntime = function () {
90
- return e;
91
- };
92
- var t,
93
- e = {},
94
- r = Object.prototype,
95
- n = r.hasOwnProperty,
96
- o = Object.defineProperty || function (t, e, r) {
97
- t[e] = r.value;
98
- },
99
- i = "function" == typeof Symbol ? Symbol : {},
100
- a = i.iterator || "@@iterator",
101
- c = i.asyncIterator || "@@asyncIterator",
102
- u = i.toStringTag || "@@toStringTag";
103
- function define(t, e, r) {
104
- return Object.defineProperty(t, e, {
105
- value: r,
106
- enumerable: !0,
107
- configurable: !0,
108
- writable: !0
109
- }), t[e];
110
- }
111
- try {
112
- define({}, "");
113
- } catch (t) {
114
- define = function (t, e, r) {
115
- return t[e] = r;
116
- };
117
- }
118
- function wrap(t, e, r, n) {
119
- var i = e && e.prototype instanceof Generator ? e : Generator,
120
- a = Object.create(i.prototype),
121
- c = new Context(n || []);
122
- return o(a, "_invoke", {
123
- value: makeInvokeMethod(t, r, c)
124
- }), a;
125
- }
126
- function tryCatch(t, e, r) {
127
- try {
128
- return {
129
- type: "normal",
130
- arg: t.call(e, r)
131
- };
132
- } catch (t) {
133
- return {
134
- type: "throw",
135
- arg: t
136
- };
137
- }
138
- }
139
- e.wrap = wrap;
140
- var h = "suspendedStart",
141
- l = "suspendedYield",
142
- f = "executing",
143
- s = "completed",
144
- y = {};
145
- function Generator() {}
146
- function GeneratorFunction() {}
147
- function GeneratorFunctionPrototype() {}
148
- var p = {};
149
- define(p, a, function () {
150
- return this;
151
- });
152
- var d = Object.getPrototypeOf,
153
- v = d && d(d(values([])));
154
- v && v !== r && n.call(v, a) && (p = v);
155
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
156
- function defineIteratorMethods(t) {
157
- ["next", "throw", "return"].forEach(function (e) {
158
- define(t, e, function (t) {
159
- return this._invoke(e, t);
160
- });
161
- });
162
- }
163
- function AsyncIterator(t, e) {
164
- function invoke(r, o, i, a) {
165
- var c = tryCatch(t[r], t, o);
166
- if ("throw" !== c.type) {
167
- var u = c.arg,
168
- h = u.value;
169
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
170
- invoke("next", t, i, a);
171
- }, function (t) {
172
- invoke("throw", t, i, a);
173
- }) : e.resolve(h).then(function (t) {
174
- u.value = t, i(u);
175
- }, function (t) {
176
- return invoke("throw", t, i, a);
177
- });
178
- }
179
- a(c.arg);
180
- }
181
- var r;
182
- o(this, "_invoke", {
183
- value: function (t, n) {
184
- function callInvokeWithMethodAndArg() {
185
- return new e(function (e, r) {
186
- invoke(t, n, e, r);
187
- });
188
- }
189
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
190
- }
191
- });
192
- }
193
- function makeInvokeMethod(e, r, n) {
194
- var o = h;
195
- return function (i, a) {
196
- if (o === f) throw new Error("Generator is already running");
197
- if (o === s) {
198
- if ("throw" === i) throw a;
199
- return {
200
- value: t,
201
- done: !0
202
- };
203
- }
204
- for (n.method = i, n.arg = a;;) {
205
- var c = n.delegate;
206
- if (c) {
207
- var u = maybeInvokeDelegate(c, n);
208
- if (u) {
209
- if (u === y) continue;
210
- return u;
211
- }
212
- }
213
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
214
- if (o === h) throw o = s, n.arg;
215
- n.dispatchException(n.arg);
216
- } else "return" === n.method && n.abrupt("return", n.arg);
217
- o = f;
218
- var p = tryCatch(e, r, n);
219
- if ("normal" === p.type) {
220
- if (o = n.done ? s : l, p.arg === y) continue;
221
- return {
222
- value: p.arg,
223
- done: n.done
224
- };
225
- }
226
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
227
- }
228
- };
229
- }
230
- function maybeInvokeDelegate(e, r) {
231
- var n = r.method,
232
- o = e.iterator[n];
233
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
234
- var i = tryCatch(o, e.iterator, r.arg);
235
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
236
- var a = i.arg;
237
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
238
- }
239
- function pushTryEntry(t) {
240
- var e = {
241
- tryLoc: t[0]
242
- };
243
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
244
- }
245
- function resetTryEntry(t) {
246
- var e = t.completion || {};
247
- e.type = "normal", delete e.arg, t.completion = e;
248
- }
249
- function Context(t) {
250
- this.tryEntries = [{
251
- tryLoc: "root"
252
- }], t.forEach(pushTryEntry, this), this.reset(!0);
253
- }
254
- function values(e) {
255
- if (e || "" === e) {
256
- var r = e[a];
257
- if (r) return r.call(e);
258
- if ("function" == typeof e.next) return e;
259
- if (!isNaN(e.length)) {
260
- var o = -1,
261
- i = function next() {
262
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
263
- return next.value = t, next.done = !0, next;
264
- };
265
- return i.next = i;
266
- }
267
- }
268
- throw new TypeError(typeof e + " is not iterable");
269
- }
270
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
271
- value: GeneratorFunctionPrototype,
272
- configurable: !0
273
- }), o(GeneratorFunctionPrototype, "constructor", {
274
- value: GeneratorFunction,
275
- configurable: !0
276
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
277
- var e = "function" == typeof t && t.constructor;
278
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
279
- }, e.mark = function (t) {
280
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
281
- }, e.awrap = function (t) {
282
- return {
283
- __await: t
284
- };
285
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
286
- return this;
287
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
288
- void 0 === i && (i = Promise);
289
- var a = new AsyncIterator(wrap(t, r, n, o), i);
290
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
291
- return t.done ? t.value : a.next();
292
- });
293
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
294
- return this;
295
- }), define(g, "toString", function () {
296
- return "[object Generator]";
297
- }), e.keys = function (t) {
298
- var e = Object(t),
299
- r = [];
300
- for (var n in e) r.push(n);
301
- return r.reverse(), function next() {
302
- for (; r.length;) {
303
- var t = r.pop();
304
- if (t in e) return next.value = t, next.done = !1, next;
305
- }
306
- return next.done = !0, next;
307
- };
308
- }, e.values = values, Context.prototype = {
309
- constructor: Context,
310
- reset: function (e) {
311
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
312
- },
313
- stop: function () {
314
- this.done = !0;
315
- var t = this.tryEntries[0].completion;
316
- if ("throw" === t.type) throw t.arg;
317
- return this.rval;
318
- },
319
- dispatchException: function (e) {
320
- if (this.done) throw e;
321
- var r = this;
322
- function handle(n, o) {
323
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
324
- }
325
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
326
- var i = this.tryEntries[o],
327
- a = i.completion;
328
- if ("root" === i.tryLoc) return handle("end");
329
- if (i.tryLoc <= this.prev) {
330
- var c = n.call(i, "catchLoc"),
331
- u = n.call(i, "finallyLoc");
332
- if (c && u) {
333
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
334
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
335
- } else if (c) {
336
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
337
- } else {
338
- if (!u) throw new Error("try statement without catch or finally");
339
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
340
- }
341
- }
342
- }
343
- },
344
- abrupt: function (t, e) {
345
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
346
- var o = this.tryEntries[r];
347
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
348
- var i = o;
349
- break;
350
- }
351
- }
352
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
353
- var a = i ? i.completion : {};
354
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
355
- },
356
- complete: function (t, e) {
357
- if ("throw" === t.type) throw t.arg;
358
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
359
- },
360
- finish: function (t) {
361
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
362
- var r = this.tryEntries[e];
363
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
364
- }
365
- },
366
- catch: function (t) {
367
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
368
- var r = this.tryEntries[e];
369
- if (r.tryLoc === t) {
370
- var n = r.completion;
371
- if ("throw" === n.type) {
372
- var o = n.arg;
373
- resetTryEntry(r);
374
- }
375
- return o;
376
- }
377
- }
378
- throw new Error("illegal catch attempt");
379
- },
380
- delegateYield: function (e, r, n) {
381
- return this.delegate = {
382
- iterator: values(e),
383
- resultName: r,
384
- nextLoc: n
385
- }, "next" === this.method && (this.arg = t), y;
386
- }
387
- }, e;
388
- }
389
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
390
- try {
391
- var info = gen[key](arg);
392
- var value = info.value;
393
- } catch (error) {
394
- reject(error);
395
- return;
396
- }
397
- if (info.done) {
398
- resolve(value);
399
- } else {
400
- Promise.resolve(value).then(_next, _throw);
401
- }
402
- }
403
- function _asyncToGenerator(fn) {
404
- return function () {
405
- var self = this,
406
- args = arguments;
407
- return new Promise(function (resolve, reject) {
408
- var gen = fn.apply(self, args);
409
- function _next(value) {
410
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
411
- }
412
- function _throw(err) {
413
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
414
- }
415
- _next(undefined);
416
- });
417
- };
418
- }
419
- function _defineProperty(obj, key, value) {
420
- key = _toPropertyKey(key);
421
- if (key in obj) {
422
- Object.defineProperty(obj, key, {
423
- value: value,
424
- enumerable: true,
425
- configurable: true,
426
- writable: true
427
- });
428
- } else {
429
- obj[key] = value;
430
- }
431
- return obj;
432
- }
433
- function _objectWithoutPropertiesLoose(source, excluded) {
434
- if (source == null) return {};
435
- var target = {};
436
- var sourceKeys = Object.keys(source);
437
- var key, i;
438
- for (i = 0; i < sourceKeys.length; i++) {
439
- key = sourceKeys[i];
440
- if (excluded.indexOf(key) >= 0) continue;
441
- target[key] = source[key];
442
- }
443
- return target;
444
- }
445
- function _objectWithoutProperties(source, excluded) {
446
- if (source == null) return {};
447
- var target = _objectWithoutPropertiesLoose(source, excluded);
448
- var key, i;
449
- if (Object.getOwnPropertySymbols) {
450
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
451
- for (i = 0; i < sourceSymbolKeys.length; i++) {
452
- key = sourceSymbolKeys[i];
453
- if (excluded.indexOf(key) >= 0) continue;
454
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
455
- target[key] = source[key];
456
- }
457
- }
458
- return target;
459
- }
460
- function _slicedToArray(arr, i) {
461
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
462
- }
463
- function _toConsumableArray(arr) {
464
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
465
- }
466
- function _arrayWithoutHoles(arr) {
467
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
468
- }
469
- function _arrayWithHoles(arr) {
470
- if (Array.isArray(arr)) return arr;
471
- }
472
- function _iterableToArray(iter) {
473
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
474
- }
475
- function _unsupportedIterableToArray(o, minLen) {
476
- if (!o) return;
477
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
478
- var n = Object.prototype.toString.call(o).slice(8, -1);
479
- if (n === "Object" && o.constructor) n = o.constructor.name;
480
- if (n === "Map" || n === "Set") return Array.from(o);
481
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
482
- }
483
- function _arrayLikeToArray(arr, len) {
484
- if (len == null || len > arr.length) len = arr.length;
485
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
486
- return arr2;
487
- }
488
- function _nonIterableSpread() {
489
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
490
- }
491
- function _nonIterableRest() {
492
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
493
- }
494
- function _toPrimitive(input, hint) {
495
- if (typeof input !== "object" || input === null) return input;
496
- var prim = input[Symbol.toPrimitive];
497
- if (prim !== undefined) {
498
- var res = prim.call(input, hint || "default");
499
- if (typeof res !== "object") return res;
500
- throw new TypeError("@@toPrimitive must return a primitive value.");
501
- }
502
- return (hint === "string" ? String : Number)(input);
503
- }
504
- function _toPropertyKey(arg) {
505
- var key = _toPrimitive(arg, "string");
506
- return typeof key === "symbol" ? key : String(key);
507
- }
508
-
509
40
  /* eslint-disable valid-jsdoc */
510
41
  // @ts-check
511
42
 
512
- var TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
43
+ const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
513
44
 
514
45
  /**
515
46
  * Replace all text with emoji with an image html tag
@@ -517,11 +48,11 @@ var TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAA
517
48
  * @return {string}
518
49
  */
519
50
  function replaceAllTextEmojis(text) {
520
- var allEmojis = getAllEmojisFromText(text);
51
+ let allEmojis = getAllEmojisFromText(text);
521
52
  if (allEmojis) {
522
- allEmojis = _toConsumableArray(new Set(allEmojis)); // remove duplicates
53
+ allEmojis = [...new Set(allEmojis)]; // remove duplicates
523
54
 
524
- allEmojis.forEach(function (emoji) {
55
+ allEmojis.forEach(emoji => {
525
56
  text = replaceAll(text, emoji, getInputEmojiHTML('', emoji));
526
57
  });
527
58
  }
@@ -555,20 +86,19 @@ function getAllEmojisFromText(text) {
555
86
  * @return {string}
556
87
  */
557
88
  function getImageEmoji(emoji) {
558
- var _emojiPickerEl$shadow;
559
89
  /** @type {HTMLElement | null} */
560
- var emojiPickerEl = document.querySelector('em-emoji-picker');
90
+ const emojiPickerEl = document.querySelector('em-emoji-picker');
561
91
  if (!emojiPickerEl) {
562
- return getInputEmojiNativeHTML(emoji["native"]);
92
+ return getInputEmojiNativeHTML(emoji.native);
563
93
  }
564
94
 
565
95
  /** @type {HTMLSpanElement | null=} */
566
- var emojiSpanEl = emojiPickerEl === null || emojiPickerEl === void 0 || (_emojiPickerEl$shadow = emojiPickerEl.shadowRoot) === null || _emojiPickerEl$shadow === void 0 ? void 0 : _emojiPickerEl$shadow.querySelector("[title=\"".concat(emoji.name, "\"] > span > span"));
96
+ const emojiSpanEl = emojiPickerEl?.shadowRoot?.querySelector(`[title="${emoji.name}"] > span > span`);
567
97
  if (!emojiSpanEl) {
568
- return getInputEmojiNativeHTML(emoji["native"]);
98
+ return getInputEmojiNativeHTML(emoji.native);
569
99
  }
570
- var style = replaceAll(emojiSpanEl.style.cssText, '"', "'");
571
- return getInputEmojiHTML(style, emoji["native"]);
100
+ const style = replaceAll(emojiSpanEl.style.cssText, '"', "'");
101
+ return getInputEmojiHTML(style, emoji.native);
572
102
  }
573
103
 
574
104
  // eslint-disable-next-line valid-jsdoc
@@ -579,7 +109,7 @@ function getImageEmoji(emoji) {
579
109
  * @returns
580
110
  */
581
111
  function getInputEmojiHTML(style, emoji) {
582
- return "<img style=\"".concat(style, "; display: inline-block\" data-emoji=\"").concat(emoji, "\" src=\"").concat(TRANSPARENT_GIF, "\" />");
112
+ return `<img style="${style}; display: inline-block" data-emoji="${emoji}" src="${TRANSPARENT_GIF}" />`;
583
113
  }
584
114
 
585
115
  /**
@@ -588,7 +118,7 @@ function getInputEmojiHTML(style, emoji) {
588
118
  * @returns
589
119
  */
590
120
  function getInputEmojiNativeHTML(emoji) {
591
- return "<span class=\"width: 18px; height: 18px; display: inline-block; margin: 0 1px;\">".concat(emoji, "</span>");
121
+ return `<span class="width: 18px; height: 18px; display: inline-block; margin: 0 1px;">${emoji}</span>`;
592
122
  }
593
123
 
594
124
  /**
@@ -597,10 +127,10 @@ function getInputEmojiNativeHTML(emoji) {
597
127
  * @return {string}
598
128
  */
599
129
  function replaceAllTextEmojiToString(html) {
600
- var container = document.createElement("div");
130
+ const container = document.createElement("div");
601
131
  container.innerHTML = html;
602
- var images = Array.prototype.slice.call(container.querySelectorAll("img"));
603
- images.forEach(function (image) {
132
+ const images = Array.prototype.slice.call(container.querySelectorAll("img"));
133
+ images.forEach(image => {
604
134
  container.innerHTML = container.innerHTML.replace(image.outerHTML, image.dataset.emoji);
605
135
  });
606
136
  return container.innerHTML;
@@ -613,12 +143,12 @@ function replaceAllTextEmojiToString(html) {
613
143
  * @param {React.ClipboardEvent} event
614
144
  */
615
145
  function handleCopy(event) {
616
- var selectedText = window.getSelection();
146
+ const selectedText = window.getSelection();
617
147
  if (selectedText === null) {
618
148
  return;
619
149
  }
620
- var container = document.createElement("div");
621
- for (var i = 0, len = selectedText.rangeCount; i < len; ++i) {
150
+ let container = document.createElement("div");
151
+ for (let i = 0, len = selectedText.rangeCount; i < len; ++i) {
622
152
  container.appendChild(selectedText.getRangeAt(i).cloneContents());
623
153
  }
624
154
  container = replaceEmojiToString(container);
@@ -626,28 +156,41 @@ function handleCopy(event) {
626
156
  event.preventDefault();
627
157
  }
628
158
 
159
+ /** @type {Range|undefined} */
160
+ /** @type {Range|undefined} */
161
+ let currentRangeCached;
162
+
629
163
  /**
630
- *
631
- * @param {string} html
164
+ * Caches the current text selection range
165
+ */
166
+ function cacheCurrentRange() {
167
+ const selection = window.getSelection();
168
+ if (!selection.rangeCount || selection?.anchorNode['className'] !== 'react-input-emoji--input' && selection.anchorNode.parentNode['className'] !== 'react-input-emoji--input') return;
169
+ const range = selection.getRangeAt(0);
170
+ currentRangeCached = range.cloneRange();
171
+ }
172
+
173
+ /**
174
+ * @param {string} html - HTML string to be pasted at the caret position
632
175
  */
633
176
  function handlePasteHtmlAtCaret(html) {
634
- var sel;
635
- var range;
177
+ let sel;
178
+ let range;
636
179
  if (window.getSelection) {
637
180
  // IE9 and non-IE
638
181
  sel = window.getSelection();
639
182
  if (sel === null) return;
640
183
  if (sel.getRangeAt && sel.rangeCount) {
641
- range = sel.getRangeAt(0);
184
+ range = currentRangeCached ?? sel.getRangeAt(0);
642
185
  range.deleteContents();
643
186
 
644
187
  // Range.createContextualFragment() would be useful here but is
645
188
  // non-standard and not supported in all browsers (IE9, for one)
646
- var el = document.createElement("div");
189
+ const el = document.createElement("div");
647
190
  el.innerHTML = html;
648
- var frag = document.createDocumentFragment();
649
- var node;
650
- var lastNode;
191
+ const frag = document.createDocumentFragment();
192
+ let node;
193
+ let lastNode;
651
194
  while (node = el.firstChild) {
652
195
  lastNode = frag.appendChild(node);
653
196
  }
@@ -656,6 +199,7 @@ function handlePasteHtmlAtCaret(html) {
656
199
  // Preserve the selection
657
200
  if (lastNode) {
658
201
  range = range.cloneRange();
202
+ currentRangeCached = range;
659
203
  range.setStartAfter(lastNode);
660
204
  range.collapse(true);
661
205
  sel.removeAllRanges();
@@ -671,8 +215,8 @@ function handlePasteHtmlAtCaret(html) {
671
215
  * @return {HTMLDivElement}
672
216
  */
673
217
  function replaceEmojiToString(container) {
674
- var images = Array.prototype.slice.call(container.querySelectorAll("img"));
675
- images.forEach(function (image) {
218
+ const images = Array.prototype.slice.call(container.querySelectorAll("img"));
219
+ images.forEach(image => {
676
220
  image.outerHTML = image.dataset.emoji;
677
221
  });
678
222
  return container;
@@ -683,11 +227,12 @@ function replaceEmojiToString(container) {
683
227
  * @param {{text: string, html: string}} props
684
228
  * @return {number}
685
229
  */
686
- function totalCharacters(_ref2) {
687
- var text = _ref2.text,
688
- html = _ref2.html;
689
- var textCount = text.length;
690
- var emojisCount = (html.match(/<img/g) || []).length;
230
+ function totalCharacters({
231
+ text,
232
+ html
233
+ }) {
234
+ const textCount = text.length;
235
+ const emojisCount = (html.match(/<img/g) || []).length;
691
236
  return textCount + emojisCount;
692
237
  }
693
238
  /**
@@ -696,12 +241,12 @@ function totalCharacters(_ref2) {
696
241
  * @return {string}
697
242
  */
698
243
  function removeHtmlExceptBr(inputDiv) {
699
- var temp = inputDiv.innerHTML.replaceAll(/<br\s*\/?>/gi, "[BR]"); // temporarily replace <br> with placeholder
700
- var tempContainer = document.createElement("div");
244
+ const temp = inputDiv.innerHTML.replaceAll(/<br\s*\/?>/gi, "[BR]"); // temporarily replace <br> with placeholder
245
+ const tempContainer = document.createElement("div");
701
246
  tempContainer.innerHTML = temp;
702
- var stripped = tempContainer.innerText; // strip all html tags
703
- var _final = stripped.replaceAll(/\[BR\]/gi, "</br>"); // replace placeholders with <br>
704
- return _final;
247
+ const stripped = tempContainer.innerText; // strip all html tags
248
+ const final = stripped.replaceAll(/\[BR\]/gi, "</br>"); // replace placeholders with <br>
249
+ return final;
705
250
  }
706
251
 
707
252
  /**
@@ -710,8 +255,8 @@ function removeHtmlExceptBr(inputDiv) {
710
255
  * @returns
711
256
  */
712
257
  function getSelectionStart$1(range) {
713
- var node = range.startContainer;
714
- var offset = range.startOffset;
258
+ let node = range.startContainer;
259
+ let offset = range.startOffset;
715
260
 
716
261
  // Handle cases where the selection start node is not a text node
717
262
  if (node.nodeType !== Node.TEXT_NODE) {
@@ -728,8 +273,8 @@ function getSelectionStart$1(range) {
728
273
  offset = 0;
729
274
  }
730
275
  return {
731
- node: node,
732
- offset: offset
276
+ node,
277
+ offset
733
278
  };
734
279
  }
735
280
 
@@ -738,13 +283,13 @@ function getSelectionStart$1(range) {
738
283
  * @return {Object} cursor
739
284
  */
740
285
  function getCursor() {
741
- var selection = window.getSelection();
742
- var range = selection.getRangeAt(0);
743
- var selectionStart = getSelectionStart$1(range);
286
+ const selection = window.getSelection();
287
+ const range = selection.getRangeAt(0);
288
+ const selectionStart = getSelectionStart$1(range);
744
289
  return {
745
- selection: selection,
746
- range: range,
747
- selectionStart: selectionStart
290
+ selection,
291
+ range,
292
+ selectionStart
748
293
  };
749
294
  }
750
295
 
@@ -752,30 +297,31 @@ function getCursor() {
752
297
  *
753
298
  */
754
299
  function addLineBreak() {
755
- var _getCursor = getCursor(),
756
- selection = _getCursor.selection,
757
- range = _getCursor.range,
758
- selectionStart = _getCursor.selectionStart;
300
+ const {
301
+ selection,
302
+ range,
303
+ selectionStart
304
+ } = getCursor();
759
305
 
760
306
  // If cursor is at the end of the text content, add one more line break
761
307
  if (selection.isCollapsed && selectionStart.offset === selectionStart.node.textContent.length) {
762
- var br = document.createElement("br");
308
+ const br = document.createElement("br");
763
309
  range.insertNode(br);
764
310
  range.setStartAfter(br);
765
311
  range.setEndAfter(br);
766
312
  selection.removeAllRanges();
767
313
  selection.addRange(range);
768
- var br2 = document.createElement("br");
314
+ const br2 = document.createElement("br");
769
315
  range.insertNode(br2);
770
316
  range.setStartAfter(br2);
771
317
  range.setEndAfter(br2);
772
318
  selection.removeAllRanges();
773
319
  selection.addRange(range);
774
320
  } else {
775
- var _br = document.createElement("br");
776
- range.insertNode(_br);
777
- range.setStartAfter(_br);
778
- range.setEndAfter(_br);
321
+ const br = document.createElement("br");
322
+ range.insertNode(br);
323
+ range.setStartAfter(br);
324
+ range.setEndAfter(br);
779
325
  selection.removeAllRanges();
780
326
  selection.addRange(range);
781
327
  // Set cursor position right before the first letter after the line break
@@ -994,7 +540,7 @@ var reactEasyEmoji = function reactEasyEmoji(element, optionsOrFn) {
994
540
  var emoji = reactEasyEmoji;
995
541
 
996
542
  // @ts-check
997
- var EMOJI_REGEX = new RegExp(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g);
543
+ const EMOJI_REGEX = new RegExp(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g);
998
544
 
999
545
  /**
1000
546
  * @typedef {import('../types/types').SanitizeFn} SanitizeFn
@@ -1007,17 +553,17 @@ var EMOJI_REGEX = new RegExp(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\
1007
553
  */
1008
554
  function useSanitize(shouldReturn, shouldConvertEmojiToImage) {
1009
555
  /** @type {React.MutableRefObject<SanitizeFn[]>} */
1010
- var sanitizeFnsRef = React.useRef([]);
1011
- var sanitizedTextRef = React.useRef("");
556
+ const sanitizeFnsRef = React.useRef([]);
557
+ const sanitizedTextRef = React.useRef("");
1012
558
 
1013
559
  /** @type {(fn: SanitizeFn) => void} */
1014
- var addSanitizeFn = React.useCallback(function (fn) {
560
+ const addSanitizeFn = React.useCallback(fn => {
1015
561
  sanitizeFnsRef.current.push(fn);
1016
562
  }, []);
1017
563
 
1018
564
  /** @type {(html: string) => string} */
1019
- var sanitize = React.useCallback(function (html) {
1020
- var result = sanitizeFnsRef.current.reduce(function (acc, fn) {
565
+ const sanitize = React.useCallback(html => {
566
+ let result = sanitizeFnsRef.current.reduce((acc, fn) => {
1021
567
  return fn(acc);
1022
568
  }, html);
1023
569
  result = replaceAllHtmlToString(result, shouldReturn);
@@ -1028,9 +574,9 @@ function useSanitize(shouldReturn, shouldConvertEmojiToImage) {
1028
574
  return result;
1029
575
  }, [shouldReturn, shouldConvertEmojiToImage]);
1030
576
  return {
1031
- addSanitizeFn: addSanitizeFn,
1032
- sanitize: sanitize,
1033
- sanitizedTextRef: sanitizedTextRef
577
+ addSanitizeFn,
578
+ sanitize,
579
+ sanitizedTextRef
1034
580
  };
1035
581
  }
1036
582
 
@@ -1041,9 +587,9 @@ function useSanitize(shouldReturn, shouldConvertEmojiToImage) {
1041
587
  * @return {string}
1042
588
  */
1043
589
  function replaceAllHtmlToString(html, shouldReturn) {
1044
- var container = document.createElement("div");
590
+ const container = document.createElement("div");
1045
591
  container.innerHTML = html;
1046
- var text;
592
+ let text;
1047
593
  if (shouldReturn) {
1048
594
  text = removeHtmlExceptBr(container);
1049
595
  } else {
@@ -1092,35 +638,35 @@ function handleEmoji(text) {
1092
638
  *
1093
639
  * @param {Props} props
1094
640
  */
1095
- function useExpose(_ref) {
1096
- var ref = _ref.ref,
1097
- textInputRef = _ref.textInputRef,
1098
- setValue = _ref.setValue,
1099
- emitChange = _ref.emitChange,
1100
- shouldConvertEmojiToImage = _ref.shouldConvertEmojiToImage;
1101
- var _useSanitize = useSanitize(false, shouldConvertEmojiToImage),
1102
- sanitize = _useSanitize.sanitize,
1103
- sanitizedTextRef = _useSanitize.sanitizedTextRef;
1104
- React.useImperativeHandle(ref, function () {
1105
- return {
1106
- get value() {
1107
- return sanitizedTextRef.current;
1108
- },
1109
- set value(value) {
1110
- setValue(value);
1111
- },
1112
- focus: function focus() {
1113
- if (textInputRef.current === null) return;
1114
- textInputRef.current.focus();
1115
- },
1116
- blur: function blur() {
1117
- if (textInputRef.current !== null) {
1118
- sanitize(textInputRef.current.html);
1119
- }
1120
- emitChange();
641
+ function useExpose({
642
+ ref,
643
+ textInputRef,
644
+ setValue,
645
+ emitChange,
646
+ shouldConvertEmojiToImage
647
+ }) {
648
+ const {
649
+ sanitize,
650
+ sanitizedTextRef
651
+ } = useSanitize(false, shouldConvertEmojiToImage);
652
+ React.useImperativeHandle(ref, () => ({
653
+ get value() {
654
+ return sanitizedTextRef.current;
655
+ },
656
+ set value(value) {
657
+ setValue(value);
658
+ },
659
+ focus: () => {
660
+ if (textInputRef.current === null) return;
661
+ textInputRef.current.focus();
662
+ },
663
+ blur: () => {
664
+ if (textInputRef.current !== null) {
665
+ sanitize(textInputRef.current.html);
1121
666
  }
1122
- };
1123
- });
667
+ emitChange();
668
+ }
669
+ }));
1124
670
  }
1125
671
 
1126
672
  // @ts-check
@@ -1134,19 +680,19 @@ function useExpose(_ref) {
1134
680
  */
1135
681
  function useEmit(textInputRef, onResize, onChange) {
1136
682
  /** @type {React.MutableRefObject<{width: number; height: number} | null>} */
1137
- var currentSizeRef = React.useRef(null);
1138
- var onChangeFn = React.useRef(onChange);
1139
- var checkAndEmitResize = React.useCallback(function () {
683
+ const currentSizeRef = React.useRef(null);
684
+ const onChangeFn = React.useRef(onChange);
685
+ const checkAndEmitResize = React.useCallback(() => {
1140
686
  if (textInputRef.current !== null) {
1141
- var currentSize = currentSizeRef.current;
1142
- var nextSize = textInputRef.current.size;
687
+ const currentSize = currentSizeRef.current;
688
+ const nextSize = textInputRef.current.size;
1143
689
  if ((!currentSize || currentSize.width !== nextSize.width || currentSize.height !== nextSize.height) && typeof onResize === "function") {
1144
690
  onResize(nextSize);
1145
691
  }
1146
692
  currentSizeRef.current = nextSize;
1147
693
  }
1148
694
  }, [onResize, textInputRef]);
1149
- var emitChange = React.useCallback(function (sanitizedText) {
695
+ const emitChange = React.useCallback(sanitizedText => {
1150
696
  if (typeof onChangeFn.current === "function") {
1151
697
  onChangeFn.current(sanitizedText);
1152
698
  }
@@ -1154,7 +700,7 @@ function useEmit(textInputRef, onResize, onChange) {
1154
700
  checkAndEmitResize();
1155
701
  }
1156
702
  }, [checkAndEmitResize, onResize]);
1157
- React.useEffect(function () {
703
+ React.useEffect(() => {
1158
704
  if (textInputRef.current) {
1159
705
  checkAndEmitResize();
1160
706
  }
@@ -1162,7 +708,7 @@ function useEmit(textInputRef, onResize, onChange) {
1162
708
  return emitChange;
1163
709
  }
1164
710
 
1165
- var _excluded = ["placeholder", "style", "tabIndex", "className", "onChange"];
711
+ // @ts-check
1166
712
 
1167
713
  /**
1168
714
  * @typedef {Object} Props
@@ -1196,97 +742,96 @@ var _excluded = ["placeholder", "style", "tabIndex", "className", "onChange"];
1196
742
 
1197
743
  // eslint-disable-next-line valid-jsdoc
1198
744
  /** @type {React.ForwardRefRenderFunction<Ref, Props>} */
1199
- var TextInput = function TextInput(_ref, ref) {
1200
- var placeholder = _ref.placeholder,
1201
- style = _ref.style,
1202
- tabIndex = _ref.tabIndex,
1203
- className = _ref.className,
1204
- onChange = _ref.onChange,
1205
- props = _objectWithoutProperties(_ref, _excluded);
1206
- React.useImperativeHandle(ref, function () {
1207
- return {
1208
- appendContent: function appendContent(html) {
1209
- if (textInputRef.current) {
1210
- textInputRef.current.focus();
1211
- }
1212
- handlePasteHtmlAtCaret(html);
1213
- if (textInputRef.current) {
1214
- textInputRef.current.focus();
1215
- }
1216
- if (textInputRef.current && placeholderRef.current && replaceAllTextEmojiToString(textInputRef.current.innerHTML) === "") {
745
+ const TextInput = ({
746
+ placeholder,
747
+ style,
748
+ tabIndex,
749
+ className,
750
+ onChange,
751
+ ...props
752
+ }, ref) => {
753
+ React.useImperativeHandle(ref, () => ({
754
+ appendContent: html => {
755
+ if (textInputRef.current) {
756
+ textInputRef.current.focus();
757
+ }
758
+ handlePasteHtmlAtCaret(html);
759
+ if (textInputRef.current) {
760
+ textInputRef.current.focus();
761
+ }
762
+ if (textInputRef.current && placeholderRef.current && replaceAllTextEmojiToString(textInputRef.current.innerHTML) === "") {
763
+ placeholderRef.current.style.visibility = "visible";
764
+ } else if (placeholderRef.current) {
765
+ placeholderRef.current.style.visibility = "hidden";
766
+ }
767
+ if (textInputRef.current && typeof onChange === 'function') {
768
+ onChange(textInputRef.current.innerHTML);
769
+ }
770
+ },
771
+ set html(value) {
772
+ if (textInputRef.current) {
773
+ textInputRef.current.innerHTML = value;
774
+ }
775
+ if (placeholderRef.current) {
776
+ const text = replaceAllTextEmojiToString(value);
777
+ if (text === "") {
1217
778
  placeholderRef.current.style.visibility = "visible";
1218
- } else if (placeholderRef.current) {
779
+ } else {
1219
780
  placeholderRef.current.style.visibility = "hidden";
1220
781
  }
1221
- if (textInputRef.current && typeof onChange === 'function') {
1222
- onChange(textInputRef.current.innerHTML);
1223
- }
1224
- },
1225
- set html(value) {
1226
- if (textInputRef.current) {
1227
- textInputRef.current.innerHTML = value;
1228
- }
1229
- if (placeholderRef.current) {
1230
- var text = replaceAllTextEmojiToString(value);
1231
- if (text === "") {
1232
- placeholderRef.current.style.visibility = "visible";
1233
- } else {
1234
- placeholderRef.current.style.visibility = "hidden";
1235
- }
1236
- }
1237
- if (typeof onChange === 'function' && textInputRef.current) {
1238
- onChange(textInputRef.current.innerHTML);
1239
- }
1240
- },
1241
- get html() {
1242
- if (!textInputRef.current) return '';
1243
- return textInputRef.current.innerHTML;
1244
- },
1245
- get text() {
1246
- if (!textInputRef.current) return '';
1247
- return textInputRef.current.innerText;
1248
- },
1249
- get size() {
1250
- if (!textInputRef.current) {
1251
- return {
1252
- width: 0,
1253
- height: 0
1254
- };
1255
- }
782
+ }
783
+ if (typeof onChange === 'function' && textInputRef.current) {
784
+ onChange(textInputRef.current.innerHTML);
785
+ }
786
+ },
787
+ get html() {
788
+ if (!textInputRef.current) return '';
789
+ return textInputRef.current.innerHTML;
790
+ },
791
+ get text() {
792
+ if (!textInputRef.current) return '';
793
+ return textInputRef.current.innerText;
794
+ },
795
+ get size() {
796
+ if (!textInputRef.current) {
1256
797
  return {
1257
- width: textInputRef.current.offsetWidth,
1258
- height: textInputRef.current.offsetHeight
798
+ width: 0,
799
+ height: 0
1259
800
  };
1260
- },
1261
- focus: function focus() {
1262
- if (!textInputRef.current) return;
1263
- textInputRef.current.focus();
1264
801
  }
1265
- };
1266
- });
802
+ return {
803
+ width: textInputRef.current.offsetWidth,
804
+ height: textInputRef.current.offsetHeight
805
+ };
806
+ },
807
+ focus() {
808
+ if (!textInputRef.current) return;
809
+ textInputRef.current.focus();
810
+ }
811
+ }));
1267
812
 
1268
813
  /** @type {React.CSSProperties} */
1269
- var placeholderStyle = React.useMemo(function () {
1270
- var placeholderStyle = {};
814
+ const placeholderStyle = React.useMemo(() => {
815
+ const placeholderStyle = {};
1271
816
  if (style.placeholderColor) {
1272
817
  placeholderStyle.color = style.placeholderColor;
1273
818
  }
1274
819
  return placeholderStyle;
1275
- }, [style === null || style === void 0 ? void 0 : style.placeholderColor]);
820
+ }, [style?.placeholderColor]);
1276
821
 
1277
822
  /** @type {React.CSSProperties} */
1278
- var inputStyle = React.useMemo(function () {
1279
- var inputStyle = {};
823
+ const inputStyle = React.useMemo(() => {
824
+ const inputStyle = {};
1280
825
  if (style.color) {
1281
826
  inputStyle.color = style.color;
1282
827
  }
1283
828
  return inputStyle;
1284
- }, [style === null || style === void 0 ? void 0 : style.color]);
829
+ }, [style?.color]);
1285
830
 
1286
831
  /** @type {React.MutableRefObject<HTMLDivElement | null>} */
1287
- var placeholderRef = React.useRef(null);
832
+ const placeholderRef = React.useRef(null);
1288
833
  /** @type {React.MutableRefObject<HTMLDivElement | null>} */
1289
- var textInputRef = React.useRef(null);
834
+ const textInputRef = React.useRef(null);
1290
835
 
1291
836
  /**
1292
837
  *
@@ -1325,9 +870,9 @@ var TextInput = function TextInput(_ref, ref) {
1325
870
  */
1326
871
  function handleKeyUp(event) {
1327
872
  props.onKeyUp(event);
1328
- var input = textInputRef.current;
873
+ const input = textInputRef.current;
1329
874
  if (placeholderRef.current && input) {
1330
- var text = replaceAllTextEmojiToString(input.innerHTML);
875
+ const text = replaceAllTextEmojiToString(input.innerHTML);
1331
876
  if (text === "") {
1332
877
  placeholderRef.current.style.visibility = "visible";
1333
878
  } else {
@@ -1354,7 +899,7 @@ var TextInput = function TextInput(_ref, ref) {
1354
899
  onKeyUp: handleKeyUp,
1355
900
  tabIndex: tabIndex,
1356
901
  contentEditable: true,
1357
- className: "react-input-emoji--input".concat(className ? " ".concat(className) : ""),
902
+ className: `react-input-emoji--input${className ? ` ${className}` : ""}`,
1358
903
  onBlur: props.onBlur,
1359
904
  onCopy: props.onCopy,
1360
905
  onPaste: props.onPaste,
@@ -1362,7 +907,9 @@ var TextInput = function TextInput(_ref, ref) {
1362
907
  style: inputStyle
1363
908
  })));
1364
909
  };
1365
- var TextInputWithRef = /*#__PURE__*/React.forwardRef(TextInput);
910
+ const TextInputWithRef = /*#__PURE__*/React.forwardRef(TextInput);
911
+
912
+ // vendors
1366
913
 
1367
914
  /**
1368
915
  * @typedef {object} Props
@@ -1377,30 +924,27 @@ var TextInputWithRef = /*#__PURE__*/React.forwardRef(TextInput);
1377
924
  * @param {Props} props
1378
925
  * @return {JSX.Element}
1379
926
  */
1380
- function EmojiPickerButton(_ref) {
1381
- var showPicker = _ref.showPicker,
1382
- toggleShowPicker = _ref.toggleShowPicker,
1383
- buttonElement = _ref.buttonElement,
1384
- buttonRef = _ref.buttonRef;
1385
- var localButtonRef = React.useRef(null);
1386
- var _useState = React.useState(false),
1387
- _useState2 = _slicedToArray(_useState, 2),
1388
- showCustomButtonContent = _useState2[0],
1389
- setShowCustomButtonContent = _useState2[1];
1390
- React.useEffect(function () {
1391
- var _buttonRef$current$ch, _buttonRef$current, _buttonElement$childN, _buttonElement$childN2;
1392
- if (((_buttonRef$current$ch = buttonRef === null || buttonRef === void 0 || (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || (_buttonRef$current = _buttonRef$current.childNodes) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.length) !== null && _buttonRef$current$ch !== void 0 ? _buttonRef$current$ch : 0) > 2) {
927
+ function EmojiPickerButton({
928
+ showPicker,
929
+ toggleShowPicker,
930
+ buttonElement,
931
+ buttonRef
932
+ }) {
933
+ const localButtonRef = React.useRef(null);
934
+ const [showCustomButtonContent, setShowCustomButtonContent] = React.useState(false);
935
+ React.useEffect(() => {
936
+ if ((buttonRef?.current?.childNodes?.length ?? 0) > 2) {
1393
937
  localButtonRef.current.appendChild(buttonRef.current.childNodes[0]);
1394
938
  setShowCustomButtonContent(true);
1395
- } else if (((_buttonElement$childN = buttonElement === null || buttonElement === void 0 || (_buttonElement$childN2 = buttonElement.childNodes) === null || _buttonElement$childN2 === void 0 ? void 0 : _buttonElement$childN2.length) !== null && _buttonElement$childN !== void 0 ? _buttonElement$childN : 0) > 2) {
1396
- localButtonRef.current.appendChild(buttonElement === null || buttonElement === void 0 ? void 0 : buttonElement.childNodes[0]);
939
+ } else if ((buttonElement?.childNodes?.length ?? 0) > 2) {
940
+ localButtonRef.current.appendChild(buttonElement?.childNodes[0]);
1397
941
  setShowCustomButtonContent(true);
1398
942
  }
1399
- }, [buttonElement === null || buttonElement === void 0 ? void 0 : buttonElement.childNodes]);
943
+ }, [buttonElement?.childNodes]);
1400
944
  return /*#__PURE__*/React__default["default"].createElement("button", {
1401
945
  ref: localButtonRef,
1402
946
  type: "button",
1403
- className: "react-input-emoji--button".concat(showPicker ? " react-input-emoji--button__show" : ""),
947
+ className: `react-input-emoji--button${showPicker ? " react-input-emoji--button__show" : ""}`,
1404
948
  onClick: toggleShowPicker
1405
949
  }, !showCustomButtonContent && /*#__PURE__*/React__default["default"].createElement("svg", {
1406
950
  xmlns: "http://www.w3.org/2000/svg",
@@ -3852,8 +3396,9 @@ function $e5534fc185f7111e$export$2e2bcd8739ae039(props) {
3852
3396
  });
3853
3397
  }
3854
3398
 
3855
- var EMOJI_MART_DATA_URL = "https://cdn.jsdelivr.net/npm/@emoji-mart/data";
3856
- var cacheI18n = {};
3399
+ // vendors
3400
+ const EMOJI_MART_DATA_URL = "https://cdn.jsdelivr.net/npm/@emoji-mart/data";
3401
+ const cacheI18n = {};
3857
3402
 
3858
3403
  /**
3859
3404
  * @typedef {object} Props
@@ -3869,55 +3414,38 @@ var cacheI18n = {};
3869
3414
  * @param {Props} props
3870
3415
  */
3871
3416
  function EmojiPicker(props) {
3872
- var theme = props.theme,
3873
- onSelectEmoji = props.onSelectEmoji,
3874
- disableRecent = props.disableRecent,
3875
- customEmojis = props.customEmojis,
3876
- language = props.language;
3417
+ const {
3418
+ theme,
3419
+ onSelectEmoji,
3420
+ disableRecent,
3421
+ customEmojis,
3422
+ language
3423
+ } = props;
3877
3424
 
3878
3425
  /** @type {string[]} */
3879
- var categories = React.useMemo(function () {
3426
+ const categories = React.useMemo(() => {
3880
3427
  /** @type {string[]} */
3881
- var categoryies = [];
3428
+ let categoryies = [];
3882
3429
  if (!disableRecent) {
3883
3430
  categoryies.push("frequent");
3884
3431
  }
3885
- categoryies = [].concat(_toConsumableArray(categoryies), ["people", "nature", "foods", "activity", "places", "objects", "symbols", "flags"]);
3432
+ categoryies = [...categoryies, "people", "nature", "foods", "activity", "places", "objects", "symbols", "flags"];
3886
3433
  return categoryies;
3887
3434
  }, [disableRecent]);
3888
- var _useState = React.useState(undefined),
3889
- _useState2 = _slicedToArray(_useState, 2),
3890
- i18n = _useState2[0],
3891
- setI18n = _useState2[1];
3892
- React.useEffect(function () {
3893
- var _ref2;
3435
+ const [i18n, setI18n] = React.useState(undefined);
3436
+ React.useEffect(() => {
3894
3437
  if (!language) {
3895
- var _ref;
3896
3438
  if (cacheI18n.en) {
3897
3439
  setI18n(cacheI18n.en);
3898
3440
  return;
3899
3441
  }
3900
3442
 
3901
3443
  // @ts-ignore
3902
- fetch("".concat(EMOJI_MART_DATA_URL, "/i18n/en.json")).then(function (_x) {
3903
- return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
3904
- var translations;
3905
- return _regeneratorRuntime().wrap(function _callee$(_context) {
3906
- while (1) switch (_context.prev = _context.next) {
3907
- case 0:
3908
- _context.next = 2;
3909
- return data.json();
3910
- case 2:
3911
- translations = _context.sent;
3912
- setI18n(translations);
3913
- cacheI18n.en = translations;
3914
- case 5:
3915
- case "end":
3916
- return _context.stop();
3917
- }
3918
- }, _callee);
3919
- }))).apply(this, arguments);
3920
- })["catch"](function (error) {
3444
+ fetch(`${EMOJI_MART_DATA_URL}/i18n/en.json`).then(async data => {
3445
+ const translations = await data.json();
3446
+ setI18n(translations);
3447
+ cacheI18n.en = translations;
3448
+ }).catch(error => {
3921
3449
  console.error("Failed to load translations:", error);
3922
3450
  });
3923
3451
  return;
@@ -3928,25 +3456,11 @@ function EmojiPicker(props) {
3928
3456
  }
3929
3457
 
3930
3458
  // @ts-ignore
3931
- fetch("".concat(EMOJI_MART_DATA_URL, "/i18n/").concat(language, ".json")).then(function (_x2) {
3932
- return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
3933
- var translations;
3934
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3935
- while (1) switch (_context2.prev = _context2.next) {
3936
- case 0:
3937
- _context2.next = 2;
3938
- return data.json();
3939
- case 2:
3940
- translations = _context2.sent;
3941
- setI18n(translations);
3942
- cacheI18n[language] = translations;
3943
- case 5:
3944
- case "end":
3945
- return _context2.stop();
3946
- }
3947
- }, _callee2);
3948
- }))).apply(this, arguments);
3949
- })["catch"](function (error) {
3459
+ fetch(`${EMOJI_MART_DATA_URL}/i18n/${language}.json`).then(async data => {
3460
+ const translations = await data.json();
3461
+ setI18n(translations);
3462
+ cacheI18n[language] = translations;
3463
+ }).catch(error => {
3950
3464
  console.error("Failed to load translations:", error);
3951
3465
  });
3952
3466
  }, [language]);
@@ -3982,21 +3496,20 @@ var EmojiPicker$1 = /*#__PURE__*/React.memo(EmojiPicker);
3982
3496
  * @param {Props} props
3983
3497
  * @return {JSX.Element}
3984
3498
  */
3985
- function EmojiPickerContainer(_ref) {
3986
- var showPicker = _ref.showPicker,
3987
- theme = _ref.theme,
3988
- handleSelectEmoji = _ref.handleSelectEmoji,
3989
- disableRecent = _ref.disableRecent,
3990
- customEmojis = _ref.customEmojis,
3991
- position = _ref.position,
3992
- language = _ref.language;
3499
+ function EmojiPickerContainer({
3500
+ showPicker,
3501
+ theme,
3502
+ handleSelectEmoji,
3503
+ disableRecent,
3504
+ customEmojis,
3505
+ position,
3506
+ language
3507
+ }) {
3993
3508
  return /*#__PURE__*/React__default["default"].createElement("div", {
3994
3509
  className: "react-emoji-picker--container"
3995
3510
  }, showPicker && /*#__PURE__*/React__default["default"].createElement("div", {
3996
3511
  className: "react-emoji-picker--wrapper",
3997
- onClick: function onClick(evt) {
3998
- return evt.stopPropagation();
3999
- },
3512
+ onClick: evt => evt.stopPropagation(),
4000
3513
  style: position === 'below' ? {
4001
3514
  top: '40px'
4002
3515
  } : {}
@@ -4011,7 +3524,8 @@ function EmojiPickerContainer(_ref) {
4011
3524
  }))));
4012
3525
  }
4013
3526
 
4014
- var EMOJI_PICKER_CONTAINER_HEIGHT = 435;
3527
+ // @ts-check
3528
+ const EMOJI_PICKER_CONTAINER_HEIGHT = 435;
4015
3529
 
4016
3530
  /**
4017
3531
  * @typedef {import('../types/types').SanitizeFn} SanitizeFn
@@ -4037,38 +3551,36 @@ var EMOJI_PICKER_CONTAINER_HEIGHT = 435;
4037
3551
 
4038
3552
  // eslint-disable-next-line valid-jsdoc
4039
3553
  /** @type {React.FC<Props>} */
4040
- var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
4041
- var theme = props.theme,
4042
- keepOpened = props.keepOpened,
4043
- disableRecent = props.disableRecent,
4044
- customEmojis = props.customEmojis,
4045
- addSanitizeFn = props.addSanitizeFn,
4046
- addPolluteFn = props.addPolluteFn,
4047
- appendContent = props.appendContent,
4048
- buttonElement = props.buttonElement,
4049
- buttonRef = props.buttonRef,
4050
- language = props.language;
4051
- var _useState = React.useState(false),
4052
- _useState2 = _slicedToArray(_useState, 2),
4053
- showPicker = _useState2[0],
4054
- setShowPicker = _useState2[1];
3554
+ const EmojiPickerWrapper = props => {
3555
+ const {
3556
+ theme,
3557
+ keepOpened,
3558
+ disableRecent,
3559
+ customEmojis,
3560
+ addSanitizeFn,
3561
+ addPolluteFn,
3562
+ appendContent,
3563
+ buttonElement,
3564
+ buttonRef,
3565
+ language
3566
+ } = props;
3567
+ const [showPicker, setShowPicker] = React.useState(false);
4055
3568
  /** @type {[HTMLDivElement | undefined, React.Dispatch<React.SetStateAction<HTMLDivElement | undefined>>]} */
4056
- var _useState3 = React.useState(),
4057
- _useState4 = _slicedToArray(_useState3, 2),
4058
- customButton = _useState4[0],
4059
- setCustomButton = _useState4[1];
3569
+ const [customButton, setCustomButton] = React.useState();
4060
3570
  /** @type {['above' | 'below' | undefined, React.Dispatch<React.SetStateAction<'above' | 'below' | undefined>>]} */
4061
- var _useState5 = React.useState(),
4062
- _useState6 = _slicedToArray(_useState5, 2),
4063
- emojiPickerPosition = _useState6[0],
4064
- setEmojiPickerPosition = _useState6[1];
4065
- React.useEffect(function () {
3571
+ const [emojiPickerPosition, setEmojiPickerPosition] = React.useState();
3572
+ React.useEffect(() => {
3573
+ if (showPicker) {
3574
+ cacheCurrentRange();
3575
+ }
3576
+ }, [showPicker]);
3577
+ React.useEffect(() => {
4066
3578
  addSanitizeFn(replaceAllTextEmojiToString);
4067
3579
  }, [addSanitizeFn]);
4068
- React.useEffect(function () {
3580
+ React.useEffect(() => {
4069
3581
  addPolluteFn(replaceAllTextEmojis);
4070
3582
  }, [addPolluteFn]);
4071
- React.useEffect(function () {
3583
+ React.useEffect(() => {
4072
3584
  /**
4073
3585
  *
4074
3586
  * @param {MouseEvent} event
@@ -4076,14 +3588,14 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
4076
3588
  function checkClickOutside(event) {
4077
3589
  /** @type {HTMLElement} */
4078
3590
  // @ts-ignore
4079
- var element = event.target;
3591
+ const element = event.target;
4080
3592
  if (element.classList.contains("react-input-emoji--button") || element.classList.contains("react-input-emoji--button--icon")) {
4081
3593
  return;
4082
3594
  }
4083
3595
  setShowPicker(false);
4084
3596
  }
4085
3597
  document.addEventListener("click", checkClickOutside);
4086
- return function () {
3598
+ return () => {
4087
3599
  document.removeEventListener("click", checkClickOutside);
4088
3600
  };
4089
3601
  }, []);
@@ -4096,9 +3608,7 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
4096
3608
  event.stopPropagation();
4097
3609
  event.preventDefault();
4098
3610
  setEmojiPickerPosition(calcTopPosition(event));
4099
- setShowPicker(function (currentShowPicker) {
4100
- return !currentShowPicker;
4101
- });
3611
+ setShowPicker(currentShowPicker => !currentShowPicker);
4102
3612
  }
4103
3613
 
4104
3614
  /**
@@ -4107,9 +3617,9 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
4107
3617
  * @return {'above' | 'below'}
4108
3618
  */
4109
3619
  function calcTopPosition(event) {
4110
- var btn = event.currentTarget;
4111
- var btnRect = btn.getBoundingClientRect();
4112
- var popoverHeight = EMOJI_PICKER_CONTAINER_HEIGHT;
3620
+ const btn = event.currentTarget;
3621
+ const btnRect = btn.getBoundingClientRect();
3622
+ const popoverHeight = EMOJI_PICKER_CONTAINER_HEIGHT;
4113
3623
 
4114
3624
  // Decide to display above or below based on available space
4115
3625
  if (btnRect.top >= popoverHeight) {
@@ -4129,17 +3639,14 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
4129
3639
  function handleSelectEmoji(emoji) {
4130
3640
  appendContent(getImageEmoji(emoji));
4131
3641
  if (!keepOpened) {
4132
- setShowPicker(function (currentShowPicker) {
4133
- return !currentShowPicker;
4134
- });
3642
+ setShowPicker(currentShowPicker => !currentShowPicker);
4135
3643
  }
4136
3644
  }
4137
- React.useEffect(function () {
4138
- var _buttonRef$current;
4139
- if (buttonRef !== null && buttonRef !== void 0 && (_buttonRef$current = buttonRef.current) !== null && _buttonRef$current !== void 0 && _buttonRef$current.style) {
3645
+ React.useEffect(() => {
3646
+ if (buttonRef?.current?.style) {
4140
3647
  buttonRef.current.style.position = "relative";
4141
3648
  setCustomButton(buttonRef.current);
4142
- } else if (buttonElement !== null && buttonElement !== void 0 && buttonElement.style) {
3649
+ } else if (buttonElement?.style) {
4143
3650
  buttonElement.style.position = "relative";
4144
3651
  setCustomButton(buttonElement);
4145
3652
  }
@@ -4178,16 +3685,16 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
4178
3685
  * @return {string | null}
4179
3686
  */
4180
3687
  function getTextFromAtToCaret() {
4181
- var range = getRangeFromAtToCaret();
3688
+ const range = getRangeFromAtToCaret();
4182
3689
  if (!range) return null;
4183
- var text = range.text.substring(range.begin, range.end);
3690
+ const text = range.text.substring(range.begin, range.end);
4184
3691
  return text || null;
4185
3692
  }
4186
3693
 
4187
3694
  // eslint-disable-next-line valid-jsdoc
4188
3695
  /** */
4189
3696
  function deleteTextFromAtToCaret() {
4190
- var range = getRangeFromAtToCaret();
3697
+ const range = getRangeFromAtToCaret();
4191
3698
  if (!range) return;
4192
3699
 
4193
3700
  // @ts-ignore
@@ -4199,22 +3706,24 @@ function deleteTextFromAtToCaret() {
4199
3706
  * @return {{begin: number, end: number, text: string, element: Node} | null}
4200
3707
  */
4201
3708
  function getRangeFromAtToCaret() {
4202
- var elementWithFocus = getElementWithFocus();
3709
+ const elementWithFocus = getElementWithFocus();
4203
3710
  if (!elementWithFocus) {
4204
3711
  return null;
4205
3712
  }
4206
- var element = elementWithFocus.element,
4207
- caretOffset = elementWithFocus.caretOffset;
4208
- var text = element.textContent;
4209
- var lastAt = text.lastIndexOf("@");
3713
+ const {
3714
+ element,
3715
+ caretOffset
3716
+ } = elementWithFocus;
3717
+ const text = element.textContent;
3718
+ const lastAt = text.lastIndexOf("@");
4210
3719
  if (lastAt === -1 || lastAt >= caretOffset || lastAt !== 0 && text[lastAt - 1] !== " ") {
4211
3720
  return null;
4212
3721
  }
4213
3722
  return {
4214
3723
  begin: lastAt,
4215
3724
  end: caretOffset,
4216
- text: text,
4217
- element: element
3725
+ text,
3726
+ element
4218
3727
  };
4219
3728
  }
4220
3729
 
@@ -4223,14 +3732,14 @@ function getRangeFromAtToCaret() {
4223
3732
  * @return {{element: Node, caretOffset: number}}
4224
3733
  */
4225
3734
  function getElementWithFocus() {
4226
- var element = getSelectionStart();
3735
+ const element = getSelectionStart();
4227
3736
  if (element === null) {
4228
3737
  return null;
4229
3738
  }
4230
- var caretOffset = 0;
3739
+ let caretOffset = 0;
4231
3740
  if (typeof window.getSelection != "undefined") {
4232
- var range = window.getSelection().getRangeAt(0);
4233
- var preCaretRange = range.cloneRange();
3741
+ const range = window.getSelection().getRangeAt(0);
3742
+ const preCaretRange = range.cloneRange();
4234
3743
  preCaretRange.selectNodeContents(element);
4235
3744
  preCaretRange.setEnd(range.endContainer, range.endOffset);
4236
3745
  caretOffset = preCaretRange.toString().length;
@@ -4240,16 +3749,16 @@ function getElementWithFocus() {
4240
3749
  // @ts-ignore
4241
3750
  document.selection.type != "Control") {
4242
3751
  // @ts-ignore
4243
- var textRange = document.selection.createRange();
3752
+ const textRange = document.selection.createRange();
4244
3753
  // @ts-ignore
4245
- var preCaretTextRange = document.body.createTextRange();
3754
+ const preCaretTextRange = document.body.createTextRange();
4246
3755
  preCaretTextRange.moveToElementText(element);
4247
3756
  preCaretTextRange.setEndPoint("EndToEnd", textRange);
4248
3757
  caretOffset = preCaretTextRange.text.length;
4249
3758
  }
4250
3759
  return {
4251
- element: element,
4252
- caretOffset: caretOffset
3760
+ element,
3761
+ caretOffset
4253
3762
  };
4254
3763
  }
4255
3764
 
@@ -4258,10 +3767,12 @@ function getElementWithFocus() {
4258
3767
  * @return {Node | null}
4259
3768
  */
4260
3769
  function getSelectionStart() {
4261
- var node = document.getSelection().anchorNode;
4262
- return (node === null || node === void 0 ? void 0 : node.nodeType) == 3 ? node : null;
3770
+ const node = document.getSelection().anchorNode;
3771
+ return node?.nodeType == 3 ? node : null;
4263
3772
  }
4264
3773
 
3774
+ // @ts-check
3775
+
4265
3776
  /**
4266
3777
  * @typedef {import('../types/types').MentionUser} MentionUser
4267
3778
  */
@@ -4273,98 +3784,57 @@ function getSelectionStart() {
4273
3784
  * @returns {{mentionSearchText: string | null, mentionUsers: MentionUser[], onKeyUp: (event: React.KeyboardEvent) => void, onFocus: () => void, onSelectUser: () => void, loading: boolean}}
4274
3785
  */
4275
3786
  function useMention(searchMention) {
4276
- var _ref2;
4277
- var _useState = React.useState(false),
4278
- _useState2 = _slicedToArray(_useState, 2),
4279
- loading = _useState2[0],
4280
- setLoading = _useState2[1];
3787
+ const [loading, setLoading] = React.useState(false);
4281
3788
 
4282
3789
  /** @type {[MentionUser[], React.Dispatch<React.SetStateAction<MentionUser[]>>]} */
4283
- var _useState3 = React.useState([]),
4284
- _useState4 = _slicedToArray(_useState3, 2),
4285
- mentionUsers = _useState4[0],
4286
- setMentionUsers = _useState4[1];
3790
+ const [mentionUsers, setMentionUsers] = React.useState([]);
4287
3791
 
4288
3792
  /** @type {[string | null, React.Dispatch<React.SetStateAction<string | null>>]} */
4289
- var _useState5 = React.useState(null),
4290
- _useState6 = _slicedToArray(_useState5, 2),
4291
- mentionSearchText = _useState6[0],
4292
- setMentionSearchText = _useState6[1];
4293
- var onSelectUser = React.useCallback(function () {
3793
+ const [mentionSearchText, setMentionSearchText] = React.useState(null);
3794
+ const onSelectUser = React.useCallback(() => {
4294
3795
  deleteTextFromAtToCaret();
4295
3796
  setMentionUsers([]);
4296
3797
  }, []);
4297
3798
 
4298
3799
  /** */
4299
- var checkMentionText = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
4300
- var metionText, users;
4301
- return _regeneratorRuntime().wrap(function _callee$(_context) {
4302
- while (1) switch (_context.prev = _context.next) {
4303
- case 0:
4304
- metionText = getTextFromAtToCaret();
4305
- setMentionSearchText(metionText);
4306
- if (!(metionText === null)) {
4307
- _context.next = 6;
4308
- break;
4309
- }
4310
- setMentionUsers([]);
4311
- _context.next = 12;
4312
- break;
4313
- case 6:
4314
- setLoading(true);
4315
- _context.next = 9;
4316
- return searchMention(metionText);
4317
- case 9:
4318
- users = _context.sent;
4319
- setLoading(false);
4320
- setMentionUsers(users);
4321
- case 12:
4322
- case "end":
4323
- return _context.stop();
4324
- }
4325
- }, _callee);
4326
- })), [searchMention]);
3800
+ const checkMentionText = React.useCallback(async () => {
3801
+ const metionText = getTextFromAtToCaret();
3802
+ setMentionSearchText(metionText);
3803
+ if (metionText === null) {
3804
+ setMentionUsers([]);
3805
+ } else {
3806
+ setLoading(true);
3807
+ const users = await searchMention(metionText);
3808
+ setLoading(false);
3809
+ setMentionUsers(users);
3810
+ }
3811
+ }, [searchMention]);
4327
3812
 
4328
3813
  /** @type {(event: React.KeyboardEvent) => void} */
4329
- var onKeyUp = React.useCallback(function (_x) {
4330
- return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
4331
- var _getElementWithFocus;
4332
- var elementWithFocus;
4333
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4334
- while (1) switch (_context2.prev = _context2.next) {
4335
- case 0:
4336
- if (!(typeof searchMention !== "function")) {
4337
- _context2.next = 2;
4338
- break;
4339
- }
4340
- return _context2.abrupt("return");
4341
- case 2:
4342
- if (event.key === "Backspace" && (_getElementWithFocus = getElementWithFocus()) !== null && _getElementWithFocus !== void 0 && _getElementWithFocus.element.parentElement.hasAttribute("data-mention-id")) {
4343
- elementWithFocus = getElementWithFocus();
4344
- elementWithFocus.element.parentElement.remove();
4345
- } else if (!["ArrowUp", "ArrowDown", "Esc", "Escape"].includes(event.key)) {
4346
- checkMentionText();
4347
- }
4348
- case 3:
4349
- case "end":
4350
- return _context2.stop();
4351
- }
4352
- }, _callee2);
4353
- }))).apply(this, arguments);
3814
+ const onKeyUp = React.useCallback(async event => {
3815
+ if (typeof searchMention !== "function") return;
3816
+ if (event.key === "Backspace" && getElementWithFocus()?.element.parentElement.hasAttribute("data-mention-id")) {
3817
+ const elementWithFocus = getElementWithFocus();
3818
+ elementWithFocus.element.parentElement.remove();
3819
+ } else if (!["ArrowUp", "ArrowDown", "Esc", "Escape"].includes(event.key)) {
3820
+ checkMentionText();
3821
+ }
4354
3822
  }, [checkMentionText, searchMention]);
4355
- var onFocus = React.useCallback(function () {
3823
+ const onFocus = React.useCallback(() => {
4356
3824
  checkMentionText();
4357
3825
  }, [checkMentionText]);
4358
3826
  return {
4359
- mentionSearchText: mentionSearchText,
4360
- mentionUsers: mentionUsers,
4361
- onKeyUp: onKeyUp,
4362
- onFocus: onFocus,
4363
- onSelectUser: onSelectUser,
4364
- loading: loading
3827
+ mentionSearchText,
3828
+ mentionUsers,
3829
+ onKeyUp,
3830
+ onFocus,
3831
+ onSelectUser,
3832
+ loading
4365
3833
  };
4366
3834
  }
4367
3835
 
3836
+ // @ts-check
3837
+
4368
3838
  /**
4369
3839
  * @typedef {import('../types/types').MentionUser} MentionUser
4370
3840
  */
@@ -4387,36 +3857,32 @@ function useMention(searchMention) {
4387
3857
 
4388
3858
  // eslint-disable-next-line valid-jsdoc
4389
3859
  /** @type {React.ForwardRefRenderFunction<Ref, Props>} */
4390
- var MentionUserList = function MentionUserList(_ref, ref) {
4391
- var users = _ref.users,
4392
- mentionSearchText = _ref.mentionSearchText,
4393
- onSelect = _ref.onSelect,
4394
- addEventListener = _ref.addEventListener;
4395
- var _useState = React.useState(0),
4396
- _useState2 = _slicedToArray(_useState, 2),
4397
- selectedUser = _useState2[0],
4398
- setSelectedUser = _useState2[1];
4399
- React.useImperativeHandle(ref, function () {
4400
- return {
4401
- prevUser: function prevUser() {
4402
- setSelectedUser(function (currentSelectedUser) {
4403
- if (currentSelectedUser === 0) {
4404
- return 0;
4405
- }
4406
- return currentSelectedUser - 1;
4407
- });
4408
- },
4409
- nextUser: function nextUser() {
4410
- setSelectedUser(function (currentSelectedUser) {
4411
- if (currentSelectedUser === users.length - 1) {
4412
- return users.length - 1;
4413
- }
4414
- return currentSelectedUser + 1;
4415
- });
4416
- }
4417
- };
4418
- });
4419
- React.useEffect(function () {
3860
+ const MentionUserList = ({
3861
+ users,
3862
+ mentionSearchText,
3863
+ onSelect,
3864
+ addEventListener
3865
+ }, ref) => {
3866
+ const [selectedUser, setSelectedUser] = React.useState(0);
3867
+ React.useImperativeHandle(ref, () => ({
3868
+ prevUser: () => {
3869
+ setSelectedUser(currentSelectedUser => {
3870
+ if (currentSelectedUser === 0) {
3871
+ return 0;
3872
+ }
3873
+ return currentSelectedUser - 1;
3874
+ });
3875
+ },
3876
+ nextUser: () => {
3877
+ setSelectedUser(currentSelectedUser => {
3878
+ if (currentSelectedUser === users.length - 1) {
3879
+ return users.length - 1;
3880
+ }
3881
+ return currentSelectedUser + 1;
3882
+ });
3883
+ }
3884
+ }));
3885
+ React.useEffect(() => {
4420
3886
  setSelectedUser(0);
4421
3887
  }, [users]);
4422
3888
 
@@ -4427,20 +3893,20 @@ var MentionUserList = function MentionUserList(_ref, ref) {
4427
3893
  * @return {string}
4428
3894
  */
4429
3895
  function getMentionSelectedNameEl(selectedText, rest) {
4430
- return "<span class=\"react-input-emoji--mention--item--name__selected\" data-testid=\"metion-selected-word\">".concat(selectedText, "</span>").concat(rest);
3896
+ return `<span class="react-input-emoji--mention--item--name__selected" data-testid="metion-selected-word">${selectedText}</span>${rest}`;
4431
3897
  }
4432
3898
 
4433
3899
  /** @type {(MentionUser & {nameHtml: string})[]} */
4434
- var usersFiltered = React.useMemo(function () {
4435
- var searchText = mentionSearchText ? mentionSearchText.substring(1).toLocaleLowerCase() : "";
4436
- return users.map(function (user) {
4437
- var nameHtml = user.name;
3900
+ const usersFiltered = React.useMemo(() => {
3901
+ const searchText = mentionSearchText ? mentionSearchText.substring(1).toLocaleLowerCase() : "";
3902
+ return users.map(user => {
3903
+ let nameHtml = user.name;
4438
3904
  if (mentionSearchText && mentionSearchText.length > 1) {
4439
3905
  if (user.name.toLowerCase().startsWith(searchText)) {
4440
3906
  nameHtml = getMentionSelectedNameEl(user.name.substring(0, searchText.length), user.name.substring(searchText.length));
4441
3907
  } else {
4442
- var names = user.name.split(" ");
4443
- nameHtml = names.map(function (name) {
3908
+ const names = user.name.split(" ");
3909
+ nameHtml = names.map(name => {
4444
3910
  if (name.toLocaleLowerCase().startsWith(searchText)) {
4445
3911
  return getMentionSelectedNameEl(name.substring(0, searchText.length), name.substring(searchText.length));
4446
3912
  }
@@ -4448,9 +3914,10 @@ var MentionUserList = function MentionUserList(_ref, ref) {
4448
3914
  }).join(" ");
4449
3915
  }
4450
3916
  }
4451
- return _objectSpread2(_objectSpread2({}, user), {}, {
4452
- nameHtml: nameHtml
4453
- });
3917
+ return {
3918
+ ...user,
3919
+ nameHtml
3920
+ };
4454
3921
  });
4455
3922
  }, [mentionSearchText, users]);
4456
3923
 
@@ -4461,47 +3928,45 @@ var MentionUserList = function MentionUserList(_ref, ref) {
4461
3928
  * @returns {(event: React.MouseEvent) => void} event
4462
3929
  */
4463
3930
  function handleClick(user) {
4464
- return function (event) {
3931
+ return event => {
4465
3932
  event.stopPropagation();
4466
3933
  event.preventDefault();
4467
3934
  onSelect(user);
4468
3935
  };
4469
3936
  }
4470
- React.useEffect(function () {
4471
- var unsubscribe = addEventListener("enter", function (event) {
3937
+ React.useEffect(() => {
3938
+ const unsubscribe = addEventListener("enter", event => {
4472
3939
  event.stopPropagation();
4473
3940
  event.preventDefault();
4474
3941
  onSelect(usersFiltered[selectedUser]);
4475
3942
  });
4476
- return function () {
3943
+ return () => {
4477
3944
  unsubscribe();
4478
3945
  };
4479
3946
  }, [addEventListener, onSelect, selectedUser, usersFiltered]);
4480
3947
  return /*#__PURE__*/React__default["default"].createElement("ul", {
4481
3948
  className: "react-input-emoji--mention--list",
4482
3949
  "data-testid": "mention-user-list"
4483
- }, usersFiltered.map(function (user, index) {
4484
- return /*#__PURE__*/React__default["default"].createElement("li", {
4485
- key: user.id
4486
- }, /*#__PURE__*/React__default["default"].createElement("button", {
4487
- type: "button",
4488
- onClick: handleClick(user),
4489
- className: "react-input-emoji--mention--item".concat(selectedUser === index ? " react-input-emoji--mention--item__selected" : ""),
4490
- onMouseOver: function onMouseOver() {
4491
- return setSelectedUser(index);
4492
- }
4493
- }, /*#__PURE__*/React__default["default"].createElement("img", {
4494
- className: "react-input-emoji--mention--item--img",
4495
- src: user.image
4496
- }), /*#__PURE__*/React__default["default"].createElement("div", {
4497
- className: "react-input-emoji--mention--item--name",
4498
- dangerouslySetInnerHTML: {
4499
- __html: user.nameHtml
4500
- }
4501
- })));
4502
- }));
3950
+ }, usersFiltered.map((user, index) => /*#__PURE__*/React__default["default"].createElement("li", {
3951
+ key: user.id
3952
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
3953
+ type: "button",
3954
+ onClick: handleClick(user),
3955
+ className: `react-input-emoji--mention--item${selectedUser === index ? " react-input-emoji--mention--item__selected" : ""}`,
3956
+ onMouseOver: () => setSelectedUser(index)
3957
+ }, /*#__PURE__*/React__default["default"].createElement("img", {
3958
+ className: "react-input-emoji--mention--item--img",
3959
+ src: user.image
3960
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
3961
+ className: "react-input-emoji--mention--item--name",
3962
+ dangerouslySetInnerHTML: {
3963
+ __html: user.nameHtml
3964
+ }
3965
+ })))));
4503
3966
  };
4504
- var MentionUserListWithRef = /*#__PURE__*/React.forwardRef(MentionUserList);
3967
+ const MentionUserListWithRef = /*#__PURE__*/React.forwardRef(MentionUserList);
3968
+
3969
+ // @ts-check
4505
3970
 
4506
3971
  /**
4507
3972
  * @typedef {import('../types/types').MentionUser} MetionUser
@@ -4525,55 +3990,54 @@ var MentionUserListWithRef = /*#__PURE__*/React.forwardRef(MentionUserList);
4525
3990
 
4526
3991
  // eslint-disable-next-line valid-jsdoc
4527
3992
  /** @type {React.FC<Props>} */
4528
- var MentionWrapper = function MentionWrapper(_ref) {
4529
- var searchMention = _ref.searchMention,
4530
- addEventListener = _ref.addEventListener,
4531
- appendContent = _ref.appendContent,
4532
- addSanitizeFn = _ref.addSanitizeFn;
3993
+ const MentionWrapper = ({
3994
+ searchMention,
3995
+ addEventListener,
3996
+ appendContent,
3997
+ addSanitizeFn
3998
+ }) => {
4533
3999
  /** @type {React.MutableRefObject<import('./mention-user-list').Ref | null>} */
4534
- var metionUserListRef = React.useRef(null);
4535
- var _useState = React.useState(false),
4536
- _useState2 = _slicedToArray(_useState, 2),
4537
- showUserList = _useState2[0],
4538
- setShowUserList = _useState2[1];
4539
- var _useMention = useMention(searchMention),
4540
- mentionSearchText = _useMention.mentionSearchText,
4541
- mentionUsers = _useMention.mentionUsers,
4542
- loading = _useMention.loading,
4543
- onKeyUp = _useMention.onKeyUp,
4544
- onFocus = _useMention.onFocus,
4545
- onSelectUser = _useMention.onSelectUser;
4546
- React.useEffect(function () {
4547
- addSanitizeFn(function (html) {
4548
- var container = document.createElement("div");
4000
+ const metionUserListRef = React.useRef(null);
4001
+ const [showUserList, setShowUserList] = React.useState(false);
4002
+ const {
4003
+ mentionSearchText,
4004
+ mentionUsers,
4005
+ loading,
4006
+ onKeyUp,
4007
+ onFocus,
4008
+ onSelectUser
4009
+ } = useMention(searchMention);
4010
+ React.useEffect(() => {
4011
+ addSanitizeFn(html => {
4012
+ const container = document.createElement("div");
4549
4013
  container.innerHTML = html;
4550
- var mentionsEl = Array.prototype.slice.call(container.querySelectorAll(".react-input-emoji--mention--text"));
4551
- mentionsEl.forEach(function (mentionEl) {
4552
- container.innerHTML = container.innerHTML.replace(mentionEl.outerHTML, "@[".concat(mentionEl.dataset.mentionName, "](userId:").concat(mentionEl.dataset.mentionId, ")"));
4014
+ const mentionsEl = Array.prototype.slice.call(container.querySelectorAll(".react-input-emoji--mention--text"));
4015
+ mentionsEl.forEach(mentionEl => {
4016
+ container.innerHTML = container.innerHTML.replace(mentionEl.outerHTML, `@[${mentionEl.dataset.mentionName}](userId:${mentionEl.dataset.mentionId})`);
4553
4017
  });
4554
4018
  return container.innerHTML;
4555
4019
  });
4556
4020
  }, [addSanitizeFn]);
4557
- React.useEffect(function () {
4021
+ React.useEffect(() => {
4558
4022
  setShowUserList(mentionUsers.length > 0);
4559
4023
  }, [mentionUsers]);
4560
- React.useEffect(function () {
4024
+ React.useEffect(() => {
4561
4025
  /** */
4562
4026
  function checkClickOutside() {
4563
4027
  setShowUserList(false);
4564
4028
  }
4565
4029
  document.addEventListener("click", checkClickOutside);
4566
- return function () {
4030
+ return () => {
4567
4031
  document.removeEventListener("click", checkClickOutside);
4568
4032
  };
4569
4033
  }, []);
4570
- React.useEffect(function () {
4571
- var unsubscribe = addEventListener("keyUp", onKeyUp);
4572
- return function () {
4034
+ React.useEffect(() => {
4035
+ const unsubscribe = addEventListener("keyUp", onKeyUp);
4036
+ return () => {
4573
4037
  unsubscribe();
4574
4038
  };
4575
4039
  }, [addEventListener, onKeyUp]);
4576
- React.useEffect(function () {
4040
+ React.useEffect(() => {
4577
4041
  /**
4578
4042
  *
4579
4043
  * @param {React.KeyboardEvent} event
@@ -4586,30 +4050,30 @@ var MentionWrapper = function MentionWrapper(_ref) {
4586
4050
  break;
4587
4051
  }
4588
4052
  }
4589
- var unsubscribe = addEventListener("keyDown", handleKeyDown);
4590
- return function () {
4053
+ const unsubscribe = addEventListener("keyDown", handleKeyDown);
4054
+ return () => {
4591
4055
  unsubscribe();
4592
4056
  };
4593
4057
  }, [addEventListener]);
4594
- React.useEffect(function () {
4595
- var unsubscribe = addEventListener("focus", onFocus);
4596
- return function () {
4058
+ React.useEffect(() => {
4059
+ const unsubscribe = addEventListener("focus", onFocus);
4060
+ return () => {
4597
4061
  unsubscribe();
4598
4062
  };
4599
4063
  }, [addEventListener, onFocus]);
4600
- React.useEffect(function () {
4064
+ React.useEffect(() => {
4601
4065
  if (showUserList) {
4602
- var unsubscribeArrowUp = addEventListener("arrowUp", function (event) {
4066
+ const unsubscribeArrowUp = addEventListener("arrowUp", event => {
4603
4067
  event.stopPropagation();
4604
4068
  event.preventDefault();
4605
4069
  metionUserListRef.current.prevUser();
4606
4070
  });
4607
- var unsubscribeArrowDown = addEventListener("arrowDown", function (event) {
4071
+ const unsubscribeArrowDown = addEventListener("arrowDown", event => {
4608
4072
  event.stopPropagation();
4609
4073
  event.preventDefault();
4610
4074
  metionUserListRef.current.nextUser();
4611
4075
  });
4612
- return function () {
4076
+ return () => {
4613
4077
  unsubscribeArrowUp();
4614
4078
  unsubscribeArrowDown();
4615
4079
  };
@@ -4622,7 +4086,7 @@ var MentionWrapper = function MentionWrapper(_ref) {
4622
4086
  */
4623
4087
  function handleSelect(user) {
4624
4088
  onSelectUser();
4625
- appendContent("<span class=\"react-input-emoji--mention--text\" data-mention-id=\"".concat(user.id, "\" data-mention-name=\"").concat(user.name, "\">@").concat(user.name, "</span> "));
4089
+ appendContent(`<span class="react-input-emoji--mention--text" data-mention-id="${user.id}" data-mention-name="${user.name}">@${user.name}</span> `);
4626
4090
  }
4627
4091
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, loading ? /*#__PURE__*/React__default["default"].createElement("div", {
4628
4092
  className: "react-input-emoji--mention--container"
@@ -4632,9 +4096,7 @@ var MentionWrapper = function MentionWrapper(_ref) {
4632
4096
  className: "react-input-emoji--mention--loading--spinner"
4633
4097
  }, "Loading..."))) : showUserList && /*#__PURE__*/React__default["default"].createElement("div", {
4634
4098
  className: "react-input-emoji--mention--container",
4635
- onClick: function onClick(evt) {
4636
- return evt.stopPropagation();
4637
- }
4099
+ onClick: evt => evt.stopPropagation()
4638
4100
  }, /*#__PURE__*/React__default["default"].createElement(MentionUserListWithRef, {
4639
4101
  ref: metionUserListRef,
4640
4102
  mentionSearchText: mentionSearchText,
@@ -4653,20 +4115,16 @@ var MentionWrapper = function MentionWrapper(_ref) {
4653
4115
  */
4654
4116
  function createObserver() {
4655
4117
  /** @type {import('../types/types').Listerner<T>[]} */
4656
- var listeners = [];
4118
+ let listeners = [];
4657
4119
  return {
4658
- subscribe: function subscribe(listener) {
4120
+ subscribe: listener => {
4659
4121
  listeners.push(listener);
4660
- return function () {
4661
- listeners = listeners.filter(function (l) {
4662
- return l !== listener;
4663
- });
4122
+ return () => {
4123
+ listeners = listeners.filter(l => l !== listener);
4664
4124
  };
4665
4125
  },
4666
- publish: function publish(event) {
4667
- listeners.forEach(function (listener) {
4668
- return listener(event);
4669
- });
4126
+ publish: event => {
4127
+ listeners.forEach(listener => listener(event));
4670
4128
  },
4671
4129
  get currentListerners() {
4672
4130
  return listeners;
@@ -4684,28 +4142,26 @@ function createObserver() {
4684
4142
  /** */
4685
4143
  function useEventListeners() {
4686
4144
  /** @type {TextInputListeners} */
4687
- var listeners = React.useMemo(function () {
4688
- return {
4689
- keyDown: createObserver(),
4690
- keyUp: createObserver(),
4691
- arrowUp: createObserver(),
4692
- arrowDown: createObserver(),
4693
- enter: createObserver(),
4694
- focus: createObserver(),
4695
- blur: createObserver()
4696
- };
4697
- }, []);
4145
+ const listeners = React.useMemo(() => ({
4146
+ keyDown: createObserver(),
4147
+ keyUp: createObserver(),
4148
+ arrowUp: createObserver(),
4149
+ arrowDown: createObserver(),
4150
+ enter: createObserver(),
4151
+ focus: createObserver(),
4152
+ blur: createObserver()
4153
+ }), []);
4698
4154
 
4699
4155
  /**
4700
4156
  * @template {keyof TextInputListeners} T, K
4701
4157
  * @type {(event: keyof TextInputListeners, fn: import('../types/types').Listerner<any>) => () => void}
4702
4158
  */
4703
- var addEventListener = React.useCallback(function (event, fn) {
4159
+ const addEventListener = React.useCallback((event, fn) => {
4704
4160
  return listeners[event].subscribe(fn);
4705
4161
  }, [listeners]);
4706
4162
  return {
4707
- addEventListener: addEventListener,
4708
- listeners: listeners
4163
+ addEventListener,
4164
+ listeners
4709
4165
  };
4710
4166
  }
4711
4167
 
@@ -4719,23 +4175,23 @@ function useEventListeners() {
4719
4175
  /** */
4720
4176
  function usePollute() {
4721
4177
  /** @type {React.MutableRefObject<PolluteFn[]>} */
4722
- var polluteFnsRef = React.useRef([]);
4178
+ const polluteFnsRef = React.useRef([]);
4723
4179
 
4724
4180
  /** @type {(fn: PolluteFn) => void} */
4725
- var addPolluteFn = React.useCallback(function (fn) {
4181
+ const addPolluteFn = React.useCallback(fn => {
4726
4182
  polluteFnsRef.current.push(fn);
4727
4183
  }, []);
4728
4184
 
4729
4185
  /** @type {(html: string) => string} */
4730
- var pollute = React.useCallback(function (text) {
4731
- var result = polluteFnsRef.current.reduce(function (acc, fn) {
4186
+ const pollute = React.useCallback(text => {
4187
+ const result = polluteFnsRef.current.reduce((acc, fn) => {
4732
4188
  return fn(acc);
4733
4189
  }, text);
4734
4190
  return result;
4735
4191
  }, []);
4736
4192
  return {
4737
- addPolluteFn: addPolluteFn,
4738
- pollute: pollute
4193
+ addPolluteFn,
4194
+ pollute
4739
4195
  };
4740
4196
  }
4741
4197
 
@@ -4791,72 +4247,77 @@ function usePollute() {
4791
4247
  * @return {JSX.Element}
4792
4248
  */
4793
4249
  function InputEmoji(props, ref) {
4794
- var onChange = props.onChange,
4795
- onEnter = props.onEnter,
4796
- onResize = props.onResize,
4797
- onClick = props.onClick,
4798
- onFocus = props.onFocus,
4799
- onBlur = props.onBlur,
4800
- onKeyDown = props.onKeyDown,
4801
- theme = props.theme,
4802
- cleanOnEnter = props.cleanOnEnter,
4803
- placeholder = props.placeholder,
4804
- maxLength = props.maxLength,
4805
- keepOpened = props.keepOpened,
4806
- inputClass = props.inputClass,
4807
- disableRecent = props.disableRecent,
4808
- tabIndex = props.tabIndex,
4809
- value = props.value,
4810
- customEmojis = props.customEmojis,
4811
- language = props.language,
4812
- searchMention = props.searchMention,
4813
- buttonElement = props.buttonElement,
4814
- buttonRef = props.buttonRef,
4815
- shouldReturn = props.shouldReturn,
4816
- shouldConvertEmojiToImage = props.shouldConvertEmojiToImage,
4817
- borderRadius = props.borderRadius,
4818
- borderColor = props.borderColor,
4819
- fontSize = props.fontSize,
4820
- fontFamily = props.fontFamily,
4821
- background = props.background,
4822
- placeholderColor = props.placeholderColor,
4823
- color = props.color;
4250
+ const {
4251
+ onChange,
4252
+ onEnter,
4253
+ onResize,
4254
+ onClick,
4255
+ onFocus,
4256
+ onBlur,
4257
+ onKeyDown,
4258
+ theme,
4259
+ cleanOnEnter,
4260
+ placeholder,
4261
+ maxLength,
4262
+ keepOpened,
4263
+ inputClass,
4264
+ disableRecent,
4265
+ tabIndex,
4266
+ value,
4267
+ customEmojis,
4268
+ language,
4269
+ searchMention,
4270
+ buttonElement,
4271
+ buttonRef,
4272
+ shouldReturn,
4273
+ shouldConvertEmojiToImage,
4274
+ // style
4275
+ borderRadius,
4276
+ borderColor,
4277
+ fontSize,
4278
+ fontFamily,
4279
+ background,
4280
+ placeholderColor,
4281
+ color
4282
+ } = props;
4824
4283
 
4825
4284
  /** @type {React.MutableRefObject<import('./text-input').Ref | null>} */
4826
- var textInputRef = React.useRef(null);
4827
- var _useEventListeners = useEventListeners(),
4828
- addEventListener = _useEventListeners.addEventListener,
4829
- listeners = _useEventListeners.listeners;
4830
- var _useSanitize = useSanitize(shouldReturn, shouldConvertEmojiToImage),
4831
- addSanitizeFn = _useSanitize.addSanitizeFn,
4832
- sanitize = _useSanitize.sanitize,
4833
- sanitizedTextRef = _useSanitize.sanitizedTextRef;
4834
- var _usePollute = usePollute(),
4835
- addPolluteFn = _usePollute.addPolluteFn,
4836
- pollute = _usePollute.pollute;
4837
- var updateHTML = React.useCallback(function () {
4838
- var nextValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
4285
+ const textInputRef = React.useRef(null);
4286
+ const {
4287
+ addEventListener,
4288
+ listeners
4289
+ } = useEventListeners();
4290
+ const {
4291
+ addSanitizeFn,
4292
+ sanitize,
4293
+ sanitizedTextRef
4294
+ } = useSanitize(shouldReturn, shouldConvertEmojiToImage);
4295
+ const {
4296
+ addPolluteFn,
4297
+ pollute
4298
+ } = usePollute();
4299
+ const updateHTML = React.useCallback((nextValue = "") => {
4839
4300
  if (textInputRef.current === null) return;
4840
4301
  textInputRef.current.html = replaceAllTextEmojis(nextValue);
4841
4302
  sanitizedTextRef.current = nextValue;
4842
4303
  }, [sanitizedTextRef]);
4843
- var setValue = React.useCallback(
4304
+ const setValue = React.useCallback(
4844
4305
  /**
4845
4306
  *
4846
4307
  * @param {string} value
4847
4308
  */
4848
- function (value) {
4309
+ value => {
4849
4310
  updateHTML(value);
4850
4311
  }, [updateHTML]);
4851
- var emitChange = useEmit(textInputRef, onResize, onChange);
4312
+ const emitChange = useEmit(textInputRef, onResize, onChange);
4852
4313
  useExpose({
4853
- ref: ref,
4854
- setValue: setValue,
4855
- textInputRef: textInputRef,
4856
- emitChange: emitChange,
4857
- shouldConvertEmojiToImage: shouldConvertEmojiToImage
4314
+ ref,
4315
+ setValue,
4316
+ textInputRef,
4317
+ emitChange,
4318
+ shouldConvertEmojiToImage
4858
4319
  });
4859
- React.useEffect(function () {
4320
+ React.useEffect(() => {
4860
4321
  if (sanitizedTextRef.current !== value) {
4861
4322
  setValue(value);
4862
4323
  }
@@ -4866,7 +4327,7 @@ function InputEmoji(props, ref) {
4866
4327
  // updateHTML();
4867
4328
  // }, [updateHTML]);
4868
4329
 
4869
- React.useEffect(function () {
4330
+ React.useEffect(() => {
4870
4331
  /**
4871
4332
  * Handle keydown event
4872
4333
  * @param {React.KeyboardEvent} event
@@ -4878,7 +4339,7 @@ function InputEmoji(props, ref) {
4878
4339
  }
4879
4340
  if (event.key === "Enter" && textInputRef.current) {
4880
4341
  event.preventDefault();
4881
- var text = sanitize(textInputRef.current.html);
4342
+ const text = sanitize(textInputRef.current.html);
4882
4343
  emitChange(sanitizedTextRef.current);
4883
4344
  if (typeof onEnter === "function" && listeners.enter.currentListerners.length === 0) {
4884
4345
  onEnter(text);
@@ -4896,12 +4357,12 @@ function InputEmoji(props, ref) {
4896
4357
  }
4897
4358
  return true;
4898
4359
  }
4899
- var unsubscribe = addEventListener("keyDown", handleKeydown);
4900
- return function () {
4360
+ const unsubscribe = addEventListener("keyDown", handleKeydown);
4361
+ return () => {
4901
4362
  unsubscribe();
4902
4363
  };
4903
4364
  }, [addEventListener, cleanOnEnter, emitChange, listeners.enter.currentListerners.length, maxLength, onEnter, onKeyDown, sanitize, sanitizedTextRef, updateHTML]);
4904
- React.useEffect(function () {
4365
+ React.useEffect(() => {
4905
4366
  /** */
4906
4367
  function handleFocus() {
4907
4368
  if (typeof onClick === "function") {
@@ -4911,20 +4372,20 @@ function InputEmoji(props, ref) {
4911
4372
  onFocus();
4912
4373
  }
4913
4374
  }
4914
- var unsubscribe = addEventListener("focus", handleFocus);
4915
- return function () {
4375
+ const unsubscribe = addEventListener("focus", handleFocus);
4376
+ return () => {
4916
4377
  unsubscribe();
4917
4378
  };
4918
4379
  }, [addEventListener, onClick, onFocus]);
4919
- React.useEffect(function () {
4380
+ React.useEffect(() => {
4920
4381
  /** */
4921
4382
  function handleBlur() {
4922
4383
  if (typeof onBlur === "function") {
4923
4384
  onBlur();
4924
4385
  }
4925
4386
  }
4926
- var unsubscribe = addEventListener("blur", handleBlur);
4927
- return function () {
4387
+ const unsubscribe = addEventListener("blur", handleBlur);
4388
+ return () => {
4928
4389
  unsubscribe();
4929
4390
  };
4930
4391
  }, [addEventListener, onBlur]);
@@ -4959,7 +4420,7 @@ function InputEmoji(props, ref) {
4959
4420
  */
4960
4421
  function handlePaste(event) {
4961
4422
  event.preventDefault();
4962
- var content;
4423
+ let content;
4963
4424
  if (event.clipboardData) {
4964
4425
  content = event.clipboardData.getData("text/plain");
4965
4426
  content = pollute(content);
@@ -4987,13 +4448,13 @@ function InputEmoji(props, ref) {
4987
4448
  onEnter: listeners.enter.publish,
4988
4449
  placeholder: placeholder,
4989
4450
  style: {
4990
- borderRadius: borderRadius,
4991
- borderColor: borderColor,
4992
- fontSize: fontSize,
4993
- fontFamily: fontFamily,
4994
- background: background,
4995
- placeholderColor: placeholderColor,
4996
- color: color
4451
+ borderRadius,
4452
+ borderColor,
4453
+ fontSize,
4454
+ fontFamily,
4455
+ background,
4456
+ placeholderColor,
4457
+ color
4997
4458
  },
4998
4459
  tabIndex: tabIndex,
4999
4460
  className: inputClass,
@@ -5011,7 +4472,7 @@ function InputEmoji(props, ref) {
5011
4472
  language: language
5012
4473
  }));
5013
4474
  }
5014
- var InputEmojiWithRef = /*#__PURE__*/React.forwardRef(InputEmoji);
4475
+ const InputEmojiWithRef = /*#__PURE__*/React.forwardRef(InputEmoji);
5015
4476
  InputEmojiWithRef.defaultProps = {
5016
4477
  theme: /** @type {const} */"auto",
5017
4478
  height: 30,