@konstructio/ui 0.1.2-alpha.3 → 0.1.2-alpha.30

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 (163) hide show
  1. package/dist/DatePicker.css +1 -1
  2. package/dist/Modal-5xSxFoaD.js +99 -0
  3. package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
  4. package/dist/chevron-down-DgT-uSF9.js +5 -0
  5. package/dist/chevron-right-DYvXLeql.js +7 -0
  6. package/dist/chevron-up-DrQr2Fwd.js +5 -0
  7. package/dist/components/Alert/Alert.js +2 -2
  8. package/dist/components/AlertDialog/AlertDialog.js +1 -1
  9. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
  10. package/dist/components/AlertDialog/components/index.js +1 -1
  11. package/dist/components/Badge/Badge.js +30 -33
  12. package/dist/components/Badge/Badge.variants.js +8 -6
  13. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  14. package/dist/components/Breadcrumb/components/Item/Item.js +24 -23
  15. package/dist/components/Breadcrumb/hooks/useBreadcrumb.js +1 -1
  16. package/dist/components/Button/Button.js +1 -1
  17. package/dist/components/Button/Button.variants.js +1 -1
  18. package/dist/components/Card/Card.variants.js +5 -9
  19. package/dist/components/Checkbox/Checkbox.js +6 -6
  20. package/dist/components/Command/Command.js +2 -2
  21. package/dist/components/Command/components/Command.js +1 -1
  22. package/dist/components/Command/components/CommandEmpty.js +1 -1
  23. package/dist/components/Command/components/CommandGroup.js +1 -1
  24. package/dist/components/Command/components/CommandInput.js +2 -2
  25. package/dist/components/Command/components/CommandItem.js +1 -1
  26. package/dist/components/Command/components/CommandList.js +1 -1
  27. package/dist/components/Command/components/CommandSeparator.js +1 -1
  28. package/dist/components/Command/components/DialogContent.js +2 -2
  29. package/dist/components/Command/components/DialogOverlay.js +1 -1
  30. package/dist/components/Datepicker/DatePicker.js +1209 -1147
  31. package/dist/components/Divider/Divider.variants.js +1 -1
  32. package/dist/components/Dropdown/Dropdown.js +46 -28
  33. package/dist/components/Dropdown/Dropdown.variants.js +32 -9
  34. package/dist/components/Dropdown/components/List/List.js +133 -54
  35. package/dist/components/Dropdown/components/List/List.variants.js +9 -7
  36. package/dist/components/Dropdown/components/ListItem/ListItem.js +74 -24
  37. package/dist/components/Dropdown/components/ListItem/ListItem.variants.js +9 -7
  38. package/dist/components/Dropdown/components/Wrapper.js +144 -109
  39. package/dist/components/Dropdown/constants/index.js +4 -0
  40. package/dist/components/Dropdown/constants/pagination.js +4 -0
  41. package/dist/components/Dropdown/contexts/dropdown.context.js +26 -8
  42. package/dist/components/Dropdown/contexts/dropdown.provider.js +48 -19
  43. package/dist/components/Dropdown/hooks/useDropdown.js +83 -39
  44. package/dist/components/Dropdown/hooks/useNavigationList.js +28 -36
  45. package/dist/components/DropdownButton/DropdownButton.js +1 -1
  46. package/dist/components/Filter/Filter.variants.js +2 -2
  47. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +1 -1
  48. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +1 -1
  49. package/dist/components/Input/Input.js +1 -1
  50. package/dist/components/Input/Input.variants.js +1 -1
  51. package/dist/components/Loading/Loading.js +1 -7
  52. package/dist/components/Modal/Modal.js +2 -2
  53. package/dist/components/Modal/components/Body/Body.js +1 -1
  54. package/dist/components/Modal/components/Footer/Footer.js +1 -1
  55. package/dist/components/Modal/components/Header/Header.js +1 -1
  56. package/dist/components/Modal/components/Wrapper/Wrapper.js +3 -3
  57. package/dist/components/Modal/components/index.js +1 -1
  58. package/dist/components/NumberInput/NumberInput.js +2 -2
  59. package/dist/components/PhoneNumberInput/PhoneNumberInput.js +8 -0
  60. package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +45 -0
  61. package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +27 -0
  62. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +629 -0
  63. package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +36 -0
  64. package/dist/components/PhoneNumberInput/components/TruncateText/TruncateText.js +45 -0
  65. package/dist/components/PhoneNumberInput/components/Wrapper.js +625 -0
  66. package/dist/components/PhoneNumberInput/components/index.js +6 -0
  67. package/dist/components/PhoneNumberInput/contexts/index.js +8 -0
  68. package/dist/components/PhoneNumberInput/contexts/phone-number.context.js +28 -0
  69. package/dist/components/PhoneNumberInput/contexts/phone-number.hook.js +13 -0
  70. package/dist/components/PhoneNumberInput/contexts/phone-number.provider.js +6137 -0
  71. package/dist/components/PhoneNumberInput/utils/index.js +11 -0
  72. package/dist/components/PieChart/PieChart.js +647 -664
  73. package/dist/components/RadioCard/RadioCard.variants.js +1 -6
  74. package/dist/components/RadioGroup/RadioGroup.js +1 -1
  75. package/dist/components/Range/Range.js +1 -1
  76. package/dist/components/Sidebar/Sidebar.variants.js +2 -2
  77. package/dist/components/Sidebar/components/Wrapper/Wrapper.js +29 -28
  78. package/dist/components/Slider/Slider.js +1 -1
  79. package/dist/components/Switch/Switch.js +8 -8
  80. package/dist/components/Switch/Switch.variants.js +4 -4
  81. package/dist/components/Tabs/Tabs.js +1 -1
  82. package/dist/components/Tabs/Tabs.variants.js +45 -24
  83. package/dist/components/Tabs/components/Content.js +1 -1
  84. package/dist/components/Tabs/components/List.js +1 -1
  85. package/dist/components/Tabs/components/Trigger.js +9 -8
  86. package/dist/components/Tag/Tag.js +1 -1
  87. package/dist/components/TagSelect/components/Wrapper/Wrapper.js +98 -49
  88. package/dist/components/TimePicker/TimePicker.variants.js +2 -2
  89. package/dist/components/TimePicker/components/Wrapper/Wrapper.js +2 -2
  90. package/dist/components/Toast/Toast.js +206 -181
  91. package/dist/components/Tooltip/Tooltip.js +1 -1
  92. package/dist/components/Typography/Typography.variants.js +18 -23
  93. package/dist/components/VirtualizedTable/VirtualizedTable.js +119 -0
  94. package/dist/components/VirtualizedTable/VirtualizedTable.variants.js +5 -0
  95. package/dist/components/VirtualizedTable/assets/chevron-down.js +25 -0
  96. package/dist/components/VirtualizedTable/assets/chevron-up.js +25 -0
  97. package/dist/components/VirtualizedTable/assets/index.js +6 -0
  98. package/dist/components/VirtualizedTable/components/Actions/Actions.js +72 -0
  99. package/dist/components/VirtualizedTable/components/Body/Body.js +51 -0
  100. package/dist/components/VirtualizedTable/components/DotPaginate/DotPaginate.js +165 -0
  101. package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +34 -0
  102. package/dist/components/VirtualizedTable/components/Filter/Filter.js +88 -0
  103. package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +48 -0
  104. package/dist/components/VirtualizedTable/components/Header/Header.js +84 -0
  105. package/dist/components/VirtualizedTable/components/Pagination/Pagination.js +53 -0
  106. package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +67 -0
  107. package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +34 -0
  108. package/dist/components/VirtualizedTable/components/WrapperBody/WrapperBody.js +27 -0
  109. package/dist/components/VirtualizedTable/components/index.js +16 -0
  110. package/dist/components/VirtualizedTable/constants/index.js +5 -0
  111. package/dist/components/VirtualizedTable/constants/pagination.js +5 -0
  112. package/dist/components/VirtualizedTable/contexts/index.js +8 -0
  113. package/dist/components/VirtualizedTable/contexts/table.context.js +32 -0
  114. package/dist/components/VirtualizedTable/contexts/table.hook.js +11 -0
  115. package/dist/components/VirtualizedTable/contexts/table.provider.js +85 -0
  116. package/dist/components/index.js +79 -73
  117. package/dist/contexts/theme.provider.js +0 -1
  118. package/dist/{createLucideIcon-DbC6TvM5.js → createLucideIcon-D4r5Phnh.js} +0 -24
  119. package/dist/debounce-BFejQm9P.js +200 -0
  120. package/dist/ellipsis-vertical-BVPtjl5f.js +9 -0
  121. package/dist/{index-h-Ul0anl.js → index--V_ZsiQe.js} +1 -22
  122. package/dist/index-2hB40Iuc.js +1873 -0
  123. package/dist/index-BZPx6jYI.js +8 -0
  124. package/dist/{index-bwWKd82e.js → index-BbQkJE5L.js} +1 -1
  125. package/dist/index-BtQfgaSF.js +60 -0
  126. package/dist/index-C3tHPg8y.js +662 -0
  127. package/dist/index-CIAmiWcw.js +200 -0
  128. package/dist/index-CSFe9uC5.js +14 -0
  129. package/dist/index-CSWGJT-v.js +1722 -0
  130. package/dist/index-CigKKiZS.js +91 -0
  131. package/dist/index-DDByhzds.js +137 -0
  132. package/dist/{index-BAraV3ai.js → index-DH2Fnov1.js} +11 -12
  133. package/dist/index-DLcqcWxM.js +29 -0
  134. package/dist/index-Dbt2vBmS.js +136 -0
  135. package/dist/{index-DB2XhXHn.js → index-DpW9ExsS.js} +7 -7
  136. package/dist/index-DrWQH0QF.js +55 -0
  137. package/dist/{index-D3xzCzcO.js → index-X4k_cU8k.js} +4 -4
  138. package/dist/index-kyuBfLcN.js +479 -0
  139. package/dist/{index-C1g_chDT.js → index-mPY_8Y5v.js} +2 -2
  140. package/dist/index-ohdbKsws.js +27 -0
  141. package/dist/index.d.ts +184 -18
  142. package/dist/index.js +106 -98
  143. package/dist/libphonenumber-_7ZyKWA7.js +11549 -0
  144. package/dist/package.json +46 -32
  145. package/dist/styles.css +1 -1
  146. package/dist/ui/civo-theme.css +191 -167
  147. package/dist/{useBreadcrumb-B8DnuqkR.js → useBreadcrumb-BAHbGQ_O.js} +0 -10
  148. package/dist/utils/index.js +534 -501
  149. package/dist/{x-BPcqkRZd.js → x-DPU9OdYH.js} +1 -1
  150. package/package.json +46 -32
  151. package/dist/Modal-V67Uz78z.js +0 -98
  152. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  153. package/dist/chevron-down-BLZPftpV.js +0 -11
  154. package/dist/chevron-up-RLP4nX7V.js +0 -54
  155. package/dist/index-BXuxPoz7.js +0 -435
  156. package/dist/index-BfXxHr_2.js +0 -125
  157. package/dist/index-C9T9HQaa.js +0 -423
  158. package/dist/index-CZnD2QxM.js +0 -32
  159. package/dist/index-CrBonFvu.js +0 -144
  160. package/dist/index-Cvx4lqTq.js +0 -47
  161. package/dist/index-DQH6odE9.js +0 -82
  162. package/dist/index-Oq5GlCHP.js +0 -131
  163. package/dist/index-iXyXtdgP.js +0 -31
@@ -0,0 +1,629 @@
1
+ import { jsx as f, jsxs as N } from "react/jsx-runtime";
2
+ import * as y from "react";
3
+ import { useRef as R, useMemo as F, useEffect as T } from "react";
4
+ import { flushSync as k } from "react-dom";
5
+ import { Typography as w } from "../../../Typography/Typography.js";
6
+ import { TruncateText as D } from "../TruncateText/TruncateText.js";
7
+ import { usePhoneNumberContext as A } from "../../contexts/phone-number.hook.js";
8
+ function b(r, l, e) {
9
+ let t = e.initialDeps ?? [], s;
10
+ function i() {
11
+ var n, o, a, c;
12
+ let h;
13
+ e.key && ((n = e.debug) != null && n.call(e)) && (h = Date.now());
14
+ const u = r();
15
+ if (!(u.length !== t.length || u.some((m, p) => t[p] !== m)))
16
+ return s;
17
+ t = u;
18
+ let g;
19
+ if (e.key && ((o = e.debug) != null && o.call(e)) && (g = Date.now()), s = l(...u), e.key && ((a = e.debug) != null && a.call(e))) {
20
+ const m = Math.round((Date.now() - h) * 100) / 100, p = Math.round((Date.now() - g) * 100) / 100, E = p / 16, x = (v, _) => {
21
+ for (v = String(v); v.length < _; )
22
+ v = " " + v;
23
+ return v;
24
+ };
25
+ console.info(
26
+ `%c⏱ ${x(p, 5)} /${x(m, 5)} ms`,
27
+ `
28
+ font-size: .6rem;
29
+ font-weight: bold;
30
+ color: hsl(${Math.max(
31
+ 0,
32
+ Math.min(120 - 120 * E, 120)
33
+ )}deg 100% 31%);`,
34
+ e?.key
35
+ );
36
+ }
37
+ return (c = e?.onChange) == null || c.call(e, s), s;
38
+ }
39
+ return i.updateDeps = (n) => {
40
+ t = n;
41
+ }, i;
42
+ }
43
+ function S(r, l) {
44
+ if (r === void 0)
45
+ throw new Error("Unexpected undefined");
46
+ return r;
47
+ }
48
+ const V = (r, l) => Math.abs(r - l) < 1.01, W = (r, l, e) => {
49
+ let t;
50
+ return function(...s) {
51
+ r.clearTimeout(t), t = r.setTimeout(() => l.apply(this, s), e);
52
+ };
53
+ }, z = (r) => {
54
+ const { offsetWidth: l, offsetHeight: e } = r;
55
+ return { width: l, height: e };
56
+ }, L = (r) => r, j = (r) => {
57
+ const l = Math.max(r.startIndex - r.overscan, 0), e = Math.min(r.endIndex + r.overscan, r.count - 1), t = [];
58
+ for (let s = l; s <= e; s++)
59
+ t.push(s);
60
+ return t;
61
+ }, P = (r, l) => {
62
+ const e = r.scrollElement;
63
+ if (!e)
64
+ return;
65
+ const t = r.targetWindow;
66
+ if (!t)
67
+ return;
68
+ const s = (n) => {
69
+ const { width: o, height: a } = n;
70
+ l({ width: Math.round(o), height: Math.round(a) });
71
+ };
72
+ if (s(z(e)), !t.ResizeObserver)
73
+ return () => {
74
+ };
75
+ const i = new t.ResizeObserver((n) => {
76
+ const o = () => {
77
+ const a = n[0];
78
+ if (a?.borderBoxSize) {
79
+ const c = a.borderBoxSize[0];
80
+ if (c) {
81
+ s({ width: c.inlineSize, height: c.blockSize });
82
+ return;
83
+ }
84
+ }
85
+ s(z(e));
86
+ };
87
+ r.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
88
+ });
89
+ return i.observe(e, { box: "border-box" }), () => {
90
+ i.unobserve(e);
91
+ };
92
+ }, M = {
93
+ passive: !0
94
+ }, O = typeof window > "u" ? !0 : "onscrollend" in window, B = (r, l) => {
95
+ const e = r.scrollElement;
96
+ if (!e)
97
+ return;
98
+ const t = r.targetWindow;
99
+ if (!t)
100
+ return;
101
+ let s = 0;
102
+ const i = r.options.useScrollendEvent && O ? () => {
103
+ } : W(
104
+ t,
105
+ () => {
106
+ l(s, !1);
107
+ },
108
+ r.options.isScrollingResetDelay
109
+ ), n = (h) => () => {
110
+ const { horizontal: u, isRtl: d } = r.options;
111
+ s = u ? e.scrollLeft * (d && -1 || 1) : e.scrollTop, i(), l(s, h);
112
+ }, o = n(!0), a = n(!1);
113
+ a(), e.addEventListener("scroll", o, M);
114
+ const c = r.options.useScrollendEvent && O;
115
+ return c && e.addEventListener("scrollend", a, M), () => {
116
+ e.removeEventListener("scroll", o), c && e.removeEventListener("scrollend", a);
117
+ };
118
+ }, $ = (r, l, e) => {
119
+ if (l?.borderBoxSize) {
120
+ const t = l.borderBoxSize[0];
121
+ if (t)
122
+ return Math.round(
123
+ t[e.options.horizontal ? "inlineSize" : "blockSize"]
124
+ );
125
+ }
126
+ return r[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
127
+ }, q = (r, {
128
+ adjustments: l = 0,
129
+ behavior: e
130
+ }, t) => {
131
+ var s, i;
132
+ const n = r + l;
133
+ (i = (s = t.scrollElement) == null ? void 0 : s.scrollTo) == null || i.call(s, {
134
+ [t.options.horizontal ? "left" : "top"]: n,
135
+ behavior: e
136
+ });
137
+ };
138
+ class H {
139
+ constructor(l) {
140
+ this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
141
+ let e = null;
142
+ const t = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
143
+ s.forEach((i) => {
144
+ const n = () => {
145
+ this._measureElement(i.target, i);
146
+ };
147
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(n) : n();
148
+ });
149
+ }));
150
+ return {
151
+ disconnect: () => {
152
+ var s;
153
+ (s = t()) == null || s.disconnect(), e = null;
154
+ },
155
+ observe: (s) => {
156
+ var i;
157
+ return (i = t()) == null ? void 0 : i.observe(s, { box: "border-box" });
158
+ },
159
+ unobserve: (s) => {
160
+ var i;
161
+ return (i = t()) == null ? void 0 : i.unobserve(s);
162
+ }
163
+ };
164
+ })(), this.range = null, this.setOptions = (e) => {
165
+ Object.entries(e).forEach(([t, s]) => {
166
+ typeof s > "u" && delete e[t];
167
+ }), this.options = {
168
+ debug: !1,
169
+ initialOffset: 0,
170
+ overscan: 1,
171
+ paddingStart: 0,
172
+ paddingEnd: 0,
173
+ scrollPaddingStart: 0,
174
+ scrollPaddingEnd: 0,
175
+ horizontal: !1,
176
+ getItemKey: L,
177
+ rangeExtractor: j,
178
+ onChange: () => {
179
+ },
180
+ measureElement: $,
181
+ initialRect: { width: 0, height: 0 },
182
+ scrollMargin: 0,
183
+ gap: 0,
184
+ indexAttribute: "data-index",
185
+ initialMeasurementsCache: [],
186
+ lanes: 1,
187
+ isScrollingResetDelay: 150,
188
+ enabled: !0,
189
+ isRtl: !1,
190
+ useScrollendEvent: !1,
191
+ useAnimationFrameWithResizeObserver: !1,
192
+ ...e
193
+ };
194
+ }, this.notify = (e) => {
195
+ var t, s;
196
+ (s = (t = this.options).onChange) == null || s.call(t, this, e);
197
+ }, this.maybeNotify = b(
198
+ () => (this.calculateRange(), [
199
+ this.isScrolling,
200
+ this.range ? this.range.startIndex : null,
201
+ this.range ? this.range.endIndex : null
202
+ ]),
203
+ (e) => {
204
+ this.notify(e);
205
+ },
206
+ {
207
+ key: process.env.NODE_ENV !== "production" && "maybeNotify",
208
+ debug: () => this.options.debug,
209
+ initialDeps: [
210
+ this.isScrolling,
211
+ this.range ? this.range.startIndex : null,
212
+ this.range ? this.range.endIndex : null
213
+ ]
214
+ }
215
+ ), this.cleanup = () => {
216
+ this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
217
+ }, this._didMount = () => () => {
218
+ this.cleanup();
219
+ }, this._willUpdate = () => {
220
+ var e;
221
+ const t = this.options.enabled ? this.options.getScrollElement() : null;
222
+ if (this.scrollElement !== t) {
223
+ if (this.cleanup(), !t) {
224
+ this.maybeNotify();
225
+ return;
226
+ }
227
+ this.scrollElement = t, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((s) => {
228
+ this.observer.observe(s);
229
+ }), this._scrollToOffset(this.getScrollOffset(), {
230
+ adjustments: void 0,
231
+ behavior: void 0
232
+ }), this.unsubs.push(
233
+ this.options.observeElementRect(this, (s) => {
234
+ this.scrollRect = s, this.maybeNotify();
235
+ })
236
+ ), this.unsubs.push(
237
+ this.options.observeElementOffset(this, (s, i) => {
238
+ this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < s ? "forward" : "backward" : null, this.scrollOffset = s, this.isScrolling = i, this.maybeNotify();
239
+ })
240
+ );
241
+ }
242
+ }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, t) => {
243
+ const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
244
+ for (let n = t - 1; n >= 0; n--) {
245
+ const o = e[n];
246
+ if (s.has(o.lane))
247
+ continue;
248
+ const a = i.get(
249
+ o.lane
250
+ );
251
+ if (a == null || o.end > a.end ? i.set(o.lane, o) : o.end < a.end && s.set(o.lane, !0), s.size === this.options.lanes)
252
+ break;
253
+ }
254
+ return i.size === this.options.lanes ? Array.from(i.values()).sort((n, o) => n.end === o.end ? n.index - o.index : n.end - o.end)[0] : void 0;
255
+ }, this.getMeasurementOptions = b(
256
+ () => [
257
+ this.options.count,
258
+ this.options.paddingStart,
259
+ this.options.scrollMargin,
260
+ this.options.getItemKey,
261
+ this.options.enabled
262
+ ],
263
+ (e, t, s, i, n) => (this.pendingMeasuredCacheIndexes = [], {
264
+ count: e,
265
+ paddingStart: t,
266
+ scrollMargin: s,
267
+ getItemKey: i,
268
+ enabled: n
269
+ }),
270
+ {
271
+ key: !1
272
+ }
273
+ ), this.getMeasurements = b(
274
+ () => [this.getMeasurementOptions(), this.itemSizeCache],
275
+ ({ count: e, paddingStart: t, scrollMargin: s, getItemKey: i, enabled: n }, o) => {
276
+ if (!n)
277
+ return this.measurementsCache = [], this.itemSizeCache.clear(), [];
278
+ this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((h) => {
279
+ this.itemSizeCache.set(h.key, h.size);
280
+ }));
281
+ const a = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
282
+ this.pendingMeasuredCacheIndexes = [];
283
+ const c = this.measurementsCache.slice(0, a);
284
+ for (let h = a; h < e; h++) {
285
+ const u = i(h), d = this.options.lanes === 1 ? c[h - 1] : this.getFurthestMeasurement(c, h), g = d ? d.end + this.options.gap : t + s, m = o.get(u), p = typeof m == "number" ? m : this.options.estimateSize(h), E = g + p, x = d ? d.lane : h % this.options.lanes;
286
+ c[h] = {
287
+ index: h,
288
+ start: g,
289
+ size: p,
290
+ end: E,
291
+ key: u,
292
+ lane: x
293
+ };
294
+ }
295
+ return this.measurementsCache = c, c;
296
+ },
297
+ {
298
+ key: process.env.NODE_ENV !== "production" && "getMeasurements",
299
+ debug: () => this.options.debug
300
+ }
301
+ ), this.calculateRange = b(
302
+ () => [
303
+ this.getMeasurements(),
304
+ this.getSize(),
305
+ this.getScrollOffset(),
306
+ this.options.lanes
307
+ ],
308
+ (e, t, s, i) => this.range = e.length > 0 && t > 0 ? U({
309
+ measurements: e,
310
+ outerSize: t,
311
+ scrollOffset: s,
312
+ lanes: i
313
+ }) : null,
314
+ {
315
+ key: process.env.NODE_ENV !== "production" && "calculateRange",
316
+ debug: () => this.options.debug
317
+ }
318
+ ), this.getVirtualIndexes = b(
319
+ () => {
320
+ let e = null, t = null;
321
+ const s = this.calculateRange();
322
+ return s && (e = s.startIndex, t = s.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, t]), [
323
+ this.options.rangeExtractor,
324
+ this.options.overscan,
325
+ this.options.count,
326
+ e,
327
+ t
328
+ ];
329
+ },
330
+ (e, t, s, i, n) => i === null || n === null ? [] : e({
331
+ startIndex: i,
332
+ endIndex: n,
333
+ overscan: t,
334
+ count: s
335
+ }),
336
+ {
337
+ key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
338
+ debug: () => this.options.debug
339
+ }
340
+ ), this.indexFromElement = (e) => {
341
+ const t = this.options.indexAttribute, s = e.getAttribute(t);
342
+ return s ? parseInt(s, 10) : (console.warn(
343
+ `Missing attribute name '${t}={index}' on measured element.`
344
+ ), -1);
345
+ }, this._measureElement = (e, t) => {
346
+ const s = this.indexFromElement(e), i = this.measurementsCache[s];
347
+ if (!i)
348
+ return;
349
+ const n = i.key, o = this.elementsCache.get(n);
350
+ o !== e && (o && this.observer.unobserve(o), this.observer.observe(e), this.elementsCache.set(n, e)), e.isConnected && this.resizeItem(s, this.options.measureElement(e, t, this));
351
+ }, this.resizeItem = (e, t) => {
352
+ const s = this.measurementsCache[e];
353
+ if (!s)
354
+ return;
355
+ const i = this.itemSizeCache.get(s.key) ?? s.size, n = t - i;
356
+ n !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(s, n, this) : s.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", n), this._scrollToOffset(this.getScrollOffset(), {
357
+ adjustments: this.scrollAdjustments += n,
358
+ behavior: void 0
359
+ })), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, t)), this.notify(!1));
360
+ }, this.measureElement = (e) => {
361
+ if (!e) {
362
+ this.elementsCache.forEach((t, s) => {
363
+ t.isConnected || (this.observer.unobserve(t), this.elementsCache.delete(s));
364
+ });
365
+ return;
366
+ }
367
+ this._measureElement(e, void 0);
368
+ }, this.getVirtualItems = b(
369
+ () => [this.getVirtualIndexes(), this.getMeasurements()],
370
+ (e, t) => {
371
+ const s = [];
372
+ for (let i = 0, n = e.length; i < n; i++) {
373
+ const o = e[i], a = t[o];
374
+ s.push(a);
375
+ }
376
+ return s;
377
+ },
378
+ {
379
+ key: process.env.NODE_ENV !== "production" && "getVirtualItems",
380
+ debug: () => this.options.debug
381
+ }
382
+ ), this.getVirtualItemForOffset = (e) => {
383
+ const t = this.getMeasurements();
384
+ if (t.length !== 0)
385
+ return S(
386
+ t[I(
387
+ 0,
388
+ t.length - 1,
389
+ (s) => S(t[s]).start,
390
+ e
391
+ )]
392
+ );
393
+ }, this.getOffsetForAlignment = (e, t, s = 0) => {
394
+ const i = this.getSize(), n = this.getScrollOffset();
395
+ t === "auto" && (t = e >= n + i ? "end" : "start"), t === "center" ? e += (s - i) / 2 : t === "end" && (e -= i);
396
+ const o = this.getTotalSize() + this.options.scrollMargin - i;
397
+ return Math.max(Math.min(o, e), 0);
398
+ }, this.getOffsetForIndex = (e, t = "auto") => {
399
+ e = Math.max(0, Math.min(e, this.options.count - 1));
400
+ const s = this.measurementsCache[e];
401
+ if (!s)
402
+ return;
403
+ const i = this.getSize(), n = this.getScrollOffset();
404
+ if (t === "auto")
405
+ if (s.end >= n + i - this.options.scrollPaddingEnd)
406
+ t = "end";
407
+ else if (s.start <= n + this.options.scrollPaddingStart)
408
+ t = "start";
409
+ else
410
+ return [n, t];
411
+ const o = t === "end" ? s.end + this.options.scrollPaddingEnd : s.start - this.options.scrollPaddingStart;
412
+ return [
413
+ this.getOffsetForAlignment(o, t, s.size),
414
+ t
415
+ ];
416
+ }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: t = "start", behavior: s } = {}) => {
417
+ s === "smooth" && this.isDynamicMode() && console.warn(
418
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
419
+ ), this._scrollToOffset(this.getOffsetForAlignment(e, t), {
420
+ adjustments: void 0,
421
+ behavior: s
422
+ });
423
+ }, this.scrollToIndex = (e, { align: t = "auto", behavior: s } = {}) => {
424
+ s === "smooth" && this.isDynamicMode() && console.warn(
425
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
426
+ ), e = Math.max(0, Math.min(e, this.options.count - 1));
427
+ let i = 0;
428
+ const n = 10, o = (c) => {
429
+ if (!this.targetWindow) return;
430
+ const h = this.getOffsetForIndex(e, c);
431
+ if (!h) {
432
+ console.warn("Failed to get offset for index:", e);
433
+ return;
434
+ }
435
+ const [u, d] = h;
436
+ this._scrollToOffset(u, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
437
+ const g = this.getScrollOffset(), m = this.getOffsetForIndex(e, d);
438
+ if (!m) {
439
+ console.warn("Failed to get offset for index:", e);
440
+ return;
441
+ }
442
+ V(m[0], g) || a(d);
443
+ });
444
+ }, a = (c) => {
445
+ this.targetWindow && (i++, i < n ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, n), this.targetWindow.requestAnimationFrame(() => o(c))) : console.warn(
446
+ `Failed to scroll to index ${e} after ${n} attempts.`
447
+ ));
448
+ };
449
+ o(t);
450
+ }, this.scrollBy = (e, { behavior: t } = {}) => {
451
+ t === "smooth" && this.isDynamicMode() && console.warn(
452
+ "The `smooth` scroll behavior is not fully supported with dynamic size."
453
+ ), this._scrollToOffset(this.getScrollOffset() + e, {
454
+ adjustments: void 0,
455
+ behavior: t
456
+ });
457
+ }, this.getTotalSize = () => {
458
+ var e;
459
+ const t = this.getMeasurements();
460
+ let s;
461
+ if (t.length === 0)
462
+ s = this.options.paddingStart;
463
+ else if (this.options.lanes === 1)
464
+ s = ((e = t[t.length - 1]) == null ? void 0 : e.end) ?? 0;
465
+ else {
466
+ const i = Array(this.options.lanes).fill(null);
467
+ let n = t.length - 1;
468
+ for (; n >= 0 && i.some((o) => o === null); ) {
469
+ const o = t[n];
470
+ i[o.lane] === null && (i[o.lane] = o.end), n--;
471
+ }
472
+ s = Math.max(...i.filter((o) => o !== null));
473
+ }
474
+ return Math.max(
475
+ s - this.options.scrollMargin + this.options.paddingEnd,
476
+ 0
477
+ );
478
+ }, this._scrollToOffset = (e, {
479
+ adjustments: t,
480
+ behavior: s
481
+ }) => {
482
+ this.options.scrollToFn(e, { behavior: s, adjustments: t }, this);
483
+ }, this.measure = () => {
484
+ this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
485
+ }, this.setOptions(l);
486
+ }
487
+ }
488
+ const I = (r, l, e, t) => {
489
+ for (; r <= l; ) {
490
+ const s = (r + l) / 2 | 0, i = e(s);
491
+ if (i < t)
492
+ r = s + 1;
493
+ else if (i > t)
494
+ l = s - 1;
495
+ else
496
+ return s;
497
+ }
498
+ return r > 0 ? r - 1 : 0;
499
+ };
500
+ function U({
501
+ measurements: r,
502
+ outerSize: l,
503
+ scrollOffset: e,
504
+ lanes: t
505
+ }) {
506
+ const s = r.length - 1, i = (a) => r[a].start;
507
+ if (r.length <= t)
508
+ return {
509
+ startIndex: 0,
510
+ endIndex: s
511
+ };
512
+ let n = I(
513
+ 0,
514
+ s,
515
+ i,
516
+ e
517
+ ), o = n;
518
+ if (t === 1)
519
+ for (; o < s && r[o].end < e + l; )
520
+ o++;
521
+ else if (t > 1) {
522
+ const a = Array(t).fill(0);
523
+ for (; o < s && a.some((h) => h < e + l); ) {
524
+ const h = r[o];
525
+ a[h.lane] = h.end, o++;
526
+ }
527
+ const c = Array(t).fill(e + l);
528
+ for (; n >= 0 && c.some((h) => h >= e); ) {
529
+ const h = r[n];
530
+ c[h.lane] = h.start, n--;
531
+ }
532
+ n = Math.max(0, n - n % t), o = Math.min(s, o + (t - 1 - o % t));
533
+ }
534
+ return { startIndex: n, endIndex: o };
535
+ }
536
+ const C = typeof document < "u" ? y.useLayoutEffect : y.useEffect;
537
+ function K(r) {
538
+ const l = y.useReducer(() => ({}), {})[1], e = {
539
+ ...r,
540
+ onChange: (s, i) => {
541
+ var n;
542
+ i ? k(l) : l(), (n = r.onChange) == null || n.call(r, s, i);
543
+ }
544
+ }, [t] = y.useState(
545
+ () => new H(e)
546
+ );
547
+ return t.setOptions(e), C(() => t._didMount(), []), C(() => t._willUpdate()), t;
548
+ }
549
+ function G(r) {
550
+ return K({
551
+ observeElementRect: P,
552
+ observeElementOffset: B,
553
+ scrollToFn: q,
554
+ ...r
555
+ });
556
+ }
557
+ const te = ({
558
+ showFlagOnSearch: r,
559
+ showNameOnSearch: l
560
+ }) => {
561
+ const e = R(null), { termOfSearch: t, countries: s, handleSelectCountry: i } = A(), n = F(() => s.filter(
562
+ (a) => a.name.toLocaleLowerCase().includes(t.toLowerCase())
563
+ ), [t]), o = G({
564
+ count: n.length,
565
+ overscan: 5,
566
+ getScrollElement: () => e.current,
567
+ estimateSize: () => 40
568
+ });
569
+ return T(() => {
570
+ n.length > 0 && o.scrollToIndex(0);
571
+ }, [t, o]), n.length === 0 ? /* @__PURE__ */ f("div", { className: "overflow-y-auto max-h-60 snap-y snap-mandatory", children: /* @__PURE__ */ f("ul", { className: "relative", children: /* @__PURE__ */ f("li", { className: "w-full flex items-center h-10 select-none px-6", children: /* @__PURE__ */ f(
572
+ w,
573
+ {
574
+ variant: "body2",
575
+ component: "span",
576
+ className: "flex gap-2 items-center text-left text-slate-800 dark:text-slate-50",
577
+ children: "No options"
578
+ }
579
+ ) }) }) }) : /* @__PURE__ */ f(
580
+ "div",
581
+ {
582
+ ref: e,
583
+ className: "overflow-y-auto max-h-60 snap-y snap-mandatory",
584
+ children: /* @__PURE__ */ f(
585
+ "ul",
586
+ {
587
+ className: "relative",
588
+ style: { height: o.getTotalSize() },
589
+ children: o.getVirtualItems().map((a) => {
590
+ const c = n[a.index], { flag: h, name: u, prefix: d } = c;
591
+ return /* @__PURE__ */ f(
592
+ "li",
593
+ {
594
+ className: "absolute w-full snap-start snap-always scroll-m-0 flex items-center h-10",
595
+ style: {
596
+ top: a.start,
597
+ height: a.size
598
+ },
599
+ children: /* @__PURE__ */ f(
600
+ "button",
601
+ {
602
+ className: "w-full h-full cursor-pointer px-6 hover:bg-gray-50 transition-colors duration-150 focus-visible:outline-0 hover:outline-gray-100 focus:bg-gray-50 dark:hover:bg-slate-700",
603
+ onClick: () => i(c),
604
+ children: /* @__PURE__ */ N(
605
+ w,
606
+ {
607
+ variant: "body2",
608
+ component: "span",
609
+ className: "flex gap-2 items-center text-left text-slate-800 dark:text-slate-50",
610
+ children: [
611
+ r && /* @__PURE__ */ f(h, {}),
612
+ l && /* @__PURE__ */ f(D, { text: u, prefix: d })
613
+ ]
614
+ }
615
+ )
616
+ }
617
+ )
618
+ },
619
+ a.key
620
+ );
621
+ })
622
+ }
623
+ )
624
+ }
625
+ );
626
+ };
627
+ export {
628
+ te as FlagSelectorList
629
+ };
@@ -0,0 +1,36 @@
1
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
+ import { useCallback as d } from "react";
3
+ import { Input as p } from "../../../Input/Input.js";
4
+ import { FlagSelectorList as c } from "../FlagSelectorList/FlagSelectorList.js";
5
+ import { usePhoneNumberContext as u } from "../../contexts/phone-number.hook.js";
6
+ const S = ({
7
+ placeholder: r = "Search",
8
+ showFlagOnSearch: o,
9
+ showInputFilter: t,
10
+ showNameOnSearch: a,
11
+ showPlaceHolder: s = !0
12
+ }) => {
13
+ const { onChangeTermOfSearch: l } = u(), n = d((m) => {
14
+ l(m.target.value);
15
+ }, []);
16
+ return /* @__PURE__ */ i("div", { className: "absolute top-full mt-1.5 animate-in fade-in-0 zoom-in-95 w-full border border-transparent bg-white shadow-sm py-2 z-10 rounded-sm dark:bg-slate-800 dark:border-slate-600", children: [
17
+ t && /* @__PURE__ */ e("div", { className: "px-6 py-2.5", children: /* @__PURE__ */ e(
18
+ p,
19
+ {
20
+ isSearch: !0,
21
+ placeholder: s ? r : void 0,
22
+ onChange: n
23
+ }
24
+ ) }),
25
+ /* @__PURE__ */ e(
26
+ c,
27
+ {
28
+ showFlagOnSearch: o,
29
+ showNameOnSearch: a
30
+ }
31
+ )
32
+ ] });
33
+ };
34
+ export {
35
+ S as FlagSelectorWrapper
36
+ };