@konstructio/ui 0.1.2-alpha.40 → 0.1.2-alpha.43

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