@uiwwsw/virtual-keyboard 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,46 +1,46 @@
1
1
  "use client";
2
- import { jsxs as q, jsx as C, Fragment as ze } from "react/jsx-runtime";
3
- import { useContext as qe, createContext as Ze, forwardRef as We, useId as Be, useRef as P, useState as R, useMemo as Ke, useCallback as k, useEffect as V, useImperativeHandle as _e, createElement as Je } from "react";
4
- import { convertQwertyToHangul as Re, assemble as Ge, removeLastCharacter as Qe } from "es-hangul";
5
- import { createPortal as ke } from "react-dom";
6
- class Oe {
2
+ import { jsxs as q, jsx as T, Fragment as Me } from "react/jsx-runtime";
3
+ import { useContext as Oe, createContext as et, forwardRef as tt, useId as $e, useRef as I, useState as P, useMemo as He, useCallback as S, useEffect as z, useImperativeHandle as nt, useLayoutEffect as rt, createElement as at } from "react";
4
+ import { convertQwertyToHangul as Ue, assemble as ot, removeLastCharacter as it } from "es-hangul";
5
+ import { createPortal as Te } from "react-dom";
6
+ class ct {
7
7
  past = [];
8
8
  future = [];
9
- record(r, n) {
10
- r.value !== n.value && (r.composing && n.composing && this.past.length || (this.past.push({ ...r, composing: !1 }), this.past.length > 100 && this.past.shift()), this.future = []);
9
+ record(n, r) {
10
+ n.value !== r.value && (n.composing && r.composing && this.past.length || (this.past.push({ ...n, composing: !1 }), this.past.length > 100 && this.past.shift()), this.future = []);
11
11
  }
12
- undo(r) {
13
- const n = this.past.pop();
14
- return n ? (this.future.push({ ...r, composing: !1 }), n) : r;
12
+ undo(n) {
13
+ const r = this.past.pop();
14
+ return r ? (this.future.push({ ...n, composing: !1 }), r) : n;
15
15
  }
16
- redo(r) {
17
- const n = this.future.pop();
18
- return n ? (this.past.push({ ...r, composing: !1 }), n) : r;
16
+ redo(n) {
17
+ const r = this.future.pop();
18
+ return r ? (this.past.push({ ...n, composing: !1 }), r) : n;
19
19
  }
20
20
  clear() {
21
21
  this.past = [], this.future = [];
22
22
  }
23
23
  }
24
- const He = Ze(null);
25
- function Fe() {
26
- const e = qe(He);
24
+ const We = et(null);
25
+ function Ze() {
26
+ const e = Oe(We);
27
27
  if (!e)
28
28
  throw new Error(
29
29
  "VirtualInput must be used within a <VirtualInputProvider>."
30
30
  );
31
31
  return e;
32
32
  }
33
- function fe(e) {
33
+ function we(e) {
34
34
  return /^[\u1100-\u11FF\u3130-\u318F\uAC00-\uD7AF]$/.test(e);
35
35
  }
36
- function et(e, r) {
36
+ function lt(e, n) {
37
37
  if (e.key === "HangulMode") return { handled: !0, toggleHangulMode: !0 };
38
38
  if (e.ctrlKey || e.metaKey || e.altKey || [...e.key].length !== 1 || /[\r\n\t]/.test(e.key))
39
39
  return { handled: !1 };
40
- const n = r && /^[A-Za-z]$/.test(e.key) ? Re(e.key) : e.key;
41
- return { handled: !0, text: n, composing: fe(n) };
40
+ const r = n && /^[A-Za-z]$/.test(e.key) ? Ue(e.key) : e.key;
41
+ return { handled: !0, text: r, composing: we(r) };
42
42
  }
43
- const G = [
43
+ const re = [
44
44
  [
45
45
  {
46
46
  label: "q",
@@ -211,7 +211,7 @@ const G = [
211
211
  width: 1.25
212
212
  }
213
213
  ]
214
- ], tt = [
214
+ ], ut = [
215
215
  [
216
216
  {
217
217
  label: "1",
@@ -280,7 +280,7 @@ const G = [
280
280
  type: "action"
281
281
  }
282
282
  ]
283
- ], rt = [
283
+ ], st = [
284
284
  [
285
285
  {
286
286
  label: "1",
@@ -363,7 +363,7 @@ const G = [
363
363
  }
364
364
  ]
365
365
  ];
366
- function de(e) {
366
+ function me(e) {
367
367
  switch (e) {
368
368
  case "hangul":
369
369
  return !0;
@@ -376,34 +376,34 @@ function de(e) {
376
376
  return null;
377
377
  }
378
378
  }
379
- const se = () => !0, nt = {
379
+ const ge = () => !0, dt = {
380
380
  text: {
381
381
  mode: "text",
382
- layout: G,
383
- filterKey: se,
382
+ layout: re,
383
+ filterKey: ge,
384
384
  sanitizeValue: (e) => e.replace(/[\r\n\t]+/g, " ")
385
385
  },
386
386
  number: {
387
387
  mode: "number",
388
- layout: tt,
388
+ layout: ut,
389
389
  filterKey: (e) => /^[0-9.]+$/.test(e),
390
390
  sanitizeValue: (e) => e.replace(/[^0-9.]/g, "")
391
391
  },
392
392
  tel: {
393
393
  mode: "tel",
394
- layout: rt,
394
+ layout: st,
395
395
  filterKey: (e) => /^[0-9*#+]+$/.test(e),
396
396
  sanitizeValue: (e) => e.replace(/[^0-9*#+]/g, "")
397
397
  },
398
398
  hangul: {
399
399
  mode: "hangul",
400
- layout: G,
401
- filterKey: se,
400
+ layout: re,
401
+ filterKey: ge,
402
402
  sanitizeValue: (e) => e.replace(/[A-Za-z]/g, "")
403
403
  },
404
404
  alpha: {
405
405
  mode: "alpha",
406
- layout: G,
406
+ layout: re,
407
407
  filterKey: (e) => /^[A-Za-z]+$/.test(e),
408
408
  sanitizeValue: (e) => e.replace(/[^A-Za-z]/g, "")
409
409
  },
@@ -411,270 +411,346 @@ const se = () => !0, nt = {
411
411
  mode: "alphanumeric",
412
412
  layout: [
413
413
  Array.from("1234567890", (e) => ({ value: e })),
414
- ...G
414
+ ...re
415
415
  ],
416
416
  filterKey: (e) => /^[A-Za-z0-9]+$/.test(e),
417
417
  sanitizeValue: (e) => e.replace(/[^A-Za-z0-9]/g, "")
418
418
  },
419
419
  custom: {
420
420
  mode: "custom",
421
- layout: G,
422
- filterKey: se,
421
+ layout: re,
422
+ filterKey: ge,
423
423
  sanitizeValue: (e) => e.replace(/[\r\n\t]+/g, " ")
424
424
  }
425
425
  };
426
- function ye(e) {
427
- const r = e?.mode ?? "text", n = nt[r];
426
+ function Se(e) {
427
+ const n = e?.mode ?? "text", r = dt[n];
428
428
  return {
429
- mode: r,
430
- layout: e?.layout ?? n.layout ?? G,
431
- filterKey: e?.filterKey ?? n.filterKey ?? se,
432
- sanitizeValue: e?.sanitizeValue ?? n.sanitizeValue ?? ((o) => o)
429
+ mode: n,
430
+ layout: e?.layout ?? r.layout ?? re,
431
+ filterKey: e?.filterKey ?? r.filterKey ?? ge,
432
+ sanitizeValue: e?.sanitizeValue ?? r.sanitizeValue ?? ((a) => a)
433
433
  };
434
434
  }
435
- const ot = new Intl.Segmenter(void 0, { granularity: "grapheme" }), at = new Intl.Segmenter(void 0, { granularity: "word" });
436
- function it(e, r) {
437
- const n = Math.max(0, Math.min(r, e.length - 1));
438
- for (const o of at.segment(e))
439
- if (n < o.index + o.segment.length)
440
- return [o.index, o.index + o.segment.length];
441
- return [0, 0];
442
- }
443
- const Ee = (e) => Array.from(ot.segment(e));
444
- function ue(e, r) {
435
+ const ft = new Intl.Segmenter(void 0, { granularity: "grapheme" }), Ve = (e) => Array.from(ft.segment(e));
436
+ function Z(e, n) {
445
437
  return [
446
- ...Ee(e).map((o) => o.index),
438
+ ...Ve(e).map((a) => a.index),
447
439
  e.length
448
- ].filter((o) => o <= Math.max(0, r)).at(-1) ?? 0;
440
+ ].filter((a) => a <= Math.max(0, n)).at(-1) ?? 0;
449
441
  }
450
- function be(e, r, n) {
451
- const o = [
452
- ...Ee(e).map((i) => i.index),
442
+ function Le(e, n, r) {
443
+ const a = [
444
+ ...Ve(e).map((i) => i.index),
453
445
  e.length
454
446
  ];
455
- return n < 0 ? o.filter((i) => i < r).at(-1) ?? 0 : o.find((i) => i > r) ?? e.length;
447
+ return r < 0 ? a.filter((i) => i < n).at(-1) ?? 0 : a.find((i) => i > n) ?? e.length;
456
448
  }
457
- const te = ({ anchor: e, caret: r }) => [Math.min(e, r), Math.max(e, r)];
458
- function lt(e, r, n = !1, o) {
459
- const [i, c] = te(e);
460
- let h = e.value.slice(0, i), v = r;
461
- i === c && e.composing && n && fe(h.at(-1) ?? "") && (v = Ge([h.at(-1), r]), h = h.slice(0, -1));
462
- const d = h + v + e.value.slice(c);
463
- if (o !== void 0 && d.length > o) return e;
464
- const L = h.length + v.length;
465
- return { value: d, caret: L, anchor: L, composing: n };
449
+ const ae = ({ anchor: e, caret: n }) => [Math.min(e, n), Math.max(e, n)];
450
+ function qe(e, n, r = !1, a) {
451
+ const [i, s] = ae(e);
452
+ let f = e.value.slice(0, i), v = n;
453
+ i === s && e.composing && r && we(f.at(-1) ?? "") && (v = ot([f.at(-1), n]), f = f.slice(0, -1));
454
+ const c = f + v + e.value.slice(s);
455
+ if (a !== void 0 && c.length > a) return e;
456
+ const m = f.length + v.length;
457
+ return { value: c, caret: m, anchor: m, composing: r };
466
458
  }
467
- function me(e, r) {
468
- let [n, o] = te(e);
469
- if (n === o) {
470
- if (r < 0 && e.composing && fe(e.value[n - 1] ?? "")) {
471
- const i = e.value.slice(0, n - 1) + Qe(e.value[n - 1]);
459
+ function ve(e, n) {
460
+ let [r, a] = ae(e);
461
+ if (r === a) {
462
+ if (n < 0 && e.composing && we(e.value[r - 1] ?? "")) {
463
+ const i = e.value.slice(0, r - 1) + it(e.value[r - 1]);
472
464
  return {
473
- value: i + e.value.slice(o),
465
+ value: i + e.value.slice(a),
474
466
  anchor: i.length,
475
467
  caret: i.length,
476
468
  composing: !0
477
469
  };
478
470
  }
479
- r < 0 ? n = be(e.value, n, -1) : o = be(e.value, o, 1);
471
+ n < 0 ? r = Le(e.value, r, -1) : a = Le(e.value, a, 1);
480
472
  }
481
473
  return {
482
- value: e.value.slice(0, n) + e.value.slice(o),
483
- caret: n,
484
- anchor: n,
474
+ value: e.value.slice(0, r) + e.value.slice(a),
475
+ caret: r,
476
+ anchor: r,
485
477
  composing: !1
486
478
  };
487
479
  }
488
- function Ve(e, r, n = !1) {
489
- const [o, i] = te(e), c = r === "home" ? 0 : r === "end" ? e.value.length : !n && o !== i ? r < 0 ? o : i : be(e.value, e.caret, r);
480
+ function Fe(e, n, r = !1) {
481
+ const [a, i] = ae(e), s = n === "home" ? 0 : n === "end" ? e.value.length : !r && a !== i ? n < 0 ? a : i : Le(e.value, e.caret, n);
490
482
  return {
491
483
  ...e,
492
- caret: c,
493
- anchor: n ? e.anchor : c,
484
+ caret: s,
485
+ anchor: r ? e.anchor : s,
494
486
  composing: !1
495
487
  };
496
488
  }
497
- const kt = We(
489
+ function pt(e, n, r, a, i, s) {
490
+ if (n === e.value) return e;
491
+ let f = 0;
492
+ for (; f < e.value.length && f < n.length && e.value[f] === n[f]; )
493
+ f++;
494
+ f = Math.min(
495
+ Z(e.value, f),
496
+ Z(n, f)
497
+ );
498
+ let v = e.value.length, c = n.length;
499
+ for (; v > f && c > f && e.value[v - 1] === n[c - 1]; )
500
+ v--, c--;
501
+ for (; Z(e.value, v) !== v || Z(n, c) !== c; )
502
+ v < e.value.length && v++, c < n.length && c++;
503
+ const m = n.slice(f, c), p = a(m).replace(/[\r\n\t]+/g, " ");
504
+ if (m && (!p || !i(p))) return e;
505
+ const l = { ...e, anchor: f, caret: v, composing: !1 }, u = m ? qe(l, p, !1, s) : ve(l, -1);
506
+ if (u === l) return e;
507
+ const V = (w) => Z(
508
+ u.value,
509
+ w <= f ? w : w >= c ? w + p.length - m.length : f + a(m.slice(0, w - f)).replace(/[\r\n\t]+/g, " ").length
510
+ );
511
+ return {
512
+ ...u,
513
+ anchor: V(r.backward ? r.end : r.start),
514
+ caret: V(r.backward ? r.start : r.end)
515
+ };
516
+ }
517
+ const ht = typeof window > "u" ? z : rt, Mt = tt(
498
518
  function({
499
- value: r,
500
- defaultValue: n = "",
501
- placeholder: o,
519
+ value: n,
520
+ defaultValue: r = "",
521
+ placeholder: a,
502
522
  onChange: i,
503
- onValueChange: c,
504
- onClipboardError: h,
523
+ onValueChange: s,
524
+ onClipboardError: f,
505
525
  mode: v = "text",
506
- layout: d,
507
- filterKey: L,
508
- sanitizeValue: f,
526
+ layout: c,
527
+ filterKey: m,
528
+ sanitizeValue: p,
509
529
  disabled: l = !1,
510
530
  readOnly: u = !1,
511
- maxLength: I,
531
+ maxLength: V,
512
532
  ...w
513
533
  }, Q) {
514
- const H = Be(), {
515
- focusId: re,
516
- onFocus: X,
517
- onBlur: D,
518
- defaultLayout: O,
519
- inputRef: Z,
520
- hangulMode: ne,
521
- theme: p,
522
- toggleKorean: S,
523
- enterSelectionMode: g
524
- } = Fe(), y = P(null), z = P(null), [A, j] = R(() => ({
525
- value: r ?? n,
526
- caret: (r ?? n).length,
527
- anchor: (r ?? n).length,
534
+ const H = $e(), {
535
+ focusId: le,
536
+ onFocus: te,
537
+ onBlur: F,
538
+ defaultLayout: oe,
539
+ inputRef: X,
540
+ hangulMode: J,
541
+ theme: ue,
542
+ toggleKorean: g,
543
+ setEditingStatus: L
544
+ } = Ze(), y = I(null), A = I(null), x = I(!1), B = I(!1), R = I(null), [Y, N] = P(null), [b, O] = P(!1), [U, de] = P(() => ({
545
+ value: n ?? r,
546
+ caret: (n ?? r).length,
547
+ anchor: (n ?? r).length,
528
548
  composing: !1
529
- })), T = r ?? A.value, s = P(A), m = P(0), U = P(new Oe()), W = P(!1), F = re === H, _ = P(F);
530
- _.current = F;
531
- const ae = r !== void 0 && r !== A.value;
532
- ae && U.current.clear(), s.current = {
533
- ...A,
534
- value: T,
535
- caret: ue(T, A.caret),
536
- anchor: ue(T, A.anchor),
537
- composing: ae ? !1 : A.composing
549
+ })), W = n ?? U.value, d = I(U), ne = I(0), ie = I(new ct()), G = I(!1), h = le === H, k = I(h);
550
+ k.current = h;
551
+ const $ = n !== void 0 && n !== U.value;
552
+ $ && ie.current.clear(), d.current = {
553
+ ...U,
554
+ value: W,
555
+ caret: Z(W, U.caret),
556
+ anchor: Z(W, U.anchor),
557
+ composing: $ ? !1 : U.composing
538
558
  };
539
- const N = Ke(
540
- () => ye({
559
+ const j = He(
560
+ () => Se({
541
561
  mode: v,
542
- layout: d ?? (v === "text" || v === "custom" ? O : void 0),
543
- filterKey: L,
544
- sanitizeValue: f
562
+ layout: c ?? (v === "text" || v === "custom" ? oe : void 0),
563
+ filterKey: m,
564
+ sanitizeValue: p
545
565
  }),
546
- [v, d, O, L, f]
547
- ), [b, K] = R(""), Y = P(
548
- void 0
549
- ), B = P(null), M = k(() => {
550
- clearTimeout(Y.current), B.current = null;
551
- }, []);
552
- V(() => {
553
- (l || u) && M();
554
- }, [l, u, M]), V(() => {
555
- const t = (a) => {
556
- B.current && B.current.id !== a.pointerId && M();
557
- };
558
- return window.addEventListener("blur", M), window.addEventListener("scroll", M, !0), window.addEventListener("pointerdown", t, !0), document.addEventListener("visibilitychange", M), () => {
559
- M(), window.removeEventListener("blur", M), window.removeEventListener("scroll", M, !0), window.removeEventListener("pointerdown", t, !0), document.removeEventListener("visibilitychange", M);
560
- };
561
- }, [M]);
562
- const x = k(
563
- (t, a = !0) => {
564
- const E = s.current.value;
565
- if (a && U.current.record(s.current, t), s.current = t, m.current++, j(t), t.value !== E) {
566
- c?.(t.value);
567
- const $ = { value: t.value };
566
+ [v, c, oe, m, p]
567
+ ), [ye, fe] = P(""), E = S(
568
+ (t, o = !0, C = !1) => {
569
+ const K = d.current.value;
570
+ if (o && ie.current.record(d.current, t), x.current = !C, d.current = t, ne.current++, fe(""), de(t), t.value !== K) {
571
+ s?.(t.value);
572
+ const M = { value: t.value };
568
573
  i?.({
569
- target: $,
570
- currentTarget: $
574
+ target: M,
575
+ currentTarget: M
571
576
  });
572
577
  }
573
578
  },
574
- [i, c]
575
- ), ee = k(
576
- (t, a = !1) => {
579
+ [i, s]
580
+ ), D = S(() => {
581
+ const t = A.current;
582
+ if (!t || l || x.current || t.value !== d.current.value || B.current)
583
+ return null;
584
+ const o = t.selectionStart ?? 0, C = t.selectionEnd ?? o, K = t.selectionDirection === "backward" ? { anchor: C, caret: o } : { anchor: o, caret: C }, M = Z(d.current.value, K.anchor), _ = Z(d.current.value, K.caret);
585
+ return (M !== d.current.anchor || _ !== d.current.caret || M !== K.anchor || _ !== K.caret) && E(
586
+ { ...d.current, anchor: M, caret: _, composing: !1 },
587
+ !1,
588
+ M === K.anchor && _ === K.caret
589
+ ), { anchor: M, caret: _ };
590
+ }, [l, E]);
591
+ z(() => {
592
+ const t = () => {
593
+ document.activeElement === A.current && D();
594
+ }, o = A.current;
595
+ return document.addEventListener("selectionchange", t), o?.addEventListener("select", t), () => {
596
+ document.removeEventListener("selectionchange", t), o?.removeEventListener("select", t);
597
+ };
598
+ }, [D]), ht(() => {
599
+ if (R.current && R.current.value !== W && (B.current = !1, R.current = null, N(null)), !l && A.current && !B.current && (x.current || $)) {
600
+ const { anchor: t, caret: o } = d.current, C = Math.min(t, o), K = Math.max(t, o), M = t > o ? "backward" : "forward";
601
+ (A.current.selectionStart !== C || A.current.selectionEnd !== K || C !== K && A.current.selectionDirection !== M) && A.current.setSelectionRange(C, K, M);
602
+ }
603
+ x.current = !1;
604
+ }), z(() => {
605
+ if (!h) return;
606
+ const [t, o] = ae(d.current);
607
+ L({
608
+ selectionLength: Ve(W.slice(t, o)).length,
609
+ hasValue: !!W,
610
+ message: ye
611
+ });
612
+ }, [
613
+ W,
614
+ U.anchor,
615
+ U.caret,
616
+ ye,
617
+ h,
618
+ L
619
+ ]);
620
+ const ce = S(
621
+ (t, o = !1) => {
577
622
  if (l || u) return;
578
- const E = N.sanitizeValue(t).replace(/[\r\n\t]+/g, " ");
579
- E && x(lt(s.current, E, a, I));
623
+ D();
624
+ const C = j.sanitizeValue(t).replace(/[\r\n\t]+/g, " ");
625
+ C && E(qe(d.current, C, o, V));
580
626
  },
581
- [l, u, N, I, x]
582
- ), pe = k(() => {
583
- !l && !u && x(U.current.undo(s.current), !1);
584
- }, [l, u, x]), he = k(() => {
585
- !l && !u && x(U.current.redo(s.current), !1);
586
- }, [l, u, x]), Le = k(
587
- () => x({
588
- ...s.current,
589
- caret: s.current.value.length,
627
+ [l, u, j, V, E, D]
628
+ ), be = S(() => {
629
+ !l && !u && E(ie.current.undo(d.current), !1);
630
+ }, [l, u, E]), xe = S(() => {
631
+ !l && !u && E(ie.current.redo(d.current), !1);
632
+ }, [l, u, E]), Ke = S(
633
+ () => E({
634
+ ...d.current,
635
+ caret: d.current.value.length,
590
636
  anchor: 0,
591
637
  composing: !1
592
638
  }),
593
- [x]
594
- ), Se = k(
595
- (t, a = !1) => x(Ve(s.current, t === "left" ? -1 : 1, a)),
596
- [x]
597
- ), Ne = (t) => {
598
- if (w.onKeyDown?.(t), t.defaultPrevented || l) return;
599
- const a = t.key;
600
- if (a === "Escape") {
601
- t.preventDefault(), x({ ...s.current, composing: !1 }), D(!0), y.current?.blur();
639
+ [E]
640
+ ), Ie = S(
641
+ (t, o = !1) => {
642
+ D(), E(Fe(d.current, t === "left" ? -1 : 1, o));
643
+ },
644
+ [E, D]
645
+ ), Ye = (t) => {
646
+ if (w.onKeyDown?.(t), t.defaultPrevented || l || B.current || t.nativeEvent.isComposing || t.keyCode === 229)
647
+ return;
648
+ D();
649
+ const o = t.key;
650
+ if (o === "Escape") {
651
+ t.preventDefault(), E({ ...d.current, composing: !1 }), F(!0), A.current?.blur();
602
652
  return;
603
653
  }
604
- if (a === "HangulMode") {
605
- t.preventDefault(), x({ ...s.current, composing: !1 }), S();
654
+ if (o === "HangulMode") {
655
+ t.preventDefault(), E({ ...d.current, composing: !1 }), g();
606
656
  return;
607
657
  }
608
- const E = t.ctrlKey || t.metaKey;
609
- if (E && ["z", "y"].includes(a.toLowerCase())) {
610
- t.preventDefault(), a.toLowerCase() === "y" || t.shiftKey ? he() : pe();
658
+ const C = t.ctrlKey || t.metaKey;
659
+ if (C && ["z", "y"].includes(o.toLowerCase())) {
660
+ t.preventDefault(), o.toLowerCase() === "y" || t.shiftKey ? xe() : be();
611
661
  return;
612
662
  }
613
- if (E && a.toLowerCase() === "a") {
614
- t.preventDefault(), x({
615
- ...s.current,
616
- caret: s.current.value.length,
663
+ if (C && o.toLowerCase() === "a") {
664
+ t.preventDefault(), E({
665
+ ...d.current,
666
+ caret: d.current.value.length,
617
667
  anchor: 0,
618
668
  composing: !1
619
669
  });
620
670
  return;
621
671
  }
622
- const $ = a === "Home" || a === "ArrowUp" || E && a === "ArrowLeft" ? "home" : a === "End" || a === "ArrowDown" || E && a === "ArrowRight" ? "end" : a === "ArrowLeft" ? -1 : a === "ArrowRight" ? 1 : null;
623
- if ($ !== null) {
624
- t.preventDefault(), x(Ve(s.current, $, t.shiftKey));
672
+ const K = o === "Home" || o === "ArrowUp" || C && o === "ArrowLeft" ? "home" : o === "End" || o === "ArrowDown" || C && o === "ArrowRight" ? "end" : o === "ArrowLeft" ? -1 : o === "ArrowRight" ? 1 : null;
673
+ if (K !== null) {
674
+ t.preventDefault(), E(Fe(d.current, K, t.shiftKey));
625
675
  return;
626
676
  }
627
- if (a === "Tab" || a === "Enter") {
628
- x({ ...s.current, composing: !1 });
677
+ if (o === "Tab" || o === "Enter") {
678
+ o === "Enter" && t.preventDefault(), E({ ...d.current, composing: !1 });
629
679
  return;
630
680
  }
631
681
  if (u) return;
632
- if (a === "Backspace" || a === "Delete") {
633
- t.preventDefault(), x(me(s.current, a === "Backspace" ? -1 : 1));
682
+ if (o === "Backspace" || o === "Delete") {
683
+ t.preventDefault(), E(ve(d.current, o === "Backspace" ? -1 : 1));
634
684
  return;
635
685
  }
636
- const J = et(
686
+ const M = lt(
637
687
  t,
638
- de(N.mode) ?? ne
688
+ me(j.mode) ?? J
639
689
  );
640
- J.handled && J.text && (t.preventDefault(), N.filterKey(J.text) && ee(J.text, J.composing));
641
- }, ie = k(
690
+ M.handled && M.text && (t.preventDefault(), j.filterKey(M.text) && ce(M.text, M.composing));
691
+ }, pe = S(
642
692
  (t) => {
643
- const a = t instanceof Error ? t : new Error(String(t));
644
- W.current && (K(
645
- "클립보드에 접근할 수 없습니다. 키보드의 복사·붙여넣기 단축키를 사용해 주세요."
646
- ), h?.(a));
693
+ const o = t instanceof Error ? t : new Error(String(t));
694
+ G.current && (fe(
695
+ "클립보드에 접근할 수 없습니다. 입력란을 길게 눌러 기본 편집 메뉴를 사용해 주세요."
696
+ ), f?.(o));
647
697
  },
648
- [h]
649
- ), le = k(async () => {
650
- const [t, a] = te(s.current);
651
- t !== a && (await navigator.clipboard.writeText(
652
- s.current.value.slice(t, a)
653
- ), W.current && K("선택한 내용을 복사했습니다."));
654
- }, []), Ae = k(async () => {
698
+ [f]
699
+ ), he = S(async () => {
700
+ D();
701
+ const [t, o] = ae(d.current);
702
+ if (t === o) return;
703
+ const C = d.current.value, K = d.current.value.slice(t, o);
704
+ try {
705
+ if (!navigator.clipboard?.writeText)
706
+ throw new Error("Clipboard API unavailable");
707
+ await navigator.clipboard.writeText(K);
708
+ } catch (M) {
709
+ D();
710
+ const _ = A.current, [Ge, Qe] = ae(d.current);
711
+ if (!_ || !G.current || d.current.value !== C || Ge !== t || Qe !== o)
712
+ throw M;
713
+ let ee = document.activeElement;
714
+ const Re = ee?.hasAttribute(
715
+ "data-virtual-keypad"
716
+ );
717
+ if (ee !== _ && !Re) throw M;
718
+ for (; ee?.shadowRoot?.activeElement; )
719
+ ee = ee.shadowRoot.activeElement;
720
+ _.focus({ preventScroll: !0 });
721
+ try {
722
+ if (!document.execCommand?.("copy")) throw M;
723
+ } finally {
724
+ ee instanceof HTMLElement && ee !== _ && Re && ee.focus({ preventScroll: !0 });
725
+ }
726
+ }
727
+ G.current && fe("복사했어요");
728
+ }, [D]), Pe = S(async () => {
655
729
  if (l || u) return;
656
- const t = s.current, a = m.current;
657
- t.anchor !== t.caret && (await le(), W.current && _.current && m.current === a && s.current.value === t.value && x(me(t, -1)));
658
- }, [l, u, le, x]), Pe = k(async () => {
730
+ D();
731
+ const t = d.current, o = ne.current;
732
+ t.anchor !== t.caret && (await he(), G.current && k.current && ne.current === o && d.current.value === t.value && E(ve(t, -1)));
733
+ }, [l, u, he, E, D]), De = S(async () => {
659
734
  if (l || u) return;
660
- const t = m.current, a = s.current.value, E = await navigator.clipboard.readText();
661
- W.current && _.current && m.current === t && s.current.value === a && ee(E);
662
- }, [l, u, ee]), oe = Ke(
735
+ D();
736
+ const t = ne.current, o = d.current.value, C = await navigator.clipboard.readText();
737
+ G.current && k.current && ne.current === t && d.current.value === o && ce(C);
738
+ }, [l, u, ce, D]), se = He(
663
739
  () => ({
664
740
  focus: (t) => {
665
- l || y.current?.focus(t);
741
+ l || A.current?.focus(t);
666
742
  },
667
743
  blur: () => {
668
- y.current?.blur(), _.current && D(!0);
744
+ A.current?.blur(), k.current && F(!0);
669
745
  },
670
- getValue: () => s.current.value,
671
- setSelectionRange: (t, a) => x({
672
- ...s.current,
673
- anchor: ue(s.current.value, t),
674
- caret: ue(s.current.value, a),
746
+ getValue: () => d.current.value,
747
+ setSelectionRange: (t, o) => E({
748
+ ...d.current,
749
+ anchor: Z(d.current.value, t),
750
+ caret: Z(d.current.value, o),
675
751
  composing: !1
676
752
  }),
677
- handleKeyDown: (t) => y.current?.dispatchEvent(
753
+ handleKeyDown: (t) => A.current?.dispatchEvent(
678
754
  new KeyboardEvent("keydown", {
679
755
  key: t.key,
680
756
  shiftKey: t.shiftKey,
@@ -686,136 +762,91 @@ const kt = We(
686
762
  cancelable: !0
687
763
  })
688
764
  ),
689
- insertText: (t, a) => {
690
- N.filterKey(t) && ee(t, a);
765
+ insertText: (t, o) => {
766
+ j.filterKey(t) && ce(t, o);
691
767
  },
692
768
  scrollIntoView: () => y.current?.scrollIntoView({ block: "nearest", inline: "nearest" }),
693
- moveCaret: Se,
694
- undo: pe,
695
- redo: he,
696
- selectAll: Le,
697
- copySelection: () => le().catch(ie),
698
- pasteClipboard: () => Pe().catch(ie),
699
- cutSelection: () => Ae().catch(ie)
769
+ moveCaret: Ie,
770
+ undo: be,
771
+ redo: xe,
772
+ selectAll: Ke,
773
+ copySelection: () => he().catch(pe),
774
+ pasteClipboard: () => De().catch(pe),
775
+ cutSelection: () => Pe().catch(pe)
700
776
  }),
701
777
  [
702
- N,
703
- ee,
704
- Se,
705
- le,
778
+ j,
779
+ ce,
780
+ Ie,
781
+ he,
782
+ De,
706
783
  Pe,
707
- Ae,
708
- ie,
709
784
  pe,
710
- he,
711
- Le,
785
+ be,
786
+ xe,
787
+ Ke,
712
788
  l,
713
- D,
714
- x
789
+ F,
790
+ E
715
791
  ]
716
792
  );
717
- _e(Q, () => oe, [oe]), V(() => {
718
- F || j(
793
+ nt(Q, () => se, [se]), z(() => {
794
+ h || de(
719
795
  (t) => t.composing ? { ...t, composing: !1 } : t
720
796
  );
721
- }, [F]), V(() => {
722
- if (!(!F || l || u))
723
- return Z.current = oe, () => {
724
- Z.current === oe && (Z.current = null);
797
+ }, [h]), z(() => {
798
+ if (!(!h || l || u))
799
+ return X.current = se, () => {
800
+ X.current === se && (X.current = null);
725
801
  };
726
- }, [F, l, u, oe, Z]), V(() => {
727
- F && y.current && (l || u ? D(!0) : X(H, y.current, N));
728
- }, [F, l, u, H, N, X, D]), V(() => (W.current = !0, () => {
729
- W.current = !1, clearTimeout(Y.current), _.current && D(!0);
730
- }), [D]), V(() => {
731
- if (!F || !y.current || !z.current) return;
732
- const t = y.current.getBoundingClientRect(), a = z.current.getBoundingClientRect();
733
- a.right > t.right - 12 ? y.current.scrollLeft += a.right - t.right + 12 : a.left < t.left + 12 && (y.current.scrollLeft -= t.left + 12 - a.left);
734
- }, [T, A.caret, F]);
735
- const Me = (t, a) => {
736
- if (a ? w.onCut?.(t) : w.onCopy?.(t), t.defaultPrevented || l || a && u) return;
737
- const [E, $] = te(s.current);
738
- E !== $ && (t.preventDefault(), t.clipboardData.setData(
802
+ }, [h, l, u, se, X]), z(() => {
803
+ h && y.current && (l || u ? F(!0) : te(H, y.current, j));
804
+ }, [h, l, u, H, j, te, F]), z(() => (G.current = !0, () => {
805
+ G.current = !1, k.current && F(!0);
806
+ }), [F]);
807
+ const ze = (t, o) => {
808
+ if (o ? w.onCut?.(t) : w.onCopy?.(t), t.defaultPrevented || l || o && u || t.target !== A.current) return;
809
+ D();
810
+ const [C, K] = ae(d.current);
811
+ C !== K && (t.preventDefault(), t.clipboardData.setData(
739
812
  "text/plain",
740
- s.current.value.slice(E, $)
741
- ), a && x(me(s.current, -1)));
742
- }, ce = (t, a = !0) => {
743
- for (const E of y.current?.querySelectorAll(
744
- "[data-char-index]"
745
- ) ?? []) {
746
- const $ = E.getBoundingClientRect();
747
- if (t < $.left + $.width * (a ? 0.5 : 1))
748
- return Number(E.dataset.charIndex);
749
- }
750
- return s.current.value.length;
751
- }, ge = () => {
752
- y.current?.focus({ preventScroll: !0 }), !u && y.current && X(H, y.current, N);
753
- }, Xe = (t) => {
754
- if (w.onPointerDown?.(t), t.defaultPrevented || l || t.button !== 0) return;
755
- const a = t.pointerType === "mouse";
756
- if (a || t.preventDefault(), B.current || t.isPrimary === !1) {
757
- M();
758
- return;
759
- }
760
- const E = ce(t.clientX), $ = t.shiftKey ? s.current.anchor : E;
761
- B.current = {
762
- id: t.pointerId,
763
- x: t.clientX,
764
- y: t.clientY,
765
- anchor: $,
766
- mouse: a,
767
- held: !1
768
- }, clearTimeout(Y.current), a ? (ge(), x({ ...s.current, caret: E, anchor: $, composing: !1 }), y.current?.setPointerCapture?.(t.pointerId)) : u || (Y.current = setTimeout(() => {
769
- if (!B.current) return;
770
- B.current.held = !0;
771
- const [J, Ye] = it(
772
- s.current.value,
773
- ce(B.current.x, !1)
774
- );
775
- ge(), x({ ...s.current, anchor: J, caret: Ye, composing: !1 }), g();
776
- }, 550));
777
- }, [Ce, Ie] = te(s.current), Ue = Ee(T), Te = /* @__PURE__ */ C(
778
- "span",
779
- {
780
- ref: z,
781
- "aria-hidden": "true",
782
- className: "vk-caret",
783
- style: {
784
- display: "inline-block",
785
- width: 0,
786
- height: "1.1em",
787
- verticalAlign: "-0.15em",
788
- position: "relative"
813
+ d.current.value.slice(C, K)
814
+ ), o ? E(ve(d.current, -1)) : fe("복사했어요"));
815
+ }, Be = (t) => {
816
+ if (l || u) return;
817
+ const o = pt(
818
+ d.current,
819
+ t.value,
820
+ {
821
+ start: t.selectionStart ?? t.value.length,
822
+ end: t.selectionEnd ?? t.value.length,
823
+ backward: t.selectionDirection === "backward"
789
824
  },
790
- children: F && !u && !l && Ce === Ie && /* @__PURE__ */ C(
791
- "span",
792
- {
793
- style: {
794
- position: "absolute",
795
- height: "100%",
796
- borderLeft: "2px solid currentColor"
797
- }
798
- }
825
+ j.sanitizeValue,
826
+ j.filterKey,
827
+ V
828
+ );
829
+ t.value = o.value, E({ ...o });
830
+ }, _e = Object.fromEntries(
831
+ Object.entries(w).filter(([t]) => t.startsWith("aria-"))
832
+ ), Je = Object.fromEntries(
833
+ Object.entries(w).filter(
834
+ ([t]) => !t.startsWith("aria-") && !["id", "tabIndex", "role", "contentEditable", "children"].includes(
835
+ t
799
836
  )
800
- }
837
+ )
801
838
  );
802
839
  return /* @__PURE__ */ q(
803
840
  "div",
804
841
  {
805
- ...w,
842
+ ...Je,
806
843
  ref: y,
807
- id: w.id ?? H,
808
- role: "textbox",
809
- tabIndex: l ? -1 : w.tabIndex ?? 0,
810
- "aria-disabled": l || void 0,
811
- "aria-readonly": u || void 0,
812
- "aria-multiline": "false",
813
- "aria-placeholder": o,
814
844
  "data-virtual-input": "true",
815
- "data-focused": F || void 0,
816
- "data-value": T,
845
+ "data-focused": h || void 0,
817
846
  style: {
818
- display: "block",
847
+ position: "relative",
848
+ display: "flex",
849
+ alignItems: "center",
819
850
  boxSizing: "border-box",
820
851
  minHeight: "2.75em",
821
852
  padding: "0.65em 0.8em",
@@ -823,91 +854,89 @@ const kt = We(
823
854
  borderRadius: 8,
824
855
  font: "inherit",
825
856
  width: "100%",
826
- whiteSpace: "pre",
827
- overflowX: "auto",
828
- scrollbarWidth: "none",
829
857
  cursor: l ? "not-allowed" : "text",
830
- userSelect: "none",
831
- WebkitUserSelect: "none",
832
- WebkitTouchCallout: "none",
833
- touchAction: "manipulation",
834
858
  opacity: l ? 0.5 : 1,
835
- outlineOffset: 3,
859
+ colorScheme: ue,
860
+ outline: b ? "2px solid currentColor" : void 0,
861
+ outlineOffset: 2,
836
862
  ...w.style
837
863
  },
838
864
  onFocus: (t) => {
839
- w.onFocus?.(t), !t.defaultPrevented && !l && !u && X(H, t.currentTarget, N);
865
+ O(!0), w.onFocus?.(t), !t.defaultPrevented && !l && !u && te(H, t.currentTarget, j);
840
866
  },
841
867
  onBlur: (t) => {
842
- w.onBlur?.(t), M(), t.defaultPrevented || D(t);
868
+ O(!1), w.onBlur?.(t), t.defaultPrevented || F(t);
843
869
  },
844
- onKeyDown: Ne,
845
- onCopy: (t) => Me(t, !1),
846
- onCut: (t) => Me(t, !0),
870
+ onKeyDown: Ye,
871
+ onCopy: (t) => ze(t, !1),
872
+ onCut: (t) => ze(t, !0),
847
873
  onPaste: (t) => {
848
- w.onPaste?.(t), !t.defaultPrevented && !l && !u && (t.preventDefault(), ee(t.clipboardData.getData("text/plain")));
849
- },
850
- onPointerDown: Xe,
851
- onPointerMove: (t) => {
852
- if (w.onPointerMove?.(t), t.defaultPrevented) {
853
- M();
854
- return;
855
- }
856
- !B.current || B.current.id !== t.pointerId || Math.hypot(
857
- t.clientX - B.current.x,
858
- t.clientY - B.current.y
859
- ) > 8 && (clearTimeout(Y.current), B.current.mouse ? x({
860
- ...s.current,
861
- caret: ce(t.clientX),
862
- anchor: B.current.anchor,
863
- composing: !1
864
- }) : M());
865
- },
866
- onPointerUp: (t) => {
867
- w.onPointerUp?.(t);
868
- const a = B.current;
869
- if (!t.defaultPrevented && a?.id === t.pointerId && !a.mouse && !a.held && Math.hypot(t.clientX - a.x, t.clientY - a.y) <= 8) {
870
- const E = ce(t.clientX);
871
- ge(), x({
872
- ...s.current,
873
- caret: E,
874
- anchor: E,
875
- composing: !1
876
- });
877
- }
878
- M();
879
- },
880
- onPointerCancel: (t) => {
881
- w.onPointerCancel?.(t), M();
882
- },
883
- onLostPointerCapture: (t) => {
884
- w.onLostPointerCapture?.(t), B.current?.id === t.pointerId && M();
885
- },
886
- onContextMenu: (t) => {
887
- w.onContextMenu?.(t), t.defaultPrevented || t.preventDefault();
874
+ w.onPaste?.(t), !t.defaultPrevented && !l && !u && (t.preventDefault(), ce(t.clipboardData.getData("text/plain")));
888
875
  },
889
876
  children: [
890
- Ue.map(({ segment: t, index: a }) => /* @__PURE__ */ q("span", { children: [
891
- a === s.current.caret && Te,
892
- /* @__PURE__ */ C(
893
- "span",
894
- {
895
- "data-char-index": a,
896
- style: a >= Ce && a < Ie ? { background: "#bfdbfe", color: "#0f172a" } : void 0,
897
- children: t
898
- }
899
- )
900
- ] }, a)),
901
- s.current.caret === T.length && Te,
902
- !T && /* @__PURE__ */ C(
903
- "span",
877
+ /* @__PURE__ */ T(
878
+ "input",
904
879
  {
905
- "aria-hidden": "true",
906
- style: { color: p === "dark" ? "#a6b7a9" : "#58665d" },
907
- children: o || " "
880
+ ..._e,
881
+ ref: A,
882
+ id: w.id ?? H,
883
+ type: "text",
884
+ role: "textbox",
885
+ inputMode: "none",
886
+ autoComplete: "off",
887
+ autoCorrect: "off",
888
+ autoCapitalize: "off",
889
+ spellCheck: w.spellCheck ?? !1,
890
+ tabIndex: l ? -1 : w.tabIndex ?? 0,
891
+ disabled: l,
892
+ readOnly: u,
893
+ "aria-disabled": l || void 0,
894
+ "aria-readonly": u || void 0,
895
+ "data-virtual-input": "true",
896
+ "data-focused": h || void 0,
897
+ "data-value": W,
898
+ placeholder: a,
899
+ value: Y ?? W,
900
+ style: {
901
+ position: "absolute",
902
+ inset: 0,
903
+ boxSizing: "border-box",
904
+ display: "block",
905
+ width: "100%",
906
+ height: "100%",
907
+ minWidth: 0,
908
+ minHeight: "1.5em",
909
+ margin: 0,
910
+ padding: "inherit",
911
+ border: 0,
912
+ borderRadius: "inherit",
913
+ outline: "none",
914
+ background: "transparent",
915
+ color: "inherit",
916
+ caretColor: "currentColor",
917
+ font: "inherit",
918
+ lineHeight: "inherit",
919
+ letterSpacing: "inherit",
920
+ textAlign: "inherit",
921
+ appearance: "none",
922
+ WebkitAppearance: "none",
923
+ userSelect: "text",
924
+ WebkitUserSelect: "text",
925
+ touchAction: "manipulation"
926
+ },
927
+ onChange: (t) => {
928
+ B.current ? N(t.currentTarget.value) : Be(t.currentTarget);
929
+ },
930
+ onSelect: D,
931
+ onCompositionStart: () => {
932
+ D(), R.current = d.current, B.current = !0, N(A.current?.value ?? d.current.value);
933
+ },
934
+ onCompositionEnd: (t) => {
935
+ B.current = !1, N(null), R.current?.value === d.current.value ? Be(t.currentTarget) : (t.currentTarget.value = d.current.value, E({ ...d.current })), R.current = null;
936
+ }
908
937
  }
909
938
  ),
910
- /* @__PURE__ */ C(
939
+ /* @__PURE__ */ T(
911
940
  "span",
912
941
  {
913
942
  role: "status",
@@ -919,14 +948,14 @@ const kt = We(
919
948
  clipPath: "inset(50%)",
920
949
  whiteSpace: "nowrap"
921
950
  },
922
- children: b
951
+ children: ye
923
952
  }
924
953
  )
925
954
  ]
926
955
  }
927
956
  );
928
957
  }
929
- ), ct = [
958
+ ), gt = [
930
959
  [
931
960
  {
932
961
  value: "1"
@@ -1043,97 +1072,97 @@ const kt = We(
1043
1072
  }
1044
1073
  ]
1045
1074
  ];
1046
- function ut({
1075
+ function vt({
1047
1076
  tagName: e,
1048
- css: r,
1049
- children: n,
1050
- hostRef: o,
1077
+ css: n,
1078
+ children: r,
1079
+ hostRef: a,
1051
1080
  ...i
1052
1081
  }) {
1053
- const [c, h] = R(null), v = k(
1054
- (d) => {
1055
- o && (o.current = d), d && h(d.shadowRoot ?? d.attachShadow({ mode: "open" }));
1082
+ const [s, f] = P(null), v = S(
1083
+ (c) => {
1084
+ a && (a.current = c), c && f(c.shadowRoot ?? c.attachShadow({ mode: "open" }));
1056
1085
  },
1057
- [o]
1086
+ [a]
1058
1087
  );
1059
- return Je(
1088
+ return at(
1060
1089
  e,
1061
1090
  { ...i, ref: v },
1062
- c && ke(
1063
- /* @__PURE__ */ q(ze, { children: [
1064
- r && /* @__PURE__ */ C("style", { children: r }),
1065
- n
1091
+ s && Te(
1092
+ /* @__PURE__ */ q(Me, { children: [
1093
+ n && /* @__PURE__ */ T("style", { children: n }),
1094
+ r
1066
1095
  ] }),
1067
- c
1096
+ s
1068
1097
  )
1069
1098
  );
1070
1099
  }
1071
- function De(e, r, n) {
1100
+ function je(e, n, r) {
1072
1101
  if (e.type === "action") return e.value === `
1073
1102
  ` ? "Enter" : e.value;
1074
1103
  if (!/^[a-zA-Z]$/.test(e.value)) return e.value;
1075
- const o = n ? e.value.toUpperCase() : e.value;
1076
- return r ? Re(o) : o;
1104
+ const a = r ? e.value.toUpperCase() : e.value;
1105
+ return n ? Ue(a) : a;
1077
1106
  }
1078
- function xe(e, { disabled: r = !1, repeat: n = !1 } = {}) {
1079
- const o = P(e);
1080
- o.current = e;
1081
- const i = P(void 0), c = P(null), [h, v] = R(!1), d = k(() => {
1082
- clearTimeout(i.current), c.current = null, v(!1);
1107
+ function Ae(e, { disabled: n = !1, repeat: r = !1 } = {}) {
1108
+ const a = I(e);
1109
+ a.current = e;
1110
+ const i = I(void 0), s = I(null), [f, v] = P(!1), c = S(() => {
1111
+ clearTimeout(i.current), s.current = null, v(!1);
1083
1112
  }, []);
1084
- V(() => (window.addEventListener("blur", d), document.addEventListener("visibilitychange", d), () => {
1085
- d(), window.removeEventListener("blur", d), document.removeEventListener("visibilitychange", d);
1086
- }), [d]), V(() => {
1087
- r && d();
1088
- }, [r, d]);
1089
- const L = (f) => {
1090
- const l = c.current?.bounds;
1091
- return !!l && f.clientX >= l.left && f.clientX <= l.right && f.clientY >= l.top && f.clientY <= l.bottom;
1113
+ z(() => (window.addEventListener("blur", c), document.addEventListener("visibilitychange", c), () => {
1114
+ c(), window.removeEventListener("blur", c), document.removeEventListener("visibilitychange", c);
1115
+ }), [c]), z(() => {
1116
+ n && c();
1117
+ }, [n, c]);
1118
+ const m = (p) => {
1119
+ const l = s.current?.bounds;
1120
+ return !!l && p.clientX >= l.left && p.clientX <= l.right && p.clientY >= l.top && p.clientY <= l.bottom;
1092
1121
  };
1093
1122
  return {
1094
- "data-pressed": h || void 0,
1095
- onPointerDown: (f) => {
1096
- if (!(r || f.button !== 0 || c.current)) {
1097
- f.preventDefault(), c.current = {
1098
- id: f.pointerId,
1099
- bounds: f.currentTarget.getBoundingClientRect(),
1123
+ "data-pressed": f || void 0,
1124
+ onPointerDown: (p) => {
1125
+ if (!(n || p.button !== 0 || s.current)) {
1126
+ p.preventDefault(), s.current = {
1127
+ id: p.pointerId,
1128
+ bounds: p.currentTarget.getBoundingClientRect(),
1100
1129
  repeated: !1
1101
1130
  }, v(!0);
1102
1131
  try {
1103
- f.currentTarget.setPointerCapture?.(f.pointerId);
1132
+ p.currentTarget.setPointerCapture?.(p.pointerId);
1104
1133
  } catch {
1105
1134
  }
1106
- if (n) {
1135
+ if (r) {
1107
1136
  const l = () => {
1108
- c.current && (c.current.repeated = !0, o.current(), i.current = setTimeout(l, 65));
1137
+ s.current && (s.current.repeated = !0, a.current(), i.current = setTimeout(l, 65));
1109
1138
  };
1110
1139
  i.current = setTimeout(l, 450);
1111
1140
  }
1112
1141
  }
1113
1142
  },
1114
- onPointerMove: (f) => {
1115
- c.current?.id === f.pointerId && !L(f) && d();
1143
+ onPointerMove: (p) => {
1144
+ s.current?.id === p.pointerId && !m(p) && c();
1116
1145
  },
1117
- onPointerUp: (f) => {
1118
- if (c.current?.id !== f.pointerId) return;
1119
- const l = !r && L(f) && !c.current.repeated;
1120
- d(), l && o.current();
1146
+ onPointerUp: (p) => {
1147
+ if (s.current?.id !== p.pointerId) return;
1148
+ const l = !n && m(p) && !s.current.repeated;
1149
+ c(), l && a.current();
1121
1150
  },
1122
- onPointerCancel: (f) => {
1123
- c.current?.id === f.pointerId && d();
1151
+ onPointerCancel: (p) => {
1152
+ s.current?.id === p.pointerId && c();
1124
1153
  },
1125
- onLostPointerCapture: (f) => {
1126
- c.current?.id === f.pointerId && d();
1154
+ onLostPointerCapture: (p) => {
1155
+ s.current?.id === p.pointerId && c();
1127
1156
  },
1128
- onPointerLeave: (f) => {
1129
- c.current?.id === f.pointerId && !L(f) && d();
1157
+ onPointerLeave: (p) => {
1158
+ s.current?.id === p.pointerId && !m(p) && c();
1130
1159
  },
1131
- onClick: (f) => {
1132
- !r && f.detail === 0 && !c.current && o.current();
1160
+ onClick: (p) => {
1161
+ !n && p.detail === 0 && !s.current && a.current();
1133
1162
  }
1134
1163
  };
1135
1164
  }
1136
- const $e = {
1165
+ const Ce = {
1137
1166
  Shift: "Shift",
1138
1167
  HangulMode: "한영 전환",
1139
1168
  Backspace: "지우기",
@@ -1152,30 +1181,50 @@ const $e = {
1152
1181
  Redo: "다시 실행",
1153
1182
  SelectAll: "전체 선택"
1154
1183
  };
1155
- function st({
1184
+ function Ne({
1156
1185
  cell: e,
1157
- label: r,
1158
- value: n,
1159
- active: o,
1186
+ label: n,
1187
+ value: r,
1188
+ active: a,
1160
1189
  disabled: i,
1161
- dispatch: c
1190
+ dispatch: s
1162
1191
  }) {
1163
- const h = xe(c, {
1192
+ const f = Ae(s, {
1164
1193
  disabled: i,
1165
- repeat: ["Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(n)
1166
- }), v = e.type === "action" && n === "HangulMode";
1167
- return /* @__PURE__ */ C(
1194
+ repeat: ["Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(r)
1195
+ }), v = e.type === "action" && r === "HangulMode", c = e.type === "action" && (r === "Backspace" && (!e.label || e.label === "⌫") || r === "Delete" && (!e.label || e.label === "⌦"));
1196
+ return /* @__PURE__ */ T(
1168
1197
  "button",
1169
1198
  {
1170
1199
  type: "button",
1171
1200
  disabled: i,
1172
- "aria-label": $e[n] ?? r,
1173
- "aria-pressed": o,
1201
+ "aria-label": Ce[r] ?? n,
1202
+ "aria-pressed": a,
1174
1203
  className: v ? "key action language" : e.type === "action" ? "key action" : "key",
1175
- title: v ? i ? `${o ? "한국어" : "영어"} 전용` : `${o ? "영어" : "한국어"}로 전환` : void 0,
1204
+ title: v ? i ? `${a ? "한국어" : "영어"} 전용` : `${a ? "영어" : "한국어"}로 전환` : void 0,
1176
1205
  style: { flex: e.width && e.width > 0 ? e.width : 1 },
1177
- ...h,
1178
- children: v && !e.label ? /* @__PURE__ */ q("span", { className: "language-label", "aria-hidden": "true", children: [
1206
+ ...f,
1207
+ children: c ? /* @__PURE__ */ q(
1208
+ "svg",
1209
+ {
1210
+ "data-key-icon": r === "Backspace" ? "backspace" : "delete",
1211
+ "aria-hidden": "true",
1212
+ width: "24",
1213
+ height: "24",
1214
+ viewBox: "0 0 24 24",
1215
+ fill: "none",
1216
+ stroke: "currentColor",
1217
+ strokeWidth: "1.7",
1218
+ strokeLinecap: "round",
1219
+ strokeLinejoin: "round",
1220
+ focusable: "false",
1221
+ style: r === "Delete" ? { transform: "scaleX(-1)" } : void 0,
1222
+ children: [
1223
+ /* @__PURE__ */ T("path", { d: "M9 5H20a1.5 1.5 0 0 1 1.5 1.5v11A1.5 1.5 0 0 1 20 19H9l-7-7 7-7Z" }),
1224
+ /* @__PURE__ */ T("path", { d: "m12 9 6 6m0-6-6 6" })
1225
+ ]
1226
+ }
1227
+ ) : v && !e.label ? /* @__PURE__ */ q("span", { className: "language-label", "aria-hidden": "true", children: [
1179
1228
  /* @__PURE__ */ q(
1180
1229
  "svg",
1181
1230
  {
@@ -1189,72 +1238,73 @@ function st({
1189
1238
  strokeLinejoin: "round",
1190
1239
  focusable: "false",
1191
1240
  children: [
1192
- /* @__PURE__ */ C("circle", { cx: "12", cy: "12", r: "9" }),
1193
- /* @__PURE__ */ C("ellipse", { cx: "12", cy: "12", rx: "4", ry: "9" }),
1194
- /* @__PURE__ */ C("path", { d: "M3 12h18" })
1241
+ /* @__PURE__ */ T("circle", { cx: "12", cy: "12", r: "9" }),
1242
+ /* @__PURE__ */ T("ellipse", { cx: "12", cy: "12", rx: "4", ry: "9" }),
1243
+ /* @__PURE__ */ T("path", { d: "M3 12h18" })
1195
1244
  ]
1196
1245
  }
1197
1246
  ),
1198
- /* @__PURE__ */ C("span", { children: o ? "한" : "EN" })
1199
- ] }) : r
1247
+ /* @__PURE__ */ T("span", { children: a ? "한" : "EN" })
1248
+ ] }) : n
1200
1249
  }
1201
1250
  );
1202
1251
  }
1203
- function dt({
1252
+ function mt({
1204
1253
  layout: e,
1205
- viewport: r,
1206
- onHeightChange: n
1254
+ viewport: n,
1255
+ onHeightChange: r
1207
1256
  }) {
1208
- const o = Fe(), {
1257
+ const a = Ze(), {
1209
1258
  inputRef: i,
1210
- hangulMode: c,
1211
- shift: h,
1259
+ hangulMode: s,
1260
+ shift: f,
1212
1261
  shiftLocked: v,
1213
- theme: d,
1214
- selectionMode: L,
1215
- selectionAdjusting: f,
1262
+ theme: c,
1263
+ selectionMode: m,
1264
+ selectionAdjusting: p,
1216
1265
  activeInputPolicy: l,
1217
- onBlur: u
1218
- } = o, I = P(null), [w, Q] = R(!1), H = xe(() => Q((p) => !p)), re = xe(() => u(!0)), X = ["text", "hangul", "custom"].includes(
1266
+ editingStatus: u,
1267
+ onBlur: V
1268
+ } = a, w = I(null), [Q, H] = P(!1), le = Ae(() => H((g) => !g)), te = Ae(() => V(!0)), F = ["text", "hangul", "custom"].includes(
1219
1269
  l.mode
1220
- ), D = w && X && !L ? ct : e;
1221
- V(() => {
1222
- if (!I.current) return;
1223
- const p = () => {
1224
- const g = I.current?.getBoundingClientRect().height ?? 0;
1225
- n(g);
1270
+ ), oe = Q && F && !m ? gt : e;
1271
+ z(() => {
1272
+ if (!w.current) return;
1273
+ const g = () => {
1274
+ const y = w.current?.getBoundingClientRect().height ?? 0;
1275
+ r(y);
1226
1276
  };
1227
- p();
1228
- const S = new ResizeObserver(p);
1229
- return S.observe(I.current), () => S.disconnect();
1230
- }, [n]), V(() => {
1231
- let p = null;
1232
- const S = /* @__PURE__ */ new Set(), g = (m) => m.composedPath().some(
1233
- (U) => U === I.current || U instanceof Element && U.hasAttribute("data-virtual-input")
1234
- ), y = (m) => {
1235
- S.add(m.pointerId), p = S.size !== 1 || m.button !== 0 || g(m) ? null : { x: m.clientX, y: m.clientY, id: m.pointerId };
1236
- }, z = (m) => {
1237
- p && p.id === m.pointerId && Math.hypot(m.clientX - p.x, m.clientY - p.y) < 10 && !g(m) && u(!0), p = null, S.delete(m.pointerId);
1238
- }, A = (m) => {
1239
- p?.id === m.pointerId && Math.hypot(m.clientX - p.x, m.clientY - p.y) >= 10 && (p = null);
1240
- }, j = () => {
1241
- p = null;
1242
- }, T = (m) => {
1243
- j(), S.delete(m.pointerId);
1244
- }, s = () => {
1245
- j(), S.clear();
1277
+ g();
1278
+ const L = new ResizeObserver(g);
1279
+ return L.observe(w.current), () => L.disconnect();
1280
+ }, [r]), z(() => {
1281
+ let g = null;
1282
+ const L = /* @__PURE__ */ new Set(), y = (b) => b.composedPath().some(
1283
+ (O) => O === w.current || O instanceof Element && O.hasAttribute("data-virtual-input")
1284
+ ), A = (b) => {
1285
+ L.add(b.pointerId), g = L.size !== 1 || b.button !== 0 || y(b) ? null : { x: b.clientX, y: b.clientY, id: b.pointerId };
1286
+ }, x = (b) => {
1287
+ g && g.id === b.pointerId && Math.hypot(b.clientX - g.x, b.clientY - g.y) < 10 && !y(b) && V(!0), g = null, L.delete(b.pointerId);
1288
+ }, B = (b) => {
1289
+ g?.id === b.pointerId && Math.hypot(b.clientX - g.x, b.clientY - g.y) >= 10 && (g = null);
1290
+ }, R = () => {
1291
+ g = null;
1292
+ }, Y = (b) => {
1293
+ R(), L.delete(b.pointerId);
1294
+ }, N = () => {
1295
+ R(), L.clear();
1246
1296
  };
1247
- return window.addEventListener("pointerdown", y, !0), window.addEventListener("pointermove", A, !0), window.addEventListener("pointerup", z, !0), window.addEventListener("pointercancel", T, !0), window.addEventListener("scroll", j, !0), window.addEventListener("blur", s), document.addEventListener("visibilitychange", s), () => {
1248
- window.removeEventListener("pointerdown", y, !0), window.removeEventListener("pointermove", A, !0), window.removeEventListener("pointerup", z, !0), window.removeEventListener("pointercancel", T, !0), window.removeEventListener("scroll", j, !0), window.removeEventListener("blur", s), document.removeEventListener("visibilitychange", s);
1297
+ return window.addEventListener("pointerdown", A, !0), window.addEventListener("pointermove", B, !0), window.addEventListener("pointerup", x, !0), window.addEventListener("pointercancel", Y, !0), window.addEventListener("scroll", R, !0), window.addEventListener("blur", N), document.addEventListener("visibilitychange", N), () => {
1298
+ window.removeEventListener("pointerdown", A, !0), window.removeEventListener("pointermove", B, !0), window.removeEventListener("pointerup", x, !0), window.removeEventListener("pointercancel", Y, !0), window.removeEventListener("scroll", R, !0), window.removeEventListener("blur", N), document.removeEventListener("visibilitychange", N);
1249
1299
  };
1250
- }, [u]);
1251
- const O = (p) => {
1252
- const S = De(p, c, h);
1253
- if (p.type !== "action") {
1254
- i.current?.insertText(S, fe(S)), o.consumeShift();
1300
+ }, [V]);
1301
+ const X = (g) => {
1302
+ const L = je(g, s, f);
1303
+ if (g.type !== "action") {
1304
+ i.current?.insertText(L, we(L)), a.consumeShift();
1255
1305
  return;
1256
1306
  }
1257
- switch (S) {
1307
+ switch (L) {
1258
1308
  case "Undo":
1259
1309
  i.current?.undo();
1260
1310
  break;
@@ -1265,21 +1315,21 @@ function dt({
1265
1315
  i.current?.selectAll();
1266
1316
  break;
1267
1317
  case "Shift":
1268
- o.toggleShift();
1318
+ a.toggleShift();
1269
1319
  break;
1270
1320
  case "HangulMode":
1271
1321
  i.current?.handleKeyDown(
1272
- new KeyboardEvent("keydown", { key: S })
1322
+ new KeyboardEvent("keydown", { key: L })
1273
1323
  );
1274
1324
  break;
1275
1325
  case "EnterSelectionMode":
1276
- Q(!1), o.enterSelectionMode();
1326
+ H(!1), a.enterSelectionMode();
1277
1327
  break;
1278
1328
  case "ExitSelectionMode":
1279
- o.exitSelectionMode();
1329
+ a.exitSelectionMode();
1280
1330
  break;
1281
1331
  case "ToggleSelectionAdjust":
1282
- o.toggleSelectionAdjust();
1332
+ a.toggleSelectionAdjust();
1283
1333
  break;
1284
1334
  case "Copy":
1285
1335
  i.current?.copySelection();
@@ -1291,54 +1341,54 @@ function dt({
1291
1341
  i.current?.cutSelection();
1292
1342
  break;
1293
1343
  case "ArrowLeft":
1294
- i.current?.moveCaret("left", f);
1344
+ i.current?.moveCaret("left", p);
1295
1345
  break;
1296
1346
  case "ArrowRight":
1297
- i.current?.moveCaret("right", f);
1347
+ i.current?.moveCaret("right", p);
1298
1348
  break;
1299
1349
  default:
1300
- S === " " ? i.current?.insertText(" ") : i.current?.handleKeyDown(
1301
- new KeyboardEvent("keydown", { key: S })
1350
+ L === " " ? i.current?.insertText(" ") : i.current?.handleKeyDown(
1351
+ new KeyboardEvent("keydown", { key: L })
1302
1352
  );
1303
1353
  }
1304
- }, Z = de(l.mode) !== null, ne = {
1354
+ }, J = me(l.mode) !== null, ue = {
1305
1355
  position: "fixed",
1306
1356
  zIndex: 9999,
1307
1357
  boxSizing: "border-box",
1308
1358
  display: "block",
1309
- width: Math.min(r.width || 760, 760),
1310
- left: r.offsetLeft + r.width / 2,
1311
- transform: r.height ? "translate(-50%, -100%)" : "translateX(-50%)",
1312
- ...r.height ? { top: r.offsetTop + r.height } : { bottom: 0 },
1313
- maxHeight: r.height ? r.height * 0.65 : "65dvh",
1359
+ width: Math.min(n.width || 760, 760),
1360
+ left: n.offsetLeft + n.width / 2,
1361
+ transform: n.height ? "translate(-50%, -100%)" : "translateX(-50%)",
1362
+ ...n.height ? { top: n.offsetTop + n.height } : { bottom: 0 },
1363
+ maxHeight: n.height ? n.height * 0.65 : "65dvh",
1314
1364
  overflowY: "auto",
1315
- colorScheme: d,
1316
- background: d === "dark" ? "#18201f" : "#e9eeeb",
1317
- color: d === "dark" ? "#eef4ef" : "#203b31",
1318
- border: "1px solid " + (d === "dark" ? "#35413c" : "#c8d3cb"),
1365
+ colorScheme: c,
1366
+ background: c === "dark" ? "#18201f" : "#e9eeeb",
1367
+ color: c === "dark" ? "#eef4ef" : "#203b31",
1368
+ border: "1px solid " + (c === "dark" ? "#35413c" : "#c8d3cb"),
1319
1369
  borderRadius: "20px 20px 0 0",
1320
1370
  boxShadow: "0 -8px 48px #10251a20",
1321
1371
  touchAction: "manipulation",
1322
1372
  userSelect: "none",
1323
1373
  WebkitUserSelect: "none"
1324
1374
  };
1325
- return ke(
1326
- /* @__PURE__ */ C(
1327
- ut,
1375
+ return Te(
1376
+ /* @__PURE__ */ T(
1377
+ vt,
1328
1378
  {
1329
1379
  tagName: "virtual-keypad",
1330
- hostRef: I,
1380
+ hostRef: w,
1331
1381
  "data-virtual-keypad": "true",
1332
- style: ne,
1333
- onPointerDown: (p) => {
1334
- p.button === 0 && p.preventDefault();
1382
+ style: ue,
1383
+ onPointerDown: (g) => {
1384
+ g.button === 0 && g.preventDefault();
1335
1385
  },
1336
- onMouseDown: (p) => {
1337
- p.button === 0 && p.preventDefault();
1386
+ onMouseDown: (g) => {
1387
+ g.button === 0 && g.preventDefault();
1338
1388
  },
1339
- onBlur: o.onBlur,
1340
- onKeyDown: (p) => {
1341
- p.key === "Escape" && (p.preventDefault(), u(!0));
1389
+ onBlur: a.onBlur,
1390
+ onKeyDown: (g) => {
1391
+ g.key === "Escape" && (g.preventDefault(), V(!0));
1342
1392
  },
1343
1393
  css: `
1344
1394
  * {
@@ -1356,6 +1406,8 @@ function dt({
1356
1406
  justify-content: space-between;
1357
1407
  padding: 0 6px 8px;
1358
1408
  font-size: 12px;
1409
+ min-height: 52px;
1410
+ gap: 5px;
1359
1411
  }
1360
1412
  .toolbar span {
1361
1413
  opacity: 0.75;
@@ -1377,13 +1429,16 @@ function dt({
1377
1429
  margin-top: 7px;
1378
1430
  }
1379
1431
  .key {
1432
+ display: inline-flex;
1433
+ align-items: center;
1434
+ justify-content: center;
1380
1435
  min-width: 0;
1381
1436
  min-height: 44px;
1382
1437
  border: 0;
1383
1438
  border-radius: 8px;
1384
- background: ${d === "dark" ? "#303c37" : "#fff"};
1439
+ background: ${c === "dark" ? "#303c37" : "#fff"};
1385
1440
  color: inherit;
1386
- box-shadow: 0 2px 0 ${d === "dark" ? "#0d1611" : "#bdc9c1"};
1441
+ box-shadow: 0 2px 0 ${c === "dark" ? "#0d1611" : "#bdc9c1"};
1387
1442
  font: inherit;
1388
1443
  padding: 8px 0;
1389
1444
  touch-action: none;
@@ -1391,9 +1446,29 @@ function dt({
1391
1446
  user-select: none;
1392
1447
  }
1393
1448
  .action {
1394
- background: ${d === "dark" ? "#414e46" : "#d7e1db"};
1449
+ background: ${c === "dark" ? "#414e46" : "#d7e1db"};
1395
1450
  font-size: 14px;
1396
1451
  }
1452
+ .selection-count {
1453
+ min-width: 48px;
1454
+ white-space: nowrap;
1455
+ font-size: 11px;
1456
+ }
1457
+ .selection-actions {
1458
+ display: flex;
1459
+ flex: 1;
1460
+ gap: 5px;
1461
+ }
1462
+ .selection-actions .key {
1463
+ font-size: 12px;
1464
+ box-shadow: none;
1465
+ white-space: nowrap;
1466
+ }
1467
+ .feedback {
1468
+ margin: 0 6px 6px;
1469
+ font-size: 12px;
1470
+ line-height: 1.5;
1471
+ }
1397
1472
  .key[aria-pressed="true"]:not(.language) {
1398
1473
  background: #246447;
1399
1474
  color: #fff;
@@ -1445,107 +1520,135 @@ function dt({
1445
1520
  `,
1446
1521
  children: /* @__PURE__ */ q("section", { className: "keyboard", role: "group", "aria-label": "가상 키보드", children: [
1447
1522
  /* @__PURE__ */ q("div", { className: "toolbar", children: [
1448
- /* @__PURE__ */ q("span", { children: [
1449
- L ? "텍스트 편집" : w && X ? "숫자 · 기호" : l.mode === "number" ? "숫자" : l.mode === "tel" ? "전화번호" : c ? "한국어 · 두벌식" : "English",
1523
+ u.selectionLength > 0 && !m ? /* @__PURE__ */ q(Me, { children: [
1524
+ /* @__PURE__ */ T(
1525
+ "span",
1526
+ {
1527
+ className: "selection-count",
1528
+ title: u.message || void 0,
1529
+ children: u.message === "복사했어요" ? "복사했어요" : `${u.selectionLength}자 선택`
1530
+ }
1531
+ ),
1532
+ /* @__PURE__ */ T(
1533
+ "div",
1534
+ {
1535
+ className: "selection-actions",
1536
+ role: "group",
1537
+ "aria-label": "선택한 텍스트 편집",
1538
+ children: ["Copy", "Cut", "SelectAll"].map((g) => /* @__PURE__ */ T(
1539
+ Ne,
1540
+ {
1541
+ cell: { value: g, type: "action" },
1542
+ value: g,
1543
+ label: Ce[g],
1544
+ dispatch: () => X({ value: g, type: "action" })
1545
+ },
1546
+ g
1547
+ ))
1548
+ }
1549
+ )
1550
+ ] }) : /* @__PURE__ */ q("span", { children: [
1551
+ m ? u.message === "복사했어요" ? "복사했어요" : "텍스트 편집" : Q && F ? "숫자 · 기호" : l.mode === "number" ? "숫자" : l.mode === "tel" ? "전화번호" : s ? "한국어 · 두벌식" : "English",
1450
1552
  v ? " · Shift 고정" : ""
1451
1553
  ] }),
1452
- X && !L && /* @__PURE__ */ C(
1554
+ F && !m && !u.selectionLength && /* @__PURE__ */ T(
1453
1555
  "button",
1454
1556
  {
1455
1557
  type: "button",
1456
1558
  className: "close",
1457
1559
  "aria-label": "숫자·기호 전환",
1458
- "aria-pressed": w,
1459
- ...H,
1460
- children: w ? "가 / ABC" : "123 / #+="
1560
+ "aria-pressed": Q,
1561
+ ...le,
1562
+ children: Q ? "가 / ABC" : "123 / #+="
1461
1563
  }
1462
1564
  ),
1463
- /* @__PURE__ */ C(
1565
+ /* @__PURE__ */ T(
1464
1566
  "button",
1465
1567
  {
1466
1568
  type: "button",
1467
1569
  className: "close",
1468
- ...re,
1570
+ ...te,
1469
1571
  "aria-label": "키보드 닫기",
1470
1572
  children: "닫기 ↓"
1471
1573
  }
1472
1574
  )
1473
1575
  ] }),
1474
- D.map((p, S) => /* @__PURE__ */ C("div", { className: "row", children: p.map((g, y) => {
1475
- const z = De(g, c, h), A = g.type === "action" ? g.label ?? $e[z] ?? z : /^[A-Za-z]$/.test(g.value) ? z : g.label ?? z, j = g.value === "Shift" ? h : g.value === "HangulMode" ? c : g.value === "ToggleSelectionAdjust" ? f : void 0;
1476
- return /* @__PURE__ */ C(
1477
- st,
1576
+ u.message && u.message !== "복사했어요" && /* @__PURE__ */ T("p", { className: "feedback", children: u.message }),
1577
+ oe.map((g, L) => /* @__PURE__ */ T("div", { className: "row", children: g.map((y, A) => {
1578
+ const x = je(y, s, f), B = y.type === "action" ? y.label ?? Ce[x] ?? x : /^[A-Za-z]$/.test(y.value) ? x : y.label ?? x, R = y.value === "Shift" ? f : y.value === "HangulMode" ? s : y.value === "ToggleSelectionAdjust" ? p : void 0;
1579
+ return /* @__PURE__ */ T(
1580
+ Ne,
1478
1581
  {
1479
- cell: g,
1480
- label: A,
1481
- value: z,
1482
- active: j,
1483
- disabled: g.value === "HangulMode" && Z || (g.type !== "action" || z === " ") && !l.filterKey(z),
1484
- dispatch: () => O(g)
1582
+ cell: y,
1583
+ label: B,
1584
+ value: x,
1585
+ active: R,
1586
+ disabled: y.value === "HangulMode" && J || ["Copy", "Cut"].includes(x) && !u.selectionLength || x === "SelectAll" && !u.hasValue || (y.type !== "action" || x === " ") && !l.filterKey(x),
1587
+ dispatch: () => X(y)
1485
1588
  },
1486
- `${S}-${y}-${g.value}`
1589
+ `${L}-${A}-${y.value}`
1487
1590
  );
1488
- }) }, S))
1591
+ }) }, L))
1489
1592
  ] })
1490
1593
  }
1491
1594
  ),
1492
1595
  document.body
1493
1596
  );
1494
1597
  }
1495
- const ve = "virtual-keyboard:storage";
1496
- function ft(e, r) {
1497
- const n = P(r), [o, i] = R(r), c = P(o), h = k(
1498
- () => n.current instanceof Function ? n.current() : n.current,
1598
+ const ke = "virtual-keyboard:storage";
1599
+ function wt(e, n) {
1600
+ const r = I(n), [a, i] = P(n), s = I(a), f = S(
1601
+ () => r.current instanceof Function ? r.current() : r.current,
1499
1602
  []
1500
1603
  );
1501
- V(() => {
1502
- const d = (u) => {
1604
+ z(() => {
1605
+ const c = (u) => {
1503
1606
  try {
1504
- const I = u === null ? h() : JSON.parse(u);
1505
- return typeof I == typeof h() ? I : h();
1607
+ const V = u === null ? f() : JSON.parse(u);
1608
+ return typeof V == typeof f() ? V : f();
1506
1609
  } catch {
1507
- return h();
1610
+ return f();
1508
1611
  }
1509
- }, L = (u) => {
1510
- c.current = d(u), i(c.current);
1612
+ }, m = (u) => {
1613
+ s.current = c(u), i(s.current);
1511
1614
  };
1512
1615
  try {
1513
- L(window.localStorage.getItem(e));
1616
+ m(window.localStorage.getItem(e));
1514
1617
  } catch {
1515
1618
  }
1516
- const f = (u) => {
1619
+ const p = (u) => {
1517
1620
  try {
1518
1621
  if (u.storageArea && u.storageArea !== window.localStorage)
1519
1622
  return;
1520
1623
  } catch {
1521
1624
  return;
1522
1625
  }
1523
- (u.key === e || u.key === null) && L(u.newValue);
1626
+ (u.key === e || u.key === null) && m(u.newValue);
1524
1627
  }, l = (u) => {
1525
- const I = u.detail;
1526
- I.key === e && L(I.raw);
1628
+ const V = u.detail;
1629
+ V.key === e && m(V.raw);
1527
1630
  };
1528
- return window.addEventListener("storage", f), window.addEventListener(ve, l), () => {
1529
- window.removeEventListener("storage", f), window.removeEventListener(ve, l);
1631
+ return window.addEventListener("storage", p), window.addEventListener(ke, l), () => {
1632
+ window.removeEventListener("storage", p), window.removeEventListener(ke, l);
1530
1633
  };
1531
- }, [e, h]);
1532
- const v = k(
1533
- (d) => {
1534
- c.current = d instanceof Function ? d(c.current) : d, i(c.current), window.dispatchEvent(
1535
- new CustomEvent(ve, {
1536
- detail: { key: e, raw: JSON.stringify(c.current) }
1634
+ }, [e, f]);
1635
+ const v = S(
1636
+ (c) => {
1637
+ s.current = c instanceof Function ? c(s.current) : c, i(s.current), window.dispatchEvent(
1638
+ new CustomEvent(ke, {
1639
+ detail: { key: e, raw: JSON.stringify(s.current) }
1537
1640
  })
1538
1641
  );
1539
1642
  try {
1540
- window.localStorage.setItem(e, JSON.stringify(c.current));
1643
+ window.localStorage.setItem(e, JSON.stringify(s.current));
1541
1644
  } catch {
1542
1645
  }
1543
1646
  },
1544
1647
  [e]
1545
1648
  );
1546
- return [o, v];
1649
+ return [a, v];
1547
1650
  }
1548
- const pt = [
1651
+ const yt = [
1549
1652
  [
1550
1653
  {
1551
1654
  label: "전체 선택",
@@ -1625,7 +1728,7 @@ const pt = [
1625
1728
  type: "action"
1626
1729
  }
1627
1730
  ]
1628
- ], ht = () => typeof window > "u" ? { width: 0, height: 0, scale: 1, offsetLeft: 0, offsetTop: 0 } : typeof window < "u" && window.visualViewport ? {
1731
+ ], bt = () => typeof window > "u" ? { width: 0, height: 0, scale: 1, offsetLeft: 0, offsetTop: 0 } : typeof window < "u" && window.visualViewport ? {
1629
1732
  width: window.visualViewport.width,
1630
1733
  height: window.visualViewport.height,
1631
1734
  scale: window.visualViewport.scale,
@@ -1637,185 +1740,196 @@ const pt = [
1637
1740
  scale: 1,
1638
1741
  offsetLeft: 0,
1639
1742
  offsetTop: 0
1640
- }, gt = (e, r) => e.width === r.width && e.height === r.height && e.scale === r.scale && e.offsetLeft === r.offsetLeft && e.offsetTop === r.offsetTop, mt = () => {
1641
- const [e, r] = R(() => ({
1743
+ }, xt = (e, n) => e.width === n.width && e.height === n.height && e.scale === n.scale && e.offsetLeft === n.offsetLeft && e.offsetTop === n.offsetTop, kt = () => {
1744
+ const [e, n] = P(() => ({
1642
1745
  width: 0,
1643
1746
  height: 0,
1644
1747
  scale: 1,
1645
1748
  offsetLeft: 0,
1646
1749
  offsetTop: 0
1647
1750
  }));
1648
- return V(() => {
1751
+ return z(() => {
1649
1752
  if (typeof window > "u") return;
1650
- let n = null;
1651
- const o = () => {
1652
- const c = ht();
1653
- r(
1654
- (h) => gt(h, c) ? h : c
1753
+ let r = null;
1754
+ const a = () => {
1755
+ const s = bt();
1756
+ n(
1757
+ (f) => xt(f, s) ? f : s
1655
1758
  );
1656
1759
  };
1657
- o();
1760
+ a();
1658
1761
  const i = () => {
1659
- n !== null && cancelAnimationFrame(n), n = requestAnimationFrame(o);
1762
+ r !== null && cancelAnimationFrame(r), r = requestAnimationFrame(a);
1660
1763
  };
1661
1764
  return window.visualViewport ? (window.visualViewport.addEventListener("resize", i, {
1662
1765
  passive: !0
1663
1766
  }), window.visualViewport.addEventListener("scroll", i, {
1664
1767
  passive: !0
1665
1768
  })) : window.addEventListener("resize", i, { passive: !0 }), () => {
1666
- n !== null && cancelAnimationFrame(n), window.visualViewport ? (window.visualViewport.removeEventListener("resize", i), window.visualViewport.removeEventListener("scroll", i)) : window.removeEventListener("resize", i);
1769
+ r !== null && cancelAnimationFrame(r), window.visualViewport ? (window.visualViewport.removeEventListener("resize", i), window.visualViewport.removeEventListener("scroll", i)) : window.removeEventListener("resize", i);
1667
1770
  };
1668
1771
  }, []), e;
1669
1772
  };
1670
- function vt() {
1671
- const [e, r] = R("light");
1672
- return V(() => {
1773
+ function Et() {
1774
+ const [e, n] = P("light");
1775
+ return z(() => {
1673
1776
  if (typeof window > "u" || !window.matchMedia) return;
1674
- const n = window.matchMedia("(prefers-color-scheme: dark)");
1675
- r(n.matches ? "dark" : "light");
1676
- const o = (i) => {
1677
- r(i.matches ? "dark" : "light");
1777
+ const r = window.matchMedia("(prefers-color-scheme: dark)");
1778
+ n(r.matches ? "dark" : "light");
1779
+ const a = (i) => {
1780
+ n(i.matches ? "dark" : "light");
1678
1781
  };
1679
- return n.addEventListener("change", o), () => n.removeEventListener("change", o);
1782
+ return r.addEventListener("change", a), () => r.removeEventListener("change", a);
1680
1783
  }, []), e;
1681
1784
  }
1682
- function je(e) {
1785
+ function Xe(e) {
1683
1786
  return e !== void 0 ? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
1684
1787
  e
1685
- ) : typeof navigator > "u" ? !1 : je(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 || typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches;
1788
+ ) : typeof navigator > "u" ? !1 : Xe(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 || typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches;
1686
1789
  }
1687
- const we = "virtual-keyboard:focus-change";
1688
- function Et({
1790
+ const Ee = "virtual-keyboard:focus-change";
1791
+ function Tt({
1689
1792
  children: e,
1690
- layout: r = G,
1691
- defaultHangulMode: n = !0,
1692
- theme: o,
1793
+ layout: n = re,
1794
+ defaultHangulMode: r = !0,
1795
+ theme: a,
1693
1796
  keyboardVisibility: i = "auto"
1694
1797
  }) {
1695
- const c = Be(), h = P(null), v = P(null), d = P(
1798
+ const s = $e(), f = I(null), v = I(null), c = I(
1696
1799
  void 0
1697
- ), [L, f] = R(), [l, u] = R(0), [I, w] = R(!1), [Q, H] = R(!1), [re, X] = ft(
1800
+ ), [m, p] = P(), [l, u] = P(0), [V, w] = P(!1), [Q, H] = P(!1), [le, te] = P({
1801
+ selectionLength: 0,
1802
+ hasValue: !1,
1803
+ message: ""
1804
+ }), F = S((h) => {
1805
+ te(
1806
+ (k) => k.selectionLength === h.selectionLength && k.hasValue === h.hasValue && k.message === h.message ? k : h
1807
+ );
1808
+ }, []), [oe, X] = wt(
1698
1809
  "virtual-keyboard-hangul-mode",
1699
- n
1700
- ), [D, O] = R(
1701
- () => ye({ layout: r })
1702
- ), [Z, ne] = R(!1), [p, S] = R(0), g = mt(), y = vt(), z = de(D.mode) ?? re, A = !!L && (i === "always" || i === "auto" && Z), j = P(A);
1703
- j.current = A, V(() => {
1704
- const b = () => ne(je());
1705
- b();
1706
- const K = window.matchMedia?.("(pointer: coarse)");
1707
- return K?.addEventListener("change", b), () => K?.removeEventListener("change", b);
1810
+ r
1811
+ ), [J, ue] = P(
1812
+ () => Se({ layout: n })
1813
+ ), [g, L] = P(!1), [y, A] = P(0), x = kt(), B = Et(), R = me(J.mode) ?? oe, Y = !!m && (i === "always" || i === "auto" && g), N = I(Y);
1814
+ N.current = Y, z(() => {
1815
+ const h = () => L(Xe());
1816
+ h();
1817
+ const k = window.matchMedia?.("(pointer: coarse)");
1818
+ return k?.addEventListener("change", h), () => k?.removeEventListener("change", h);
1708
1819
  }, []);
1709
- const T = k(() => {
1710
- clearTimeout(d.current), v.current = null, h.current = null, f(void 0), u(0), w(!1), H(!1);
1820
+ const b = S(() => {
1821
+ clearTimeout(c.current), v.current = null, f.current = null, p(void 0), u(0), w(!1), H(!1);
1711
1822
  }, []);
1712
- V(() => {
1713
- const b = (K) => {
1714
- K.detail !== c && T();
1823
+ z(() => {
1824
+ const h = (k) => {
1825
+ k.detail !== s && b();
1715
1826
  };
1716
- return window.addEventListener(we, b), () => {
1717
- window.removeEventListener(we, b), clearTimeout(d.current);
1827
+ return window.addEventListener(Ee, h), () => {
1828
+ window.removeEventListener(Ee, h), clearTimeout(c.current);
1718
1829
  };
1719
- }, [c, T]);
1720
- const s = k(
1721
- (b, K, Y) => {
1722
- clearTimeout(d.current), v.current !== K && (u(0), w(!1), H(!1)), v.current = K, O(ye(Y)), f(b), window.dispatchEvent(
1723
- new CustomEvent(we, { detail: c })
1830
+ }, [s, b]);
1831
+ const O = S(
1832
+ (h, k, $) => {
1833
+ clearTimeout(c.current), v.current !== k && (u(0), w(!1), H(!1)), v.current = k, ue(Se($)), p(h), window.dispatchEvent(
1834
+ new CustomEvent(Ee, { detail: s })
1724
1835
  );
1725
1836
  },
1726
- [c]
1727
- ), m = k(
1728
- (b) => {
1729
- if (b === !0) {
1730
- T();
1837
+ [s]
1838
+ ), U = S(
1839
+ (h) => {
1840
+ if (h === !0) {
1841
+ const $ = document.activeElement, j = $ instanceof HTMLElement && v.current?.contains($);
1842
+ b(), j && $.blur();
1731
1843
  return;
1732
1844
  }
1733
- const K = typeof b == "object" ? b.relatedTarget : null;
1734
- K?.closest?.("[data-virtual-input], [data-virtual-keypad]") || !K && j.current || (clearTimeout(d.current), d.current = setTimeout(T, 0));
1845
+ const k = typeof h == "object" ? h.relatedTarget : null;
1846
+ k?.closest?.("[data-virtual-input], [data-virtual-keypad]") || !k && N.current || (clearTimeout(c.current), c.current = setTimeout(b, 0));
1735
1847
  },
1736
- [T]
1848
+ [b]
1737
1849
  );
1738
- V(() => {
1739
- if (!A || !p || g.scale !== 1) return;
1740
- const b = requestAnimationFrame(() => {
1741
- const K = v.current?.getBoundingClientRect();
1742
- if (!K) return;
1743
- const Y = g.offsetTop + g.height - p - 16;
1744
- K.bottom > Y && window.scrollBy({ top: K.bottom - Y, behavior: "instant" });
1850
+ z(() => {
1851
+ if (!Y || !y || x.scale !== 1) return;
1852
+ const h = requestAnimationFrame(() => {
1853
+ const k = v.current?.getBoundingClientRect();
1854
+ if (!k) return;
1855
+ const $ = x.offsetTop + x.height - y - 16;
1856
+ k.bottom > $ && window.scrollBy({ top: k.bottom - $, behavior: "instant" });
1745
1857
  });
1746
- return () => cancelAnimationFrame(b);
1858
+ return () => cancelAnimationFrame(h);
1747
1859
  }, [
1748
- L,
1749
- A,
1750
- p,
1751
- g.height,
1752
- g.offsetTop,
1753
- g.scale
1860
+ m,
1861
+ Y,
1862
+ y,
1863
+ x.height,
1864
+ x.offsetTop,
1865
+ x.scale
1754
1866
  ]);
1755
- const U = k(() => {
1756
- de(D.mode) === null && X((b) => !b);
1757
- }, [D.mode, X]), W = k(
1758
- () => u((b) => (b + 1) % 3),
1867
+ const de = S(() => {
1868
+ me(J.mode) === null && X((h) => !h);
1869
+ }, [J.mode, X]), W = S(
1870
+ () => u((h) => (h + 1) % 3),
1759
1871
  []
1760
- ), F = k(
1761
- () => u((b) => b === 1 ? 0 : b),
1872
+ ), d = S(
1873
+ () => u((h) => h === 1 ? 0 : h),
1762
1874
  []
1763
- ), _ = k(() => {
1875
+ ), ne = S(() => {
1764
1876
  w(!0), H(!1);
1765
- }, []), ae = k(() => {
1877
+ }, []), ie = S(() => {
1766
1878
  w(!1), H(!1);
1767
- }, []), N = k(
1768
- () => H((b) => !b),
1879
+ }, []), G = S(
1880
+ () => H((h) => !h),
1769
1881
  []
1770
1882
  );
1771
1883
  return /* @__PURE__ */ q(
1772
- He.Provider,
1884
+ We.Provider,
1773
1885
  {
1774
1886
  value: {
1775
- inputRef: h,
1776
- focusId: L,
1777
- onFocus: s,
1778
- onBlur: m,
1779
- defaultLayout: r,
1780
- hangulMode: z,
1887
+ inputRef: f,
1888
+ focusId: m,
1889
+ onFocus: O,
1890
+ onBlur: U,
1891
+ defaultLayout: n,
1892
+ hangulMode: R,
1781
1893
  shift: l > 0,
1782
1894
  shiftLocked: l === 2,
1783
- theme: o ?? y,
1784
- toggleKorean: U,
1895
+ theme: a ?? B,
1896
+ toggleKorean: de,
1785
1897
  toggleShift: W,
1786
- consumeShift: F,
1787
- selectionMode: I,
1898
+ consumeShift: d,
1899
+ selectionMode: V,
1788
1900
  selectionAdjusting: Q,
1789
- enterSelectionMode: _,
1790
- exitSelectionMode: ae,
1791
- toggleSelectionAdjust: N,
1792
- activeInputPolicy: D
1901
+ enterSelectionMode: ne,
1902
+ exitSelectionMode: ie,
1903
+ toggleSelectionAdjust: G,
1904
+ activeInputPolicy: J,
1905
+ editingStatus: le,
1906
+ setEditingStatus: F
1793
1907
  },
1794
1908
  children: [
1795
1909
  e,
1796
- A && /* @__PURE__ */ q(ze, { children: [
1797
- ke(
1798
- /* @__PURE__ */ C(
1910
+ Y && /* @__PURE__ */ q(Me, { children: [
1911
+ Te(
1912
+ /* @__PURE__ */ T(
1799
1913
  "div",
1800
1914
  {
1801
1915
  "aria-hidden": "true",
1802
1916
  style: {
1803
- height: p,
1917
+ height: y,
1804
1918
  pointerEvents: "none",
1805
- background: (o ?? y) === "dark" ? "#121c17" : "#f7f8f4"
1919
+ background: (a ?? B) === "dark" ? "#121c17" : "#f7f8f4"
1806
1920
  }
1807
1921
  }
1808
1922
  ),
1809
1923
  document.body
1810
1924
  ),
1811
- /* @__PURE__ */ C(
1812
- dt,
1925
+ /* @__PURE__ */ T(
1926
+ mt,
1813
1927
  {
1814
- layout: I ? pt : D.layout,
1815
- viewport: g,
1816
- onHeightChange: S
1928
+ layout: V ? yt : J.layout,
1929
+ viewport: x,
1930
+ onHeightChange: A
1817
1931
  },
1818
- L
1932
+ m
1819
1933
  )
1820
1934
  ] })
1821
1935
  ]
@@ -1823,6 +1937,6 @@ function Et({
1823
1937
  );
1824
1938
  }
1825
1939
  export {
1826
- kt as VirtualInput,
1827
- Et as VirtualInputProvider
1940
+ Mt as VirtualInput,
1941
+ Tt as VirtualInputProvider
1828
1942
  };