mainstack-design-system 1.23.1 → 1.23.2

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 (153) hide show
  1. package/dist/mainstack-design-system.cjs +1 -1
  2. package/dist/mainstack-design-system.js +20 -20
  3. package/dist/mainstack-design-system19.cjs +1 -1
  4. package/dist/mainstack-design-system19.js +1 -1
  5. package/dist/mainstack-design-system20.cjs +1 -1
  6. package/dist/mainstack-design-system20.js +1 -1
  7. package/dist/mainstack-design-system25.cjs +1 -1
  8. package/dist/mainstack-design-system25.js +1 -1
  9. package/dist/mainstack-design-system27.cjs +1 -1
  10. package/dist/mainstack-design-system27.js +7 -7
  11. package/dist/mainstack-design-system28.cjs +1 -1
  12. package/dist/mainstack-design-system28.js +1 -1
  13. package/dist/mainstack-design-system29.cjs +1 -1
  14. package/dist/mainstack-design-system29.js +67 -62
  15. package/dist/mainstack-design-system30.cjs +1 -1
  16. package/dist/mainstack-design-system30.js +5 -69
  17. package/dist/mainstack-design-system31.cjs +1 -1
  18. package/dist/mainstack-design-system31.js +59 -26
  19. package/dist/mainstack-design-system32.cjs +1 -1
  20. package/dist/mainstack-design-system32.js +35 -18
  21. package/dist/mainstack-design-system33.cjs +1 -1
  22. package/dist/mainstack-design-system33.js +19 -18
  23. package/dist/mainstack-design-system34.cjs +1 -1
  24. package/dist/mainstack-design-system34.js +8 -8
  25. package/dist/mainstack-design-system35.cjs +1 -2
  26. package/dist/mainstack-design-system35.js +14 -46
  27. package/dist/mainstack-design-system36.cjs +2 -1
  28. package/dist/mainstack-design-system36.js +47 -36
  29. package/dist/mainstack-design-system37.cjs +1 -1
  30. package/dist/mainstack-design-system37.js +39 -12
  31. package/dist/mainstack-design-system374.cjs +1 -1
  32. package/dist/mainstack-design-system374.js +1 -1
  33. package/dist/mainstack-design-system381.cjs +1 -1
  34. package/dist/mainstack-design-system381.js +1 -1
  35. package/dist/mainstack-design-system384.cjs +1 -1
  36. package/dist/mainstack-design-system384.js +3 -3
  37. package/dist/mainstack-design-system386.cjs +1 -1
  38. package/dist/mainstack-design-system386.js +1 -1
  39. package/dist/mainstack-design-system387.cjs +1 -1
  40. package/dist/mainstack-design-system387.js +1 -1
  41. package/dist/mainstack-design-system389.cjs +1 -1
  42. package/dist/mainstack-design-system389.js +1 -1
  43. package/dist/mainstack-design-system390.cjs +1 -1
  44. package/dist/mainstack-design-system390.js +2 -2
  45. package/dist/mainstack-design-system43.cjs +1 -1
  46. package/dist/mainstack-design-system43.js +1 -1
  47. package/dist/mainstack-design-system45.cjs +1 -1
  48. package/dist/mainstack-design-system45.js +1 -1
  49. package/dist/mainstack-design-system457.cjs +1 -1
  50. package/dist/mainstack-design-system457.js +1 -1
  51. package/dist/mainstack-design-system487.cjs +1 -1
  52. package/dist/mainstack-design-system487.js +1 -1
  53. package/dist/mainstack-design-system523.cjs +1 -1
  54. package/dist/mainstack-design-system523.js +1 -1
  55. package/dist/mainstack-design-system529.cjs +1 -1
  56. package/dist/mainstack-design-system529.js +1 -1
  57. package/dist/mainstack-design-system532.cjs +1 -1
  58. package/dist/mainstack-design-system532.js +2 -2
  59. package/dist/mainstack-design-system540.cjs +1 -1
  60. package/dist/mainstack-design-system540.js +1 -1
  61. package/dist/mainstack-design-system561.cjs +1 -1
  62. package/dist/mainstack-design-system561.js +1 -1
  63. package/dist/mainstack-design-system562.cjs +1 -1
  64. package/dist/mainstack-design-system562.js +1 -1
  65. package/dist/mainstack-design-system564.cjs +1 -1
  66. package/dist/mainstack-design-system564.js +1 -1
  67. package/dist/mainstack-design-system565.cjs +1 -1
  68. package/dist/mainstack-design-system565.js +1 -1
  69. package/dist/mainstack-design-system566.cjs +1 -1
  70. package/dist/mainstack-design-system566.js +1 -1
  71. package/dist/mainstack-design-system568.cjs +1 -1
  72. package/dist/mainstack-design-system568.js +1 -1
  73. package/dist/mainstack-design-system571.cjs +1 -1
  74. package/dist/mainstack-design-system571.js +1 -1
  75. package/dist/mainstack-design-system574.cjs +1 -1
  76. package/dist/mainstack-design-system574.js +1 -1
  77. package/dist/mainstack-design-system575.cjs +1 -1
  78. package/dist/mainstack-design-system575.js +1 -1
  79. package/dist/mainstack-design-system576.cjs +1 -1
  80. package/dist/mainstack-design-system576.js +1 -1
  81. package/dist/mainstack-design-system577.cjs +1 -1
  82. package/dist/mainstack-design-system577.js +1 -1
  83. package/dist/mainstack-design-system578.cjs +1 -1
  84. package/dist/mainstack-design-system578.js +1 -1
  85. package/dist/mainstack-design-system579.cjs +1 -1
  86. package/dist/mainstack-design-system579.js +1 -1
  87. package/dist/mainstack-design-system582.cjs +1 -1
  88. package/dist/mainstack-design-system582.js +1 -1
  89. package/dist/mainstack-design-system593.cjs +1 -1
  90. package/dist/mainstack-design-system593.js +1 -1
  91. package/dist/mainstack-design-system594.cjs +1 -1
  92. package/dist/mainstack-design-system594.js +1 -1
  93. package/dist/mainstack-design-system595.cjs +1 -1
  94. package/dist/mainstack-design-system595.js +1 -1
  95. package/dist/mainstack-design-system596.cjs +1 -1
  96. package/dist/mainstack-design-system596.js +1 -1
  97. package/dist/mainstack-design-system597.cjs +1 -1
  98. package/dist/mainstack-design-system597.js +1 -1
  99. package/dist/mainstack-design-system598.cjs +1 -1
  100. package/dist/mainstack-design-system598.js +2 -2
  101. package/dist/mainstack-design-system6.cjs +1 -1
  102. package/dist/mainstack-design-system6.js +1 -1
  103. package/dist/mainstack-design-system605.cjs +1 -1
  104. package/dist/mainstack-design-system605.js +1 -1
  105. package/dist/mainstack-design-system607.cjs +1 -1
  106. package/dist/mainstack-design-system607.js +1 -1
  107. package/dist/mainstack-design-system621.cjs +1 -1
  108. package/dist/mainstack-design-system621.js +12 -20
  109. package/dist/mainstack-design-system622.cjs +1 -1
  110. package/dist/mainstack-design-system622.js +19 -10
  111. package/dist/mainstack-design-system623.cjs +1 -2
  112. package/dist/mainstack-design-system623.js +10 -11
  113. package/dist/mainstack-design-system624.cjs +2 -1
  114. package/dist/mainstack-design-system624.js +12 -12
  115. package/dist/mainstack-design-system625.cjs +1 -1
  116. package/dist/mainstack-design-system625.js +12 -22
  117. package/dist/mainstack-design-system626.cjs +1 -2
  118. package/dist/mainstack-design-system626.js +21 -259
  119. package/dist/mainstack-design-system627.cjs +1 -1
  120. package/dist/mainstack-design-system627.js +228 -120
  121. package/dist/mainstack-design-system628.cjs +2 -1
  122. package/dist/mainstack-design-system628.js +146 -55
  123. package/dist/mainstack-design-system629.cjs +1 -1
  124. package/dist/mainstack-design-system629.js +60 -23
  125. package/dist/mainstack-design-system630.cjs +1 -2
  126. package/dist/mainstack-design-system630.js +21 -96
  127. package/dist/mainstack-design-system631.cjs +1 -1
  128. package/dist/mainstack-design-system631.js +93 -135
  129. package/dist/mainstack-design-system632.cjs +1 -2
  130. package/dist/mainstack-design-system632.js +130 -396
  131. package/dist/mainstack-design-system633.cjs +2 -9
  132. package/dist/mainstack-design-system633.js +392 -161
  133. package/dist/mainstack-design-system634.cjs +10 -5
  134. package/dist/mainstack-design-system634.js +158 -2143
  135. package/dist/mainstack-design-system635.cjs +5 -2
  136. package/dist/mainstack-design-system635.js +2115 -398
  137. package/dist/mainstack-design-system636.cjs +1 -41
  138. package/dist/mainstack-design-system636.js +386 -23680
  139. package/dist/mainstack-design-system637.cjs +41 -3
  140. package/dist/mainstack-design-system637.js +23496 -7198
  141. package/dist/mainstack-design-system638.cjs +3 -1
  142. package/dist/mainstack-design-system638.js +7286 -2042
  143. package/dist/mainstack-design-system639.cjs +2 -1
  144. package/dist/mainstack-design-system639.js +2195 -58
  145. package/dist/mainstack-design-system640.cjs +1 -1
  146. package/dist/mainstack-design-system640.js +61 -1
  147. package/dist/mainstack-design-system641.cjs +1 -1
  148. package/dist/mainstack-design-system641.js +1 -25
  149. package/dist/mainstack-design-system642.cjs +1 -1
  150. package/dist/mainstack-design-system642.js +23 -11
  151. package/dist/mainstack-design-system643.cjs +1 -0
  152. package/dist/mainstack-design-system643.js +13 -0
  153. package/package.json +1 -1
@@ -1,178 +1,409 @@
1
1
  'use client';
2
- import { jsx as a, Fragment as S } from "react/jsx-runtime";
3
- import { D as U } from "./index-eeqUt-Tb.js";
4
- import { b as V } from "./index-RoCFhqzC.js";
5
- import { useResponsivePopoverDrawerContext as X } from "./mainstack-design-system617.js";
6
- import * as E from "react";
7
- import { useId as T, useRef as x, useContext as A, useInsertionEffect as _, useMemo as z, Children as B, isValidElement as F, useState as b } from "react";
8
- import { M as G, i as O, u as Y, L as q } from "./MotionConfigContext-SYEZVO_k.js";
9
- import { u as W, P as J, b as Q } from "./use-presence-Dept-wE7.js";
10
- function k(e, r) {
11
- if (typeof e == "function")
12
- return e(r);
13
- e != null && (e.current = r);
14
- }
15
- function Z(...e) {
16
- return (r) => {
17
- let t = !1;
18
- const o = e.map((s) => {
19
- const n = k(s, r);
20
- return !t && typeof n == "function" && (t = !0), n;
2
+ import { jsxs as q, jsx as it } from "react/jsx-runtime";
3
+ import w, { useRef as lt, useState as v, useCallback as B, useEffect as O, forwardRef as st } from "react";
4
+ import { InputRoot as ft } from "./mainstack-design-system455.js";
5
+ import { InputField as ct } from "./mainstack-design-system456.js";
6
+ import "./mainstack-design-system454.js";
7
+ import { w as S, x as yt, y as F, A as J, z as L, B as pt, C as mt, P as m, I as dt, D as Ct, E as K, F as gt, G as ht, c as Nt, k as bt } from "./utils-C21jc49d.js";
8
+ import { usePhoneNumberContext as vt } from "./mainstack-design-system604.js";
9
+ function A(t, n) {
10
+ return Tt(t) || It(t, n) || Ot(t, n) || At();
11
+ }
12
+ function At() {
13
+ throw new TypeError(`Invalid attempt to destructure non-iterable instance.
14
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
15
+ }
16
+ function Ot(t, n) {
17
+ if (t) {
18
+ if (typeof t == "string") return z(t, n);
19
+ var e = Object.prototype.toString.call(t).slice(8, -1);
20
+ if (e === "Object" && t.constructor && (e = t.constructor.name), e === "Map" || e === "Set") return Array.from(t);
21
+ if (e === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)) return z(t, n);
22
+ }
23
+ }
24
+ function z(t, n) {
25
+ (n == null || n > t.length) && (n = t.length);
26
+ for (var e = 0, a = new Array(n); e < n; e++) a[e] = t[e];
27
+ return a;
28
+ }
29
+ function It(t, n) {
30
+ var e = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
31
+ if (e != null) {
32
+ var a, r, o, s, f = [], c = !0, u = !1;
33
+ try {
34
+ if (o = (e = e.call(t)).next, n !== 0) for (; !(c = (a = o.call(e)).done) && (f.push(a.value), f.length !== n); c = !0) ;
35
+ } catch (l) {
36
+ u = !0, r = l;
37
+ } finally {
38
+ try {
39
+ if (!c && e.return != null && (s = e.return(), Object(s) !== s)) return;
40
+ } finally {
41
+ if (u) throw r;
42
+ }
43
+ }
44
+ return f;
45
+ }
46
+ }
47
+ function Tt(t) {
48
+ if (Array.isArray(t)) return t;
49
+ }
50
+ function Pt(t) {
51
+ var n = this, e = t.value, a = t.onChange, r = t.country, o = t.defaultCountry, s = t.international, f = t.withCountryCallingCode, c = t.useNationalFormatForDefaultCountryValue, u = t.metadata;
52
+ typeof f == "boolean" && !(r && s) && console.error("[react-phone-number-input] `withCountryCallingCode` property can only be used together with `country` and `international` properties"), r && o && console.error("[react-phone-number-input] When `country` property is passed, `defaultCountry` property has no effect and therefore shouldn't be passed"), typeof s == "boolean" && !r && console.error("[react-phone-number-input] `international` property can only be used together with `country` property");
53
+ var l = Ft({
54
+ international: s,
55
+ country: r,
56
+ defaultCountry: o,
57
+ withCountryCallingCode: f
58
+ }), y = lt(), C = function(p, d, b) {
59
+ console.error("[react-phone-number-input] Expected phone number ".concat(p, " to correspond to country ").concat(d, " but ").concat(b ? "in reality it corresponds to country " + b : "it doesn't", ".")), y.current = !0;
60
+ }, g = function(p) {
61
+ return e && yt(e), wt(e, r, o, l, c, u, function() {
62
+ p && p.onCountryMismatch && p.onCountryMismatch();
63
+ for (var d = arguments.length, b = new Array(d), P = 0; P < d; P++)
64
+ b[P] = arguments[P];
65
+ C.apply(n, b);
21
66
  });
22
- if (t)
23
- return () => {
24
- for (let s = 0; s < o.length; s++) {
25
- const n = o[s];
26
- typeof n == "function" ? n() : k(e[s], null);
67
+ }, j = v(r), I = A(j, 2), E = I[0], X = I[1], Z = v(o), V = A(Z, 2), tt = V[0], et = V[1], nt = v(g()), D = A(nt, 2), rt = D[0], h = D[1], at = v(e), M = A(at, 2), T = M[0], N = M[1], ot = v(), W = A(ot, 2);
68
+ W[0];
69
+ var k = W[1], U = B(function() {
70
+ return k({});
71
+ }, [k]);
72
+ function Y(i) {
73
+ if (i) {
74
+ l === "NATIONAL_PART_OF_INTERNATIONAL" && (i = "+".concat(F(r, u)).concat(i));
75
+ var p = new J(r || o, u);
76
+ return p.input(i), p.getNumberValue();
77
+ }
78
+ }
79
+ O(function() {
80
+ e !== T && (N(e), h(g()));
81
+ }, [e]), O(function() {
82
+ if (r !== E) {
83
+ X(r);
84
+ var i, p = g({
85
+ onCountryMismatch: function() {
86
+ i = !0;
87
+ }
88
+ });
89
+ h(p), i && N(Y(p));
90
+ }
91
+ }, [r]), O(function() {
92
+ o !== tt && (et(o), h(g()));
93
+ }, [o]), O(function() {
94
+ T !== e && a(T);
95
+ }, [T]);
96
+ var ut = B(function(i) {
97
+ var p;
98
+ if (r)
99
+ if (l === "INTERNATIONAL") {
100
+ var d = S(r, u);
101
+ if (i.indexOf(d) !== 0) {
102
+ if (i && i[0] !== "+")
103
+ i = d + i;
104
+ else if (!y.current) return h(d), N(void 0), U();
27
105
  }
28
- };
106
+ } else
107
+ i && i[0] === "+" && (i = i.slice(1));
108
+ else o || i && i[0] !== "+" && (i = "+" + i);
109
+ i && (p = Y(i)), h(i), N(p);
110
+ }, [r, l, o, u, h, N, U, y]);
111
+ return {
112
+ phoneDigits: rt,
113
+ setPhoneDigits: ut,
114
+ inputFormat: l
29
115
  };
30
116
  }
31
- function ee(...e) {
32
- return E.useCallback(Z(...e), e);
117
+ function wt(t, n, e, a, r, o, s) {
118
+ if (n && a === "INTERNATIONAL") {
119
+ var f = S(n, o);
120
+ return t ? (t.indexOf(f) !== 0 && s(t, n), t) : f;
121
+ }
122
+ if (!t)
123
+ return "";
124
+ if (!n && !e)
125
+ return t;
126
+ var c = new J(void 0, o);
127
+ c.input(t);
128
+ var u = c.getNumber();
129
+ if (u)
130
+ if (n)
131
+ switch (u.country && u.country !== n ? s(t, n, u.country) : u.countryCallingCode !== F(n, o) && s(t, n), a) {
132
+ case "NATIONAL":
133
+ return L(u.formatNational());
134
+ case "NATIONAL_PART_OF_INTERNATIONAL":
135
+ return L(pt(u.formatInternational(), S(n, o)));
136
+ case "INTERNATIONAL":
137
+ throw new Error('`inputFormat: "INTERNATIONAL"` case should\'ve already been handled earlier in the code');
138
+ case "INTERNATIONAL_OR_NATIONAL":
139
+ throw new Error('`inputFormat: "INTERNATIONAL_OR_NATIONAL"` is not possible when `country` is fixed');
140
+ default:
141
+ throw new Error("Unknown `inputFormat`: ".concat(a));
142
+ }
143
+ else
144
+ return u.countryCallingCode && u.countryCallingCode === F(e, o) && r ? L(u.formatNational()) : t;
145
+ else
146
+ return "";
147
+ }
148
+ function Ft(t) {
149
+ var n = t.international, e = t.country, a = t.defaultCountry, r = t.withCountryCallingCode;
150
+ return e ? n ? r ? "INTERNATIONAL" : "NATIONAL_PART_OF_INTERNATIONAL" : "NATIONAL" : a ? "INTERNATIONAL_OR_NATIONAL" : "INTERNATIONAL";
33
151
  }
34
- class te extends E.Component {
35
- getSnapshotBeforeUpdate(r) {
36
- const t = this.props.childRef.current;
37
- if (t && r.isPresent && !this.props.isPresent) {
38
- const o = t.offsetParent, s = O(o) && o.offsetWidth || 0, n = this.props.sizeRef.current;
39
- n.height = t.offsetHeight || 0, n.width = t.offsetWidth || 0, n.top = t.offsetTop, n.left = t.offsetLeft, n.right = s - n.width - n.left;
152
+ var Rt = ["Component", "country", "defaultCountry", "useNationalFormatForDefaultCountryValue", "value", "onChange", "metadata", "international", "withCountryCallingCode"];
153
+ function _() {
154
+ return _ = Object.assign ? Object.assign.bind() : function(t) {
155
+ for (var n = 1; n < arguments.length; n++) {
156
+ var e = arguments[n];
157
+ for (var a in e)
158
+ Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
40
159
  }
41
- return null;
160
+ return t;
161
+ }, _.apply(this, arguments);
162
+ }
163
+ function jt(t, n) {
164
+ if (t == null) return {};
165
+ var e = Et(t, n), a, r;
166
+ if (Object.getOwnPropertySymbols) {
167
+ var o = Object.getOwnPropertySymbols(t);
168
+ for (r = 0; r < o.length; r++)
169
+ a = o[r], !(n.indexOf(a) >= 0) && Object.prototype.propertyIsEnumerable.call(t, a) && (e[a] = t[a]);
42
170
  }
171
+ return e;
172
+ }
173
+ function Et(t, n) {
174
+ if (t == null) return {};
175
+ var e = {}, a = Object.keys(t), r, o;
176
+ for (o = 0; o < a.length; o++)
177
+ r = a[o], !(n.indexOf(r) >= 0) && (e[r] = t[r]);
178
+ return e;
179
+ }
180
+ function R(t, n) {
181
+ var e = t.Component, a = t.country, r = t.defaultCountry, o = t.useNationalFormatForDefaultCountryValue, s = o === void 0 ? !0 : o, f = t.value, c = t.onChange, u = t.metadata, l = t.international, y = t.withCountryCallingCode, C = jt(t, Rt), g = Pt({
182
+ value: f,
183
+ onChange: c,
184
+ country: a,
185
+ defaultCountry: r,
186
+ international: l,
187
+ withCountryCallingCode: y,
188
+ useNationalFormatForDefaultCountryValue: s,
189
+ metadata: u
190
+ }), j = g.phoneDigits, I = g.setPhoneDigits, E = g.inputFormat;
191
+ return /* @__PURE__ */ w.createElement(e, _({}, C, {
192
+ ref: n,
193
+ metadata: u,
194
+ inputFormat: E,
195
+ international: l,
196
+ withCountryCallingCode: y,
197
+ country: a || r,
198
+ value: j,
199
+ onChange: I
200
+ }));
201
+ }
202
+ R = /* @__PURE__ */ w.forwardRef(R);
203
+ R.propTypes = {
204
+ /**
205
+ * The phone number (in E.164 format).
206
+ * Examples: `"+12"`, `"+12133734253"`.
207
+ * An "empty" `value` could be represented by any "falsy" value like `undefined`, `null` or an empty string `""`.
208
+ */
209
+ value: m.string,
210
+ /**
211
+ * A function of `value: string?`.
212
+ * Updates the `value` property (to `undefined` in case it's empty).
213
+ */
214
+ onChange: m.func.isRequired,
215
+ /**
216
+ * A two-letter country code for formatting `value`
217
+ * as a national phone number (example: `(213) 373-4253`),
218
+ * or as an international phone number without "country calling code"
219
+ * if `international` property is passed (example: `213 373 4253`).
220
+ * Example: "US".
221
+ * If no `country` is passed then `value`
222
+ * is formatted as an international phone number.
223
+ * (example: `+1 213 373 4253`)
224
+ */
225
+ country: m.string,
226
+ /**
227
+ * A two-letter country code for formatting `value`
228
+ * when a user inputs a national phone number (example: `(213) 373-4253`).
229
+ * The user can still input a phone number in international format.
230
+ * Example: "US".
231
+ * `country` and `defaultCountry` properties are mutually exclusive.
232
+ */
233
+ defaultCountry: m.string,
234
+ /**
235
+ * If `country` property is passed along with `international={true}` property
236
+ * then the phone number will be input in "international" format for that `country`
237
+ * (without "country calling code").
238
+ * For example, if `country="US"` property is passed to "without country select" input
239
+ * then the phone number will be input in the "national" format for `US` (`(213) 373-4253`).
240
+ * But if both `country="US"` and `international={true}` properties are passed then
241
+ * the phone number will be input in the "international" format for `US` (`213 373 4253`)
242
+ * (without "country calling code" `+1`).
243
+ */
244
+ international: m.bool,
245
+ /**
246
+ * If `country` and `international` properties are set,
247
+ * then by default it won't include "country calling code" in the input field.
248
+ * To change that, pass `withCountryCallingCode` property,
249
+ * and it will include "country calling code" in the input field.
250
+ */
251
+ withCountryCallingCode: m.bool,
252
+ /**
253
+ * A component that renders the `<input/>` itself and also
254
+ * parses and formats its `value` as the user inputs it.
255
+ * See `InputBasic.js` and `InputSmart.js` for an example.
256
+ */
257
+ Component: m.elementType.isRequired,
43
258
  /**
44
- * Required with getSnapshotBeforeUpdate to stop React complaining.
259
+ * When `defaultCountry` is defined and the initial `value` corresponds to `defaultCountry`,
260
+ * then the `value` will be formatted as a national phone number by default.
261
+ * To format the initial `value` of `defaultCountry` as an international number instead
262
+ * set `useNationalFormatForDefaultCountryValue` property to `true`.
45
263
  */
46
- componentDidUpdate() {
264
+ useNationalFormatForDefaultCountryValue: m.bool,
265
+ /**
266
+ * `libphonenumber-js` metadata.
267
+ */
268
+ metadata: mt
269
+ };
270
+ var Lt = ["type", "autoComplete", "smartCaret", "metadata"];
271
+ function x() {
272
+ return x = Object.assign ? Object.assign.bind() : function(t) {
273
+ for (var n = 1; n < arguments.length; n++) {
274
+ var e = arguments[n];
275
+ for (var a in e)
276
+ Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
277
+ }
278
+ return t;
279
+ }, x.apply(this, arguments);
280
+ }
281
+ function St(t, n) {
282
+ if (t == null) return {};
283
+ var e = _t(t, n), a, r;
284
+ if (Object.getOwnPropertySymbols) {
285
+ var o = Object.getOwnPropertySymbols(t);
286
+ for (r = 0; r < o.length; r++)
287
+ a = o[r], !(n.indexOf(a) >= 0) && Object.prototype.propertyIsEnumerable.call(t, a) && (e[a] = t[a]);
47
288
  }
48
- render() {
49
- return this.props.children;
289
+ return e;
290
+ }
291
+ function _t(t, n) {
292
+ if (t == null) return {};
293
+ var e = {}, a = Object.keys(t), r, o;
294
+ for (o = 0; o < a.length; o++)
295
+ r = a[o], !(n.indexOf(r) >= 0) && (e[r] = t[r]);
296
+ return e;
297
+ }
298
+ function Q(t) {
299
+ function n(e, a) {
300
+ var r = e.type, o = r === void 0 ? "tel" : r, s = e.autoComplete, f = s === void 0 ? "tel" : s, c = e.smartCaret, u = c === void 0 ? !0 : c, l = e.metadata, y = l === void 0 ? t : l, C = St(e, Lt);
301
+ return /* @__PURE__ */ w.createElement(R, x({}, C, {
302
+ type: o,
303
+ autoComplete: f,
304
+ metadata: y,
305
+ ref: a,
306
+ Component: u ? dt : Ct
307
+ }));
50
308
  }
309
+ return n = /* @__PURE__ */ w.forwardRef(n), n.propTypes = {
310
+ /**
311
+ * HTML `<input/>` `type` attribute.
312
+ */
313
+ type: m.string,
314
+ /**
315
+ * HTML `<input/>` `autocomplete` attribute.
316
+ */
317
+ autoComplete: m.string,
318
+ /**
319
+ * By default, the caret position is being "intelligently" managed
320
+ * while a user inputs a phone number.
321
+ * This "smart" caret behavior can be turned off
322
+ * by passing `smartCaret={false}` property.
323
+ * This is just an "escape hatch" for any possible caret position issues.
324
+ */
325
+ // Is `true` by default.
326
+ smartCaret: m.bool,
327
+ /**
328
+ * `libphonenumber-js` metadata.
329
+ */
330
+ metadata: m.object
331
+ }, n;
332
+ }
333
+ Q();
334
+ function $(t, n) {
335
+ var e = Array.prototype.slice.call(n);
336
+ return e.push(K), t.apply(this, e);
337
+ }
338
+ Q(K);
339
+ function G() {
340
+ return $(ht, arguments);
341
+ }
342
+ function H() {
343
+ return $(F, arguments);
51
344
  }
52
- function ne({ children: e, isPresent: r, anchorX: t, root: o }) {
53
- const s = T(), n = x(null), h = x({
54
- width: 0,
55
- height: 0,
56
- top: 0,
57
- left: 0,
58
- right: 0
59
- }), { nonce: v } = A(G), P = ee(n, e?.ref);
60
- return _(() => {
61
- const { width: i, height: g, top: l, left: u, right: p } = h.current;
62
- if (r || !n.current || !i || !g)
63
- return;
64
- const m = t === "left" ? `left: ${u}` : `right: ${p}`;
65
- n.current.dataset.motionPopId = s;
66
- const f = document.createElement("style");
67
- v && (f.nonce = v);
68
- const y = o ?? document.head;
69
- return y.appendChild(f), f.sheet && f.sheet.insertRule(`
70
- [data-motion-pop-id="${s}"] {
71
- position: absolute !important;
72
- width: ${i}px !important;
73
- height: ${g}px !important;
74
- ${m}px !important;
75
- top: ${l}px !important;
76
- }
77
- `), () => {
78
- y.contains(f) && y.removeChild(f);
345
+ function xt() {
346
+ return $(gt, arguments);
347
+ }
348
+ const $t = st(
349
+ ({
350
+ placeholder: t = "000 - 000 - 000",
351
+ disabled: n,
352
+ ...e
353
+ }, a) => {
354
+ const {
355
+ activeCountry: r,
356
+ isDisabled: o,
357
+ value: s,
358
+ onValueChange: f,
359
+ setActiveCountry: c
360
+ } = vt(), u = (l) => {
361
+ if (!l) return "";
362
+ const y = G(l);
363
+ if (y)
364
+ return y.nationalNumber;
365
+ let C = "";
366
+ return r && xt(r) && (C = H(r)), l.replace(`+${C}`, "");
79
367
  };
80
- }, [r]), a(te, { isPresent: r, childRef: n, sizeRef: h, children: E.cloneElement(e, { ref: P }) });
81
- }
82
- const re = ({ children: e, initial: r, isPresent: t, onExitComplete: o, custom: s, presenceAffectsLayout: n, mode: h, anchorX: v, root: P }) => {
83
- const i = W(oe), g = T();
84
- let l = !0, u = z(() => (l = !1, {
85
- id: g,
86
- initial: r,
87
- isPresent: t,
88
- custom: s,
89
- onExitComplete: (p) => {
90
- i.set(p, !0);
91
- for (const m of i.values())
92
- if (!m)
93
- return;
94
- o && o();
95
- },
96
- register: (p) => (i.set(p, !1), () => i.delete(p))
97
- }), [t, i, o]);
98
- return n && l && (u = { ...u }), z(() => {
99
- i.forEach((p, m) => i.set(m, !1));
100
- }, [t]), E.useEffect(() => {
101
- !t && !i.size && o && o();
102
- }, [t]), h === "popLayout" && (e = a(ne, { isPresent: t, anchorX: v, root: P, children: e })), a(J.Provider, { value: u, children: e });
103
- };
104
- function oe() {
105
- return /* @__PURE__ */ new Map();
106
- }
107
- const R = (e) => e.key || "";
108
- function I(e) {
109
- const r = [];
110
- return B.forEach(e, (t) => {
111
- F(t) && r.push(t);
112
- }), r;
113
- }
114
- const N = ({ children: e, custom: r, initial: t = !0, onExitComplete: o, presenceAffectsLayout: s = !0, mode: n = "sync", propagate: h = !1, anchorX: v = "left", root: P }) => {
115
- const [i, g] = Q(h), l = z(() => I(e), [e]), u = h && !i ? [] : l.map(R), p = x(!0), m = x(l), f = W(() => /* @__PURE__ */ new Map()), [y, j] = b(l), [C, L] = b(l);
116
- Y(() => {
117
- p.current = !1, m.current = l;
118
- for (let d = 0; d < C.length; d++) {
119
- const c = R(C[d]);
120
- u.includes(c) ? f.delete(c) : f.get(c) !== !0 && f.set(c, !1);
121
- }
122
- }, [C, u.length, u.join("-")]);
123
- const M = [];
124
- if (l !== y) {
125
- let d = [...l];
126
- for (let c = 0; c < C.length; c++) {
127
- const w = C[c], D = R(w);
128
- u.includes(D) || (d.splice(c, 0, w), M.push(w));
129
- }
130
- return n === "wait" && M.length && (d = M), L(I(d)), j(l), null;
368
+ return O(() => {
369
+ if (s && !r) {
370
+ const l = G(s);
371
+ l && c(l.country);
372
+ }
373
+ }, [r, c, s]), /* @__PURE__ */ q(
374
+ ft,
375
+ {
376
+ "data-slot": "phone-number-digit-field",
377
+ className: "mds:has-disabled:opacity-50",
378
+ children: [
379
+ /* @__PURE__ */ q("p", { className: Nt("mds:body-extrasmall-regular"), children: [
380
+ "(+",
381
+ H(r || "US"),
382
+ ")"
383
+ ] }),
384
+ /* @__PURE__ */ it(
385
+ ct,
386
+ {
387
+ ...e,
388
+ disabled: n || o,
389
+ placeholder: t,
390
+ value: u(s),
391
+ onChange: (l) => {
392
+ const y = bt({
393
+ value: l.target.value,
394
+ activeCountry: r
395
+ });
396
+ f && (l.target.value = y.digit, f(y));
397
+ },
398
+ ref: a
399
+ }
400
+ )
401
+ ]
402
+ }
403
+ );
131
404
  }
132
- process.env.NODE_ENV !== "production" && n === "wait" && C.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
133
- const { forceRender: H } = A(q);
134
- return a(S, { children: C.map((d) => {
135
- const c = R(d), w = h && !i ? !1 : l === C || u.includes(c), D = () => {
136
- if (f.has(c))
137
- f.set(c, !0);
138
- else
139
- return;
140
- let $ = !0;
141
- f.forEach((K) => {
142
- K || ($ = !1);
143
- }), $ && (H?.(), L(m.current), h && g?.(), o && o());
144
- };
145
- return a(re, { isPresent: w, initial: !p.current || t ? void 0 : !1, custom: r, presenceAffectsLayout: s, mode: n, root: P, onExitComplete: w ? void 0 : D, anchorX: v, children: d }, c);
146
- }) });
147
- }, pe = ({
148
- children: e,
149
- ...r
150
- }) => {
151
- const { isDesktop: t, open: o } = X();
152
- return t ? /* @__PURE__ */ a(V, { forceMount: !0, ...r, children: /* @__PURE__ */ a(N, { children: o ? /* @__PURE__ */ a(
153
- "div",
154
- {
155
- className: "mds:relative mds:z-100",
156
- "data-slot": "responsive-popover-drawer-portal",
157
- children: e
158
- }
159
- ) : null }) }) : /* @__PURE__ */ a(
160
- U.Portal,
161
- {
162
- forceMount: !0,
163
- "data-slot": "responsive-popover-drawer-portal",
164
- ...r,
165
- children: /* @__PURE__ */ a(N, { children: o ? /* @__PURE__ */ a(
166
- "div",
167
- {
168
- className: "mds:relative mds:z-100",
169
- "data-slot": "responsive-popover-drawer-portal",
170
- children: e
171
- }
172
- ) : null })
173
- }
174
- );
175
- };
405
+ );
406
+ $t.displayName = "PhoneNumberDigitField";
176
407
  export {
177
- pe as ResponsivePopoverDrawerPortal
408
+ $t as PhoneNumberDigitField
178
409
  };