@rpcbase/ui 0.207.0 → 0.208.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.
Files changed (232) hide show
  1. package/dist/index.js +7 -7
  2. package/dist/index19.js +1 -1
  3. package/dist/index19.js.map +1 -1
  4. package/dist/index200.js +56 -55
  5. package/dist/index200.js.map +1 -1
  6. package/dist/index201.js +60 -8
  7. package/dist/index201.js.map +1 -1
  8. package/dist/index202.js +7 -15
  9. package/dist/index202.js.map +1 -1
  10. package/dist/index203.js +15 -143
  11. package/dist/index203.js.map +1 -1
  12. package/dist/index204.js +145 -4
  13. package/dist/index204.js.map +1 -1
  14. package/dist/index205.js +4 -11
  15. package/dist/index205.js.map +1 -1
  16. package/dist/index206.js +10 -104
  17. package/dist/index206.js.map +1 -1
  18. package/dist/index207.js +94 -347
  19. package/dist/index207.js.map +1 -1
  20. package/dist/index208.js +349 -87
  21. package/dist/index208.js.map +1 -1
  22. package/dist/index209.js +73 -304
  23. package/dist/index209.js.map +1 -1
  24. package/dist/index210.js +309 -193
  25. package/dist/index210.js.map +1 -1
  26. package/dist/index211.js +211 -19
  27. package/dist/index211.js.map +1 -1
  28. package/dist/index212.js +18 -27
  29. package/dist/index212.js.map +1 -1
  30. package/dist/index213.js +27 -187
  31. package/dist/index213.js.map +1 -1
  32. package/dist/index214.js +186 -16
  33. package/dist/index214.js.map +1 -1
  34. package/dist/index215.js +18 -44
  35. package/dist/index215.js.map +1 -1
  36. package/dist/index216.js +60 -8
  37. package/dist/index216.js.map +1 -1
  38. package/dist/index217.js +42 -23
  39. package/dist/index217.js.map +1 -1
  40. package/dist/index218.js +9 -44
  41. package/dist/index218.js.map +1 -1
  42. package/dist/index219.js +25 -18
  43. package/dist/index219.js.map +1 -1
  44. package/dist/index220.js +45 -3
  45. package/dist/index220.js.map +1 -1
  46. package/dist/index221.js +17 -4
  47. package/dist/index221.js.map +1 -1
  48. package/dist/index222.js +3 -21
  49. package/dist/index222.js.map +1 -1
  50. package/dist/index223.js +4 -24
  51. package/dist/index223.js.map +1 -1
  52. package/dist/index224.js +17 -64
  53. package/dist/index224.js.map +1 -1
  54. package/dist/index225.js +23 -13
  55. package/dist/index225.js.map +1 -1
  56. package/dist/index226.js +68 -4
  57. package/dist/index226.js.map +1 -1
  58. package/dist/index227.js +14 -50
  59. package/dist/index227.js.map +1 -1
  60. package/dist/index228.js +4 -6
  61. package/dist/index228.js.map +1 -1
  62. package/dist/index229.js +50 -26
  63. package/dist/index229.js.map +1 -1
  64. package/dist/index230.js +5 -13
  65. package/dist/index230.js.map +1 -1
  66. package/dist/index231.js +25 -8
  67. package/dist/index231.js.map +1 -1
  68. package/dist/index232.js +17 -3
  69. package/dist/index232.js.map +1 -0
  70. package/dist/index233.js +8 -24
  71. package/dist/index233.js.map +1 -1
  72. package/dist/index234.js +2 -71
  73. package/dist/index235.js +29 -3
  74. package/dist/index235.js.map +1 -0
  75. package/dist/index236.js +69 -12
  76. package/dist/index236.js.map +1 -1
  77. package/dist/index237.js +3 -54
  78. package/dist/index238.js +11 -114
  79. package/dist/index238.js.map +1 -1
  80. package/dist/index239.js +51 -6
  81. package/dist/index239.js.map +1 -1
  82. package/dist/index240.js +115 -13
  83. package/dist/index240.js.map +1 -1
  84. package/dist/index241.js +6 -687
  85. package/dist/index241.js.map +1 -1
  86. package/dist/index242.js +13 -253
  87. package/dist/index242.js.map +1 -1
  88. package/dist/index243.js +662 -676
  89. package/dist/index243.js.map +1 -1
  90. package/dist/index244.js +252 -7430
  91. package/dist/index244.js.map +1 -1
  92. package/dist/index245.js +700 -6
  93. package/dist/index245.js.map +1 -1
  94. package/dist/index246.js +7429 -11
  95. package/dist/index246.js.map +1 -1
  96. package/dist/index247.js +5 -4
  97. package/dist/index247.js.map +1 -1
  98. package/dist/index248.js +11 -458
  99. package/dist/index248.js.map +1 -1
  100. package/dist/index249.js +5 -37
  101. package/dist/index249.js.map +1 -1
  102. package/dist/index250.js +458 -18
  103. package/dist/index250.js.map +1 -1
  104. package/dist/index251.js +34 -24
  105. package/dist/index251.js.map +1 -1
  106. package/dist/index252.js +19 -4
  107. package/dist/index252.js.map +1 -1
  108. package/dist/index253.js +23 -54
  109. package/dist/index253.js.map +1 -1
  110. package/dist/index254.js +4 -7
  111. package/dist/index254.js.map +1 -1
  112. package/dist/index255.js +57 -11
  113. package/dist/index255.js.map +1 -1
  114. package/dist/index256.js +8 -3
  115. package/dist/index256.js.map +1 -1
  116. package/dist/index257.js +12 -16
  117. package/dist/index257.js.map +1 -1
  118. package/dist/index258.js +3 -26
  119. package/dist/index258.js.map +1 -1
  120. package/dist/index259.js +15 -42
  121. package/dist/index259.js.map +1 -1
  122. package/dist/index260.js +25 -13
  123. package/dist/index260.js.map +1 -1
  124. package/dist/index261.js +40 -22
  125. package/dist/index261.js.map +1 -1
  126. package/dist/index262.js +13 -17
  127. package/dist/index262.js.map +1 -1
  128. package/dist/index263.js +24 -34
  129. package/dist/index263.js.map +1 -1
  130. package/dist/index264.js +17 -5
  131. package/dist/index264.js.map +1 -1
  132. package/dist/index265.js +35 -9
  133. package/dist/index265.js.map +1 -1
  134. package/dist/index266.js +5 -8
  135. package/dist/index266.js.map +1 -1
  136. package/dist/index267.js +9 -9
  137. package/dist/index267.js.map +1 -1
  138. package/dist/index268.js +8 -10
  139. package/dist/index268.js.map +1 -1
  140. package/dist/index269.js +9 -7
  141. package/dist/index269.js.map +1 -1
  142. package/dist/index270.js +9 -72
  143. package/dist/index270.js.map +1 -1
  144. package/dist/index271.js +7 -171
  145. package/dist/index271.js.map +1 -1
  146. package/dist/index272.js +63 -104
  147. package/dist/index272.js.map +1 -1
  148. package/dist/index273.js +169 -12
  149. package/dist/index273.js.map +1 -1
  150. package/dist/index274.js +109 -75
  151. package/dist/index274.js.map +1 -1
  152. package/dist/index275.js +12 -44
  153. package/dist/index275.js.map +1 -1
  154. package/dist/index276.js +79 -12
  155. package/dist/index276.js.map +1 -1
  156. package/dist/index277.js +45 -15
  157. package/dist/index277.js.map +1 -1
  158. package/dist/index278.js +12 -98
  159. package/dist/index278.js.map +1 -1
  160. package/dist/index279.js +15 -55
  161. package/dist/index279.js.map +1 -1
  162. package/dist/index280.js +89 -98
  163. package/dist/index280.js.map +1 -1
  164. package/dist/index281.js +27 -42
  165. package/dist/index281.js.map +1 -1
  166. package/dist/index282.js +92 -97
  167. package/dist/index282.js.map +1 -1
  168. package/dist/index283.js +62 -46
  169. package/dist/index283.js.map +1 -1
  170. package/dist/index284.js +108 -38
  171. package/dist/index284.js.map +1 -1
  172. package/dist/index285.js +48 -135
  173. package/dist/index285.js.map +1 -1
  174. package/dist/index286.js +43 -139
  175. package/dist/index286.js.map +1 -1
  176. package/dist/index287.js +105 -217
  177. package/dist/index287.js.map +1 -1
  178. package/dist/index288.js +109 -210
  179. package/dist/index288.js.map +1 -1
  180. package/dist/index289.js +168 -212
  181. package/dist/index289.js.map +1 -1
  182. package/dist/index290.js +240 -5
  183. package/dist/index290.js.map +1 -1
  184. package/dist/index291.js +298 -6
  185. package/dist/index291.js.map +1 -1
  186. package/dist/index292.js +5 -7
  187. package/dist/index292.js.map +1 -1
  188. package/dist/index293.js +4 -4
  189. package/dist/index293.js.map +1 -1
  190. package/dist/index294.js +7 -6
  191. package/dist/index294.js.map +1 -1
  192. package/dist/index295.js +6 -21
  193. package/dist/index295.js.map +1 -1
  194. package/dist/index296.js +6 -10
  195. package/dist/index296.js.map +1 -1
  196. package/dist/index297.js +18 -123
  197. package/dist/index297.js.map +1 -1
  198. package/dist/index298.js +10 -164
  199. package/dist/index298.js.map +1 -1
  200. package/dist/index299.js +116 -58
  201. package/dist/index299.js.map +1 -1
  202. package/dist/index300.js +161 -106
  203. package/dist/index300.js.map +1 -1
  204. package/dist/index301.js +66 -489
  205. package/dist/index301.js.map +1 -1
  206. package/dist/index302.js +106 -59
  207. package/dist/index302.js.map +1 -1
  208. package/dist/index303.js +492 -4
  209. package/dist/index303.js.map +1 -1
  210. package/dist/index304.js +62 -27
  211. package/dist/index304.js.map +1 -1
  212. package/dist/index305.js +4 -66
  213. package/dist/index305.js.map +1 -1
  214. package/dist/index306.js +27 -152
  215. package/dist/index306.js.map +1 -1
  216. package/dist/index307.js +59 -555
  217. package/dist/index307.js.map +1 -1
  218. package/dist/index308.js +143 -201
  219. package/dist/index308.js.map +1 -1
  220. package/dist/index309.js +56 -326
  221. package/dist/index309.js.map +1 -1
  222. package/dist/index310.js +553 -260
  223. package/dist/index310.js.map +1 -1
  224. package/dist/index311.js +214 -0
  225. package/dist/index311.js.map +1 -0
  226. package/dist/index312.js +335 -0
  227. package/dist/index312.js.map +1 -0
  228. package/dist/index313.js +272 -0
  229. package/dist/index313.js.map +1 -0
  230. package/package.json +2 -2
  231. package/dist/index234.js.map +0 -1
  232. package/dist/index237.js.map +0 -1
package/dist/index301.js CHANGED
@@ -1,495 +1,72 @@
1
- import { cn as e } from "./index12.js";
2
- import { getCountryCallingCode as t } from "./index294.js";
3
- import { resolveMessages as n } from "./index295.js";
4
- import { COMMON_IDD_PREFIXES as r, buildFallbackSelectedCountry as i, getCachedCountryOptions as a, getLocaleCacheKey as o, getValidCountry as s, normalizeSearchValue as c, optionMatchIndex as l, parseLocaleCacheKey as u, toSelectedCountry as d } from "./index297.js";
5
- import { detectNationalPrefixForDisplay as f, formatWithAsYouType as ee, getLengthIssue as te, getSuggestionState as ne, injectNationalPrefixDisplay as re, normalizeInputValue as p, sanitizeDigits as m, shouldDisplayExplicitCountrySelection as ie, stripPrefix as h } from "./index298.js";
6
- import { captureSelectionSnapshot as g, resolveSelection as _, skipFormattingCharactersLeft as v, skipFormattingCharactersRight as y } from "./index299.js";
7
- import { HiddenControl as b, NullComponent as x, SuggestionContext as ae, SuggestionOption as oe, formatCountryOption as se, suggestionSelectStyles as ce } from "./index300.js";
8
- import * as S from "react";
9
- import { jsx as C, jsxs as w } from "react/jsx-runtime";
10
- import T from "react-select";
11
- //#region src/components/PhoneNumberInput/index.tsx
12
- var le = S.forwardRef(function(le, ue) {
13
- let { value: E, defaultCountry: D, country: O, locale: de, onChange: fe, onCountryChange: pe, className: me, inputClassName: he, disabled: ge, readOnly: _e, selectProps: ve, autofillShimName: ye, messages: be, renderValidationMessage: xe, ...Se } = le, { onFocus: Ce, onBlur: we, onKeyDown: Te, name: Ee, autoComplete: De, ...Oe } = Se, k = typeof D == "string" || typeof O == "string", ke = o(de), Ae = S.useMemo(() => u(ke), [ke]), je = S.useMemo(() => n(Ae, be), [Ae, be]), A = S.useMemo(() => a(Ae, ke), [ke, Ae]), Me = S.useCallback((e) => {
14
- let t = A.find((t) => t.value === e);
15
- return t ? d(t) : i(e);
16
- }, [A]), j = S.useMemo(() => {
17
- let e = s(D ?? O ?? "US");
18
- return A.some((t) => t.value === e) ? e : A[0]?.value ?? "US";
19
- }, [
20
- A,
21
- O,
22
- D
23
- ]), M = S.useRef(k), Ne = S.useRef(null), N = S.useRef("");
24
- if (!Ne.current) if (!E) Ne.current = {
25
- country: j,
26
- inputValue: "",
27
- normalizedValue: "",
28
- hasExplicitCountrySelection: !1
29
- }, N.current = "";
30
- else {
31
- let e = k ? j : void 0, n = p(E, e, { allowJustPlus: !0 });
32
- if (!n) Ne.current = {
33
- country: j,
34
- inputValue: "",
35
- normalizedValue: "",
36
- hasExplicitCountrySelection: !1
37
- }, N.current = "";
38
- else {
39
- let { international: r, phoneNumber: i, detectedCountry: a, inferredCountry: o, hasExplicitInternationalPrefix: s } = ee(n, e), c = a ?? void 0, l = c ?? j, u = m(E ?? ""), d = typeof E == "string" ? /^\s*\+/.test(E) : !1, te = m(r), p = f(u, te, t(l), d), h = ne(n, e, i ?? void 0, {
40
- hasRemovedNationalPrefix: p,
41
- detectedCountry: c,
42
- hasExplicitInternationalPrefix: s
43
- }), g = !h.shouldSuggest && !c ? o : void 0;
44
- g && (l = g), (c || g) && (M.current = !0);
45
- let _ = t(l), v = re(r, _, { force: g ? f(u, te, _, d) : p }), y = c ?? void 0, b = M.current;
46
- Ne.current = {
47
- country: l,
48
- inputValue: v,
49
- normalizedValue: n,
50
- hasExplicitCountrySelection: b && ie(h, {
51
- detectedCountry: y,
52
- hasExplicitInternationalPrefix: s
53
- })
54
- }, N.current = n;
1
+ //#region src/components/PhoneNumberInput/selection.ts
2
+ function e(e) {
3
+ if (!e) return !1;
4
+ let t = e.charCodeAt(0);
5
+ return t >= 48 && t <= 57;
6
+ }
7
+ function t(t, n) {
8
+ let r = 0, i = Math.min(n, t.length);
9
+ for (let n = 0; n < i; n += 1) e(t[n] ?? "") && (r += 1);
10
+ return r;
11
+ }
12
+ function n(t, n) {
13
+ if (n <= 0) return t.startsWith("+") ? Math.min(1, t.length) : 0;
14
+ let r = 0;
15
+ for (let i = 0; i < t.length; i += 1) if (e(t[i] ?? "") && (r += 1, r === n)) return i + 1;
16
+ return t.length;
17
+ }
18
+ function r(t) {
19
+ return !t || e(t) ? !1 : t !== "+";
20
+ }
21
+ function i(e, t) {
22
+ let n = t;
23
+ for (; n > 0 && r(e[n - 1] ?? "");) --n;
24
+ return n;
25
+ }
26
+ function a(e, t) {
27
+ let n = t;
28
+ for (; n < e.length && r(e[n] ?? "");) n += 1;
29
+ return n;
30
+ }
31
+ function o(e) {
32
+ let { value: n } = e, r = e.selectionStart ?? n.length, i = e.selectionEnd ?? r, a = r <= 1 && n.startsWith("+"), o = i <= 1 && n.startsWith("+");
33
+ return {
34
+ selectionStart: r,
35
+ selectionEnd: i,
36
+ startDigits: t(n, r),
37
+ endDigits: t(n, i),
38
+ preserveStartIndex: a,
39
+ preserveEndIndex: o,
40
+ wasAtStart: r === 0,
41
+ wasAtEnd: i === n.length
42
+ };
43
+ }
44
+ function s(e, t) {
45
+ if (e.selectionStart === e.selectionEnd) {
46
+ if (e.wasAtEnd) {
47
+ let e = t.length;
48
+ return {
49
+ start: e,
50
+ end: e
51
+ };
55
52
  }
56
- }
57
- let Pe = Ne.current, [P, F] = S.useState(Pe.country), [Fe, I] = S.useState(Pe.inputValue), [Ie, L] = S.useState(""), [R, z] = S.useState(!1), [Le, B] = S.useState(-1), [Re, ze] = S.useState(!1), [Be, V] = S.useState(null), [Ve, H] = S.useState(Pe.hasExplicitCountrySelection), U = S.useRef(null), W = S.useRef(""), G = S.useRef(null), K = S.useRef("smooth"), q = S.useRef(null), He = S.useCallback(() => {
58
- let e = K.current;
59
- return K.current = "smooth", e;
60
- }, []), J = typeof O == "string", Ue = J ? O : P, Y = Ue ?? j, We = S.useRef(null);
61
- S.useImperativeHandle(ue, () => We.current, []), S.useLayoutEffect(() => {
62
- let e = q.current;
63
- if (!e) return;
64
- let t = We.current;
65
- if (q.current = null, !t) return;
66
- let { start: n, end: r } = e;
67
- t.setSelectionRange(n, r);
68
- }, [Fe]);
69
- let { styles: Ge, components: Ke, classNamePrefix: qe, formatOptionLabel: Je, ...Ye } = ve ?? {}, { noOptionsMessage: Xe, ...Ze } = Ye, Qe = S.useMemo(() => ({
70
- ...ce,
71
- ...Ge ?? {}
72
- }), [Ge]), $e = S.useMemo(() => {
73
- let e = {
74
- Control: b,
75
- IndicatorsContainer: x,
76
- DropdownIndicator: x,
77
- IndicatorSeparator: x,
78
- ValueContainer: x
79
- }, t = Ke ?? {};
80
- return t.Option ? {
81
- ...e,
82
- ...t
83
- } : {
84
- ...e,
85
- ...t,
86
- Option: oe
53
+ if (e.wasAtStart) return {
54
+ start: 0,
55
+ end: 0
87
56
  };
88
- }, [Ke]), et = S.useRef(!1), X = S.useCallback((e) => {
89
- et.current = !0;
90
- let t = Me(e);
91
- return pe?.(e, t), t;
92
- }, [pe, Me]);
93
- S.useEffect(() => () => {
94
- G.current != null && typeof window < "u" && window.clearTimeout(G.current);
95
- }, []), S.useEffect(() => {
96
- if (E == null) return;
97
- let e = M.current ? Y : void 0, n = N.current, r = p(E, e, {
98
- allowJustPlus: !0,
99
- previousValue: n
100
- });
101
- if (N.current = r, W.current = "", !r) {
102
- I(""), z(!1), L(""), V(null), U.current = null, H(!1);
103
- let e = k ? j : Y;
104
- !J && P !== e && (F(e), X(e));
105
- return;
106
- }
107
- if (r === "0") {
108
- I("0"), z(!1), L(""), V(null), U.current = null, H(!1);
109
- return;
110
- }
111
- if (r === "+") {
112
- I("+"), z(!0), L(""), V(null), U.current = null, H(!1);
113
- let e = k ? j : Y;
114
- !J && P !== e && (F(e), X(e));
115
- return;
116
- }
117
- let { international: i, phoneNumber: a, detectedCountry: o, inferredCountry: s, hasExplicitInternationalPrefix: c } = ee(r, e), l = o ?? void 0, u = l ?? e ?? Y, d = m(E ?? ""), h = typeof E == "string" ? /^\s*\+/.test(E) : !1, g = m(i), _ = f(d, g, t(u), h), v = ne(r, e, a ?? void 0, {
118
- hasRemovedNationalPrefix: _,
119
- detectedCountry: l,
120
- hasExplicitInternationalPrefix: c
121
- }), y = !v.shouldSuggest && !l ? s : void 0, b = y ?? u;
122
- (l || y) && (M.current = !0), !J && b !== P && (F(b), X(b)), u = b, U.current && U.current !== u && (U.current = null);
123
- let x = t(u), ae = re(i, x, { force: y ? f(d, g, x, h) : _ }), oe = l ?? void 0, se = U.current != null || ie(v, {
124
- detectedCountry: oe,
125
- hasExplicitInternationalPrefix: c
126
- });
127
- I(ae), z(v.shouldSuggest), L(v.query), V(M.current ? te(r, u) : null), H(M.current && se);
128
- }, [
129
- E,
130
- Y,
131
- j,
132
- k,
133
- J,
134
- X,
135
- P
136
- ]), S.useEffect(() => {
137
- if (et.current || !M.current) return;
138
- let e = Ue ?? j;
139
- e && X(e);
140
- }, [
141
- j,
142
- X,
143
- Ue
144
- ]), S.useEffect(() => {
145
- J && O && O !== P && F(O);
146
- }, [
147
- O,
148
- J,
149
- P
150
- ]);
151
- let Z = S.useCallback((e) => {
152
- let t = Me(e.country);
153
- fe?.({
154
- ...e,
155
- selectedCountry: t
156
- });
157
- }, [fe, Me]), tt = S.useCallback(() => {
158
- typeof window > "u" || (G.current != null && window.clearTimeout(G.current), G.current = window.setTimeout(() => {
159
- W.current = "", G.current = null;
160
- }, 800));
161
- }, []), nt = S.useCallback((e) => {
162
- let n = e.target, i = g(n), a = n.value;
163
- W.current = "";
164
- let o = M.current ? Y : void 0, s = o ? t(o) : "", c = m(a), l = a.trim().startsWith("+"), u = s ? c.startsWith(s) : !1, d = c.startsWith("0"), v = r.some((e) => c.startsWith(e)), y = !!o && !v && (u && c.slice(s.length).startsWith("0") || !l && d && c.length > 1 || l && d && c.length > 1 && !u), b = N.current, x = p(a, o, {
165
- allowJustPlus: !0,
166
- removeNationalPrefix: y,
167
- previousValue: b
168
- });
169
- if (N.current = x, !x) {
170
- I(""), z(!1), L(""), B(-1), V(null), U.current = null, H(!1), q.current = _(i, "");
171
- let e = k ? j : Y;
172
- !J && P !== e && (F(e), X(e)), Z({
173
- formattedInternational: "",
174
- formattedNational: "",
175
- e164: null,
176
- country: e,
177
- countryCallingCode: t(e),
178
- nationalNumber: "",
179
- rawInput: "",
180
- isValid: !1
181
- });
182
- return;
183
- }
184
- if (x === "0") {
185
- I("0"), z(!1), L(""), B(-1), V(null), U.current = null, H(!1), q.current = _(i, "0");
186
- let e = k ? j : Y;
187
- !J && P !== e && (F(e), X(e)), Z({
188
- formattedInternational: "0",
189
- formattedNational: "0",
190
- e164: null,
191
- country: e,
192
- countryCallingCode: t(e),
193
- nationalNumber: "0",
194
- rawInput: "0",
195
- isValid: !1
196
- });
197
- return;
198
- }
199
- if (x === "+") {
200
- I("+"), z(!0), L(""), B(0), V(null), U.current = null, H(!1), q.current = _(i, "+");
201
- let e = k ? j : Y;
202
- !J && P !== e && (F(e), X(e)), Z({
203
- formattedInternational: "+",
204
- formattedNational: "",
205
- e164: null,
206
- country: e,
207
- countryCallingCode: t(e),
208
- nationalNumber: "",
209
- rawInput: "+",
210
- isValid: !1
211
- });
212
- return;
213
- }
214
- let { international: ae, national: oe, phoneNumber: se, detectedCountry: ce, inferredCountry: S, hasExplicitInternationalPrefix: C } = ee(x, o), w = ce ?? void 0, T = w ?? o ?? Y, le = m(ae), ue = f(c, le, t(T), l), E = ne(x, o, se ?? void 0, {
215
- hasRemovedNationalPrefix: ue,
216
- detectedCountry: w,
217
- hasExplicitInternationalPrefix: C
218
- }), D = !E.shouldSuggest && !w ? S : void 0, O = D ?? T;
219
- (w || D) && (M.current = !0), !J && O !== P && (F(O), X(O)), T = O, U.current && U.current !== T && (U.current = null);
220
- let de = t(T), fe = h(m(x), de), pe = re(ae, de, { force: D ? f(c, le, de, l) : ue }), me = w ?? void 0;
221
- q.current = _(i, pe), I(pe), z(E.shouldSuggest), L(E.query), B(E.shouldSuggest ? 0 : -1), V(M.current ? te(x, T) : null);
222
- let he = U.current != null || ie(E, {
223
- detectedCountry: me,
224
- hasExplicitInternationalPrefix: C
225
- });
226
- H(M.current && he), Z({
227
- formattedInternational: ae,
228
- formattedNational: oe,
229
- e164: se?.number ?? null,
230
- country: T,
231
- countryCallingCode: de,
232
- nationalNumber: fe,
233
- rawInput: x,
234
- isValid: se?.isValid() ?? !1
235
- });
236
- }, [
237
- Y,
238
- Z,
239
- j,
240
- k,
241
- J,
242
- X,
243
- P
244
- ]), rt = S.useCallback((e) => {
245
- if (!e) return;
246
- let n = m(N.current || Fe), r = t(Y), i = n.startsWith(r) ? n.slice(r.length) : n;
247
- i ? i.startsWith(e.dialCode) || (i = `${e.dialCode}${i}`) : i = e.dialCode;
248
- let a = `+${i}`;
249
- N.current = a;
250
- let { international: o, national: s, phoneNumber: c } = ee(a, e.value), l = e.value;
251
- U.current = l, M.current = !0, I(o), q.current = {
252
- start: o.length,
253
- end: o.length
254
- }, z(!1), L(""), B(-1), V(te(a, l)), !J && l !== P && F(l), X(l);
255
- let u = m(a), d = c?.countryCallingCode ?? e.dialCode, f = h(u, d);
256
- H(!0), Z({
257
- formattedInternational: o,
258
- formattedNational: s,
259
- e164: c?.number ?? null,
260
- country: l,
261
- countryCallingCode: d,
262
- nationalNumber: f,
263
- rawInput: a,
264
- isValid: c?.isValid() ?? !1
265
- }), requestAnimationFrame(() => {
266
- We.current?.focus();
267
- });
268
- }, [
269
- Y,
270
- Z,
271
- Fe,
272
- J,
273
- X,
274
- P
275
- ]), Q = S.useMemo(() => {
276
- if (!R) return [];
277
- let e = [], t = (t) => {
278
- e.some((e) => e.value === t.value) || e.push(t);
279
- }, n = A.find((e) => e.value === j), r = A.find((e) => e.value === Y), i = Ie.trim(), a = m(i), o = c(i);
280
- return !a && !o ? (n && t(n), r && t(r), A.forEach(t), e) : (a && A.filter((e) => e.dialCode.startsWith(a)).sort((e, t) => {
281
- let n = e.dialCode === a, r = t.dialCode === a;
282
- return n && !r ? -1 : !n && r ? 1 : e.dialCode.length - t.dialCode.length;
283
- }).forEach(t), o && A.filter((e) => e.normalizedSearchableTokens.some((e) => e.includes(o))).sort((e, t) => {
284
- let n = l(e.normalizedSearchableTokens, o), r = l(t.normalizedSearchableTokens, o);
285
- return n === r ? e.name.localeCompare(t.name) : n - r;
286
- }).forEach(t), r && t(r), n && t(n), e.length === 0 && A.forEach(t), e);
287
- }, [
288
- Y,
289
- A,
290
- Ie,
291
- j,
292
- R
293
- ]), $ = Re && R && Q.length > 0;
294
- S.useEffect(() => {
295
- $ || (K.current = "smooth");
296
- }, [$]), S.useEffect(() => {
297
- if (!$) {
298
- B(-1);
299
- return;
300
- }
301
- if (Q.length === 0) {
302
- B(-1);
303
- return;
304
- }
305
- B((e) => e < 0 || e >= Q.length ? 0 : e);
306
- }, [Q, $]);
307
- let it = Le >= 0 ? Q[Le] ?? null : null;
308
- S.useEffect(() => {
309
- Le < 0 && (K.current = "smooth");
310
- }, [Le]);
311
- let at = S.useCallback((e) => {
312
- let t = Q.findIndex((t) => t.value === e.value);
313
- t !== -1 && B(t);
314
- }, [Q]), ot = S.useCallback((e, t) => Je ? Je(e, t) : se(e), [Je]), st = S.useCallback((e) => ot(e, {
315
- context: "menu",
316
- inputValue: Ie,
317
- selectValue: []
318
- }), [Ie, ot]), ct = S.useMemo(() => ({
319
- highlightedValue: it?.value ?? null,
320
- setHighlightedOption: at,
321
- renderOptionLabel: st,
322
- consumeScrollBehavior: He
323
- }), [
324
- He,
325
- it,
326
- st,
327
- at
328
- ]), lt = A.find((e) => e.value === Y), ut = lt?.flag ?? "", dt = Ve ? je.selectedCountryLabel(lt?.name ?? Y ?? null) : je.selectCountryLabel, ft = Ve && !!ut, pt = Be === "TOO_LONG" ? je.lengthTooLong(lt?.name ?? Y ?? null) : null, mt = lt?.name ?? Y ?? null, ht = null;
329
- if (pt) {
330
- let e = xe?.({
331
- message: pt,
332
- code: "TOO_LONG",
333
- countryName: mt
334
- });
335
- ht = e === void 0 ? /* @__PURE__ */ C("p", {
336
- className: "mt-1 text-xs text-destructive",
337
- children: /* @__PURE__ */ C("span", { children: pt })
338
- }) : e;
339
57
  }
340
- let gt = S.useCallback((e) => {
341
- W.current = `${W.current}${e}`.slice(-12), L(W.current), z(!0), tt();
342
- }, [tt]), _t = S.useCallback(() => {
343
- let e = W.current;
344
- e && (W.current = e.slice(0, -1), L(W.current), W.current && tt());
345
- }, [tt]), vt = S.useCallback((e) => {
346
- if (Te?.(e), e.defaultPrevented) return;
347
- let t = e.key;
348
- if (e.metaKey || e.ctrlKey || e.altKey) return;
349
- let n = e.currentTarget, r = n.value, i = n.selectionStart ?? 0, a = n.selectionEnd ?? i, o = i === a;
350
- if (t === "Backspace" && o) {
351
- let e = v(r, i);
352
- e !== i && n.setSelectionRange(e, e);
353
- } else if (t === "ArrowLeft" && o) {
354
- let t = v(r, i);
355
- if (t !== i) {
356
- e.preventDefault(), n.setSelectionRange(t, t);
357
- return;
358
- }
359
- } else if (t === "ArrowRight" && o) {
360
- let t = y(r, a);
361
- if (t !== a) {
362
- e.preventDefault(), n.setSelectionRange(t, t);
363
- return;
364
- }
365
- }
366
- if (t === "ArrowDown") {
367
- if (K.current = e.repeat ? "auto" : "smooth", e.preventDefault(), !R) {
368
- z(!0), B(Q.length > 0 ? 0 : -1);
369
- return;
370
- }
371
- Q.length > 0 && B((e) => e < 0 ? 0 : (e + 1) % Q.length);
372
- return;
373
- }
374
- if (t === "ArrowUp") {
375
- if (K.current = e.repeat ? "auto" : "smooth", e.preventDefault(), !R) {
376
- z(!0), B(Q.length > 0 ? Q.length - 1 : -1);
377
- return;
378
- }
379
- Q.length > 0 && B((e) => e < 0 ? Q.length - 1 : (e - 1 + Q.length) % Q.length);
380
- return;
381
- }
382
- if (/^[a-z]$/i.test(t)) {
383
- e.preventDefault(), R || (z(!0), B(Q.length > 0 ? 0 : -1)), gt(t.toLowerCase());
384
- return;
385
- }
386
- if ($) {
387
- if (t === "Backspace" && W.current) {
388
- e.preventDefault(), _t();
389
- return;
390
- }
391
- if (t === "Escape") {
392
- e.preventDefault(), W.current = "", L(""), z(!1);
393
- return;
394
- }
395
- if (t === "Enter" && Q.length > 0) {
396
- e.preventDefault(), rt(it ?? Q[0]);
397
- return;
398
- }
399
- }
400
- }, [
401
- gt,
402
- Q,
403
- rt,
404
- it,
405
- Te,
406
- _t,
407
- R,
408
- $
409
- ]), yt = S.useCallback((e) => {
410
- ze(!0), Ce?.(e);
411
- }, [Ce]), bt = S.useCallback((e) => {
412
- ze(!1), z(!1), W.current = "", L(""), we?.(e);
413
- }, [we]), xt = S.useCallback(() => {
414
- ge || _e || (W.current = "", L(""), z(!0), B((e) => e < 0 ? 0 : e), requestAnimationFrame(() => {
415
- We.current?.focus();
416
- }));
417
- }, [ge, _e]), St = ye ?? (Ee ? `${Ee}_shim` : void 0);
418
- return /* @__PURE__ */ w("div", {
419
- className: e("relative flex flex-col", me),
420
- children: [
421
- /* @__PURE__ */ w("div", {
422
- className: "relative",
423
- children: [/* @__PURE__ */ C("input", {
424
- ...Oe,
425
- ref: We,
426
- type: "tel",
427
- className: e("flex h-10 w-full rounded-md border border-input bg-background py-2 text-base ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "pl-11 pr-3", he),
428
- name: Ee,
429
- value: Fe,
430
- onChange: nt,
431
- onFocus: yt,
432
- onBlur: bt,
433
- onKeyDown: vt,
434
- disabled: ge,
435
- readOnly: _e,
436
- autoComplete: De ?? "off"
437
- }), /* @__PURE__ */ C("button", {
438
- type: "button",
439
- className: e("absolute left-3 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded border text-lg leading-none transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", ft ? "border-transparent" : "border-dashed border-border text-muted-foreground", ge ? "cursor-not-allowed opacity-50" : _e ? "cursor-default" : "cursor-pointer hover:bg-muted"),
440
- "aria-label": dt,
441
- onMouseDown: (e) => e.preventDefault(),
442
- onClick: xt,
443
- tabIndex: -1,
444
- disabled: ge,
445
- children: /* @__PURE__ */ C("span", {
446
- "aria-hidden": "true",
447
- children: ft ? ut : "?"
448
- })
449
- })]
450
- }),
451
- St ? /* @__PURE__ */ C("input", {
452
- tabIndex: -1,
453
- autoComplete: "tel",
454
- name: St,
455
- "aria-hidden": "true",
456
- className: "pointer-events-none absolute left-0 top-0 h-0 w-0 opacity-0"
457
- }) : null,
458
- /* @__PURE__ */ C("div", {
459
- className: "absolute left-0 top-full z-30 mt-1",
460
- style: {
461
- pointerEvents: $ ? "auto" : "none",
462
- width: "min(260px, 100%)"
463
- },
464
- onMouseDown: (e) => e.preventDefault(),
465
- children: /* @__PURE__ */ C(ae.Provider, {
466
- value: ct,
467
- children: /* @__PURE__ */ C(T, {
468
- ...Ze,
469
- menuIsOpen: $,
470
- options: Q,
471
- value: null,
472
- components: $e,
473
- styles: Qe,
474
- isClearable: !1,
475
- isSearchable: !1,
476
- backspaceRemovesValue: !1,
477
- tabSelectsValue: !1,
478
- menuShouldScrollIntoView: !1,
479
- onChange: rt,
480
- classNamePrefix: qe ?? "phone-number-suggestions",
481
- placeholder: "",
482
- formatOptionLabel: ot,
483
- noOptionsMessage: Xe ?? (() => je.noMatches)
484
- })
485
- })
486
- }),
487
- ht
488
- ]
489
- });
490
- });
491
- le.displayName = "PhoneNumberInput";
58
+ let r = e.preserveStartIndex ? Math.min(e.selectionStart, t.length) : n(t, e.startDigits), i = e.preserveEndIndex ? Math.min(e.selectionEnd, t.length) : n(t, e.endDigits), a = r, o = i;
59
+ e.wasAtStart && (a = 0), e.wasAtEnd && (o = t.length), e.selectionStart === e.selectionEnd && (a = o);
60
+ let s = Math.min(Math.max(a, 0), t.length), c = Math.min(Math.max(o, 0), t.length);
61
+ return s > c ? {
62
+ start: c,
63
+ end: c
64
+ } : {
65
+ start: s,
66
+ end: c
67
+ };
68
+ }
492
69
  //#endregion
493
- export { le as PhoneNumberInput };
70
+ export { o as captureSelectionSnapshot, s as resolveSelection, i as skipFormattingCharactersLeft, a as skipFormattingCharactersRight };
494
71
 
495
72
  //# sourceMappingURL=index301.js.map