@konstructio/ui 0.1.2-alpha.28 → 0.1.2-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chevron-up-DrQr2Fwd.js +5 -0
- package/dist/components/Badge/Badge.variants.js +1 -1
- package/dist/components/Datepicker/DatePicker.js +124 -124
- package/dist/components/Divider/Divider.variants.js +1 -1
- package/dist/components/Dropdown/components/List/List.js +45 -39
- package/dist/components/Dropdown/components/Wrapper.js +81 -80
- package/dist/components/Dropdown/hooks/useDropdown.js +21 -21
- package/dist/components/Filter/Filter.variants.js +2 -2
- package/dist/components/Input/Input.variants.js +1 -1
- package/dist/components/PhoneNumberInput/PhoneNumberInput.js +8 -0
- package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +45 -0
- package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +27 -0
- package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +629 -0
- package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +27 -0
- package/dist/components/PhoneNumberInput/components/TruncateText/TruncateText.js +45 -0
- package/dist/components/PhoneNumberInput/components/Wrapper.js +621 -0
- package/dist/components/PhoneNumberInput/components/index.js +6 -0
- package/dist/components/PhoneNumberInput/contexts/index.js +8 -0
- package/dist/components/PhoneNumberInput/contexts/phone-number.context.js +28 -0
- package/dist/components/PhoneNumberInput/contexts/phone-number.hook.js +13 -0
- package/dist/components/PhoneNumberInput/contexts/phone-number.provider.js +6137 -0
- package/dist/components/PhoneNumberInput/utils/index.js +11 -0
- package/dist/components/Sidebar/Sidebar.variants.js +2 -2
- package/dist/components/Switch/Switch.variants.js +4 -4
- package/dist/components/Tabs/Tabs.variants.js +1 -1
- package/dist/components/TimePicker/TimePicker.variants.js +2 -2
- package/dist/components/TimePicker/components/Wrapper/Wrapper.js +1 -1
- package/dist/components/Typography/Typography.variants.js +18 -23
- package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +1 -1
- package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +5 -5
- package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +22 -1886
- package/dist/components/index.js +72 -70
- package/dist/index-2hB40Iuc.js +1873 -0
- package/dist/index-C3tHPg8y.js +662 -0
- package/dist/index.d.ts +32 -13
- package/dist/index.js +82 -80
- package/dist/libphonenumber-_7ZyKWA7.js +11549 -0
- package/dist/package.json +7 -1
- package/dist/styles.css +1 -1
- package/package.json +7 -1
|
@@ -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
|
+
showNameOnSearch: r,
|
|
559
|
+
showFlagOnSearch: 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
|
+
l && /* @__PURE__ */ f(h, {}),
|
|
612
|
+
r && /* @__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
|
+
};
|
package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as m } from "react";
|
|
3
|
+
import { Input as i } from "../../../Input/Input.js";
|
|
4
|
+
import { FlagSelectorList as p } from "../FlagSelectorList/FlagSelectorList.js";
|
|
5
|
+
import { usePhoneNumberContext as c } from "../../contexts/phone-number.hook.js";
|
|
6
|
+
const g = ({
|
|
7
|
+
showInputFilter: r,
|
|
8
|
+
showNameOnSearch: o,
|
|
9
|
+
showFlagOnSearch: a
|
|
10
|
+
}) => {
|
|
11
|
+
const { onChangeTermOfSearch: t } = c(), s = m((l) => {
|
|
12
|
+
t(l.target.value);
|
|
13
|
+
}, []);
|
|
14
|
+
return /* @__PURE__ */ n("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: [
|
|
15
|
+
r && /* @__PURE__ */ e("div", { className: "px-6 py-2.5", children: /* @__PURE__ */ e(i, { isSearch: !0, placeholder: "Search", onChange: s }) }),
|
|
16
|
+
/* @__PURE__ */ e(
|
|
17
|
+
p,
|
|
18
|
+
{
|
|
19
|
+
showNameOnSearch: o,
|
|
20
|
+
showFlagOnSearch: a
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
g as FlagSelectorWrapper
|
|
27
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { P as f, R as u, T as b, C as m } from "../../../../index-2hB40Iuc.js";
|
|
3
|
+
import { d as h } from "../../../../debounce-BFejQm9P.js";
|
|
4
|
+
import { useRef as p, useState as w, useCallback as g, useEffect as i } from "react";
|
|
5
|
+
const C = ({ text: r, prefix: n }) => {
|
|
6
|
+
const s = p(null), [c, d] = w(!1), t = g(() => {
|
|
7
|
+
const e = s.current;
|
|
8
|
+
e && d(e.scrollWidth > e.clientWidth);
|
|
9
|
+
}, []);
|
|
10
|
+
return i(() => {
|
|
11
|
+
const e = new AbortController(), l = h(t, 300);
|
|
12
|
+
return window.addEventListener("resize", l, {
|
|
13
|
+
signal: e.signal
|
|
14
|
+
}), () => {
|
|
15
|
+
e.abort(), l.cancel();
|
|
16
|
+
};
|
|
17
|
+
}, [t]), i(() => {
|
|
18
|
+
t();
|
|
19
|
+
}, [r, t]), c ? /* @__PURE__ */ o(f, { delayDuration: 0, children: /* @__PURE__ */ a(u, { children: [
|
|
20
|
+
/* @__PURE__ */ o(b, { asChild: !0, children: /* @__PURE__ */ a("span", { ref: s, className: "w-full truncate cursor-pointer", children: [
|
|
21
|
+
r,
|
|
22
|
+
" ",
|
|
23
|
+
n
|
|
24
|
+
] }) }),
|
|
25
|
+
/* @__PURE__ */ a(
|
|
26
|
+
m,
|
|
27
|
+
{
|
|
28
|
+
side: "top",
|
|
29
|
+
align: "center",
|
|
30
|
+
className: "animate-in fade-in-0 relative mb-1.5 overflow-visible bg-kubefirst-dark-blue-900 text-white px-3 py-2 rounded-lg shadow-sm after:content-[''] after:absolute after:left-1/2 after:-translate-x-1/2 after:bottom-0 after:translate-y-full after:border-l-8 after:border-l-transparent after:border-r-8 after:border-r-transparent after:border-t-8 after:border-kubefirst-dark-blue-900 z-999",
|
|
31
|
+
children: [
|
|
32
|
+
r,
|
|
33
|
+
" ",
|
|
34
|
+
n
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
] }) }) : /* @__PURE__ */ a("span", { ref: s, className: "w-full truncate", children: [
|
|
39
|
+
r,
|
|
40
|
+
/* @__PURE__ */ o("span", { className: "text-slate-500", children: n })
|
|
41
|
+
] });
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
C as TruncateText
|
|
45
|
+
};
|