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

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 (103) hide show
  1. package/dist/{Modal-V67Uz78z.js → Modal-D-NOEWMX.js} +3 -3
  2. package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
  3. package/dist/{chevron-down-BLZPftpV.js → chevron-down-MZvQoT2F.js} +2 -2
  4. package/dist/chevron-right-VYBOBhRt.js +19 -0
  5. package/dist/components/Alert/Alert.js +2 -2
  6. package/dist/components/AlertDialog/AlertDialog.js +1 -1
  7. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
  8. package/dist/components/AlertDialog/components/index.js +1 -1
  9. package/dist/components/Badge/Badge.js +2 -2
  10. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  11. package/dist/components/Breadcrumb/components/Item/Item.js +16 -15
  12. package/dist/components/Checkbox/Checkbox.js +5 -4
  13. package/dist/components/Command/Command.js +2 -2
  14. package/dist/components/Command/components/Command.js +1 -1
  15. package/dist/components/Command/components/CommandEmpty.js +1 -1
  16. package/dist/components/Command/components/CommandGroup.js +1 -1
  17. package/dist/components/Command/components/CommandInput.js +2 -2
  18. package/dist/components/Command/components/CommandItem.js +1 -1
  19. package/dist/components/Command/components/CommandList.js +1 -1
  20. package/dist/components/Command/components/CommandSeparator.js +1 -1
  21. package/dist/components/Command/components/DialogContent.js +2 -2
  22. package/dist/components/Command/components/DialogOverlay.js +1 -1
  23. package/dist/components/Datepicker/DatePicker.js +545 -543
  24. package/dist/components/Dropdown/Dropdown.js +36 -24
  25. package/dist/components/Dropdown/Dropdown.variants.js +25 -7
  26. package/dist/components/Dropdown/components/List/List.js +59 -44
  27. package/dist/components/Dropdown/components/List/List.variants.js +9 -7
  28. package/dist/components/Dropdown/components/ListItem/ListItem.js +48 -24
  29. package/dist/components/Dropdown/components/ListItem/ListItem.variants.js +9 -7
  30. package/dist/components/Dropdown/components/Wrapper.js +141 -106
  31. package/dist/components/Dropdown/contexts/dropdown.context.js +9 -8
  32. package/dist/components/Dropdown/contexts/dropdown.provider.js +20 -19
  33. package/dist/components/Dropdown/hooks/useDropdown.js +26 -27
  34. package/dist/components/Dropdown/hooks/useNavigationList.js +32 -28
  35. package/dist/components/DropdownButton/DropdownButton.js +1 -1
  36. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +1 -1
  37. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +1 -1
  38. package/dist/components/Input/Input.js +1 -1
  39. package/dist/components/Loading/Loading.js +2 -2
  40. package/dist/components/Modal/Modal.js +2 -2
  41. package/dist/components/Modal/components/Wrapper/Wrapper.js +3 -3
  42. package/dist/components/Modal/components/index.js +1 -1
  43. package/dist/components/NumberInput/NumberInput.js +2 -2
  44. package/dist/components/PieChart/PieChart.js +217 -215
  45. package/dist/components/Range/Range.js +1 -1
  46. package/dist/components/Sidebar/components/Wrapper/Wrapper.js +29 -28
  47. package/dist/components/Slider/Slider.js +1 -1
  48. package/dist/components/Switch/Switch.js +6 -5
  49. package/dist/components/Tabs/Tabs.js +1 -1
  50. package/dist/components/Tabs/Tabs.variants.js +45 -24
  51. package/dist/components/Tabs/components/Content.js +1 -1
  52. package/dist/components/Tabs/components/List.js +1 -1
  53. package/dist/components/Tabs/components/Trigger.js +9 -8
  54. package/dist/components/TagSelect/components/Wrapper/Wrapper.js +98 -49
  55. package/dist/components/TimePicker/components/Wrapper/Wrapper.js +1 -1
  56. package/dist/components/Toast/Toast.js +8 -7
  57. package/dist/components/VirtualizedTable/VirtualizedTable.js +99 -0
  58. package/dist/components/VirtualizedTable/VirtualizedTable.variants.js +5 -0
  59. package/dist/components/VirtualizedTable/assets/chevron-down.js +25 -0
  60. package/dist/components/VirtualizedTable/assets/chevron-up.js +25 -0
  61. package/dist/components/VirtualizedTable/assets/index.js +6 -0
  62. package/dist/components/VirtualizedTable/components/Actions/Actions.js +46 -0
  63. package/dist/components/VirtualizedTable/components/Body/Body.js +25 -0
  64. package/dist/components/VirtualizedTable/components/DotPaginate/DotPaginate.js +165 -0
  65. package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +34 -0
  66. package/dist/components/VirtualizedTable/components/Filter/Filter.js +73 -0
  67. package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +48 -0
  68. package/dist/components/VirtualizedTable/components/Header/Header.js +82 -0
  69. package/dist/components/VirtualizedTable/components/Pagination/Pagination.js +45 -0
  70. package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +1870 -0
  71. package/dist/components/VirtualizedTable/components/index.js +14 -0
  72. package/dist/components/VirtualizedTable/constants/index.js +5 -0
  73. package/dist/components/VirtualizedTable/constants/pagination.js +5 -0
  74. package/dist/components/VirtualizedTable/contexts/index.js +8 -0
  75. package/dist/components/VirtualizedTable/contexts/table.context.js +31 -0
  76. package/dist/components/VirtualizedTable/contexts/table.hook.js +11 -0
  77. package/dist/components/VirtualizedTable/contexts/table.provider.js +778 -0
  78. package/dist/components/index.js +44 -40
  79. package/dist/{createLucideIcon-DbC6TvM5.js → createLucideIcon-D2CN7Ma9.js} +4 -4
  80. package/dist/debounce-BFejQm9P.js +200 -0
  81. package/dist/{index-D3xzCzcO.js → index-B7t8D14s.js} +2 -2
  82. package/dist/index-BAEWsOG1.js +27 -0
  83. package/dist/{index-C9T9HQaa.js → index-BITvcJAz.js} +1 -1
  84. package/dist/index-BZPx6jYI.js +8 -0
  85. package/dist/{index-BAraV3ai.js → index-Bnb0ezr3.js} +1 -1
  86. package/dist/{index-DB2XhXHn.js → index-C84F4YyO.js} +11 -10
  87. package/dist/index-Cd2vhaop.js +137 -0
  88. package/dist/{index-iXyXtdgP.js → index-DBbEcSUG.js} +1 -1
  89. package/dist/index-Dx2grAuN.js +1742 -0
  90. package/dist/{index-BXuxPoz7.js → index-DzIBBMjs.js} +18 -17
  91. package/dist/{index-h-Ul0anl.js → index-N2OStZoU.js} +1 -1
  92. package/dist/{index-Oq5GlCHP.js → index-os7vysFS.js} +1 -1
  93. package/dist/index-ti1b9kqV.js +14 -0
  94. package/dist/index.d.ts +94 -5
  95. package/dist/index.js +41 -37
  96. package/dist/package.json +26 -22
  97. package/dist/styles.css +1 -1
  98. package/dist/{x-BPcqkRZd.js → x-4F_5p77m.js} +1 -1
  99. package/package.json +26 -22
  100. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  101. package/dist/chevron-up-RLP4nX7V.js +0 -54
  102. package/dist/index-CZnD2QxM.js +0 -32
  103. package/dist/index-CrBonFvu.js +0 -144
@@ -0,0 +1,778 @@
1
+ import { jsx as ee } from "react/jsx-runtime";
2
+ import * as b from "react";
3
+ import { useState as w, useMemo as te, useCallback as _ } from "react";
4
+ import { u as se, g as re, a as ie } from "../../../index-Dx2grAuN.js";
5
+ import { TableContext as ne } from "./table.context.js";
6
+ import { DEFAULT_PAGE_SIZE as oe } from "../constants/pagination.js";
7
+ var k = class {
8
+ constructor() {
9
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
10
+ }
11
+ subscribe(e) {
12
+ return this.listeners.add(e), this.onSubscribe(), () => {
13
+ this.listeners.delete(e), this.onUnsubscribe();
14
+ };
15
+ }
16
+ hasListeners() {
17
+ return this.listeners.size > 0;
18
+ }
19
+ onSubscribe() {
20
+ }
21
+ onUnsubscribe() {
22
+ }
23
+ }, ae = {
24
+ // We need the wrapper function syntax below instead of direct references to
25
+ // global setTimeout etc.
26
+ //
27
+ // BAD: `setTimeout: setTimeout`
28
+ // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
29
+ //
30
+ // If we use direct references here, then anything that wants to spy on or
31
+ // replace the global setTimeout (like tests) won't work since we'll already
32
+ // have a hard reference to the original implementation at the time when this
33
+ // file was imported.
34
+ setTimeout: (e, t) => setTimeout(e, t),
35
+ clearTimeout: (e) => clearTimeout(e),
36
+ setInterval: (e, t) => setInterval(e, t),
37
+ clearInterval: (e) => clearInterval(e)
38
+ }, ce = class {
39
+ // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
40
+ // type at app boot; and if we leave that type, then any new timer provider
41
+ // would need to support ReturnType<typeof setTimeout>, which is infeasible.
42
+ //
43
+ // We settle for type safety for the TimeoutProvider type, and accept that
44
+ // this class is unsafe internally to allow for extension.
45
+ #t = ae;
46
+ #e = !1;
47
+ setTimeoutProvider(e) {
48
+ process.env.NODE_ENV !== "production" && this.#e && e !== this.#t && console.error(
49
+ "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
50
+ { previous: this.#t, provider: e }
51
+ ), this.#t = e, process.env.NODE_ENV !== "production" && (this.#e = !1);
52
+ }
53
+ setTimeout(e, t) {
54
+ return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setTimeout(e, t);
55
+ }
56
+ clearTimeout(e) {
57
+ this.#t.clearTimeout(e);
58
+ }
59
+ setInterval(e, t) {
60
+ return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setInterval(e, t);
61
+ }
62
+ clearInterval(e) {
63
+ this.#t.clearInterval(e);
64
+ }
65
+ }, N = new ce();
66
+ function ue(e) {
67
+ setTimeout(e, 0);
68
+ }
69
+ var F = typeof window > "u" || "Deno" in globalThis;
70
+ function Q() {
71
+ }
72
+ function z(e) {
73
+ return typeof e == "number" && e >= 0 && e !== 1 / 0;
74
+ }
75
+ function he(e, t) {
76
+ return Math.max(e + (t || 0) - Date.now(), 0);
77
+ }
78
+ function T(e, t) {
79
+ return typeof e == "function" ? e(t) : e;
80
+ }
81
+ function g(e, t) {
82
+ return typeof e == "function" ? e(t) : e;
83
+ }
84
+ var le = Object.prototype.hasOwnProperty;
85
+ function j(e, t) {
86
+ if (e === t)
87
+ return e;
88
+ const s = V(e) && V(t);
89
+ if (!s && !(B(e) && B(t))) return t;
90
+ const r = (s ? e : Object.keys(e)).length, h = s ? t : Object.keys(t), n = h.length, o = s ? new Array(n) : {};
91
+ let a = 0;
92
+ for (let l = 0; l < n; l++) {
93
+ const c = s ? l : h[l], f = e[c], u = t[c];
94
+ if (f === u) {
95
+ o[c] = f, (s ? l < r : le.call(e, c)) && a++;
96
+ continue;
97
+ }
98
+ if (f === null || u === null || typeof f != "object" || typeof u != "object") {
99
+ o[c] = u;
100
+ continue;
101
+ }
102
+ const O = j(f, u);
103
+ o[c] = O, O === f && a++;
104
+ }
105
+ return r === n && a === r ? e : o;
106
+ }
107
+ function D(e, t) {
108
+ if (!t || Object.keys(e).length !== Object.keys(t).length)
109
+ return !1;
110
+ for (const s in e)
111
+ if (e[s] !== t[s])
112
+ return !1;
113
+ return !0;
114
+ }
115
+ function V(e) {
116
+ return Array.isArray(e) && e.length === Object.keys(e).length;
117
+ }
118
+ function B(e) {
119
+ if (!H(e))
120
+ return !1;
121
+ const t = e.constructor;
122
+ if (t === void 0)
123
+ return !0;
124
+ const s = t.prototype;
125
+ return !(!H(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
126
+ }
127
+ function H(e) {
128
+ return Object.prototype.toString.call(e) === "[object Object]";
129
+ }
130
+ function W(e, t, s) {
131
+ if (typeof s.structuralSharing == "function")
132
+ return s.structuralSharing(e, t);
133
+ if (s.structuralSharing !== !1) {
134
+ if (process.env.NODE_ENV !== "production")
135
+ try {
136
+ return j(e, t);
137
+ } catch (i) {
138
+ throw console.error(
139
+ `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${i}`
140
+ ), i;
141
+ }
142
+ return j(e, t);
143
+ }
144
+ return t;
145
+ }
146
+ function fe(e, t) {
147
+ return typeof e == "function" ? e(...t) : !!e;
148
+ }
149
+ var de = class extends k {
150
+ #t;
151
+ #e;
152
+ #r;
153
+ constructor() {
154
+ super(), this.#r = (e) => {
155
+ if (!F && window.addEventListener) {
156
+ const t = () => e();
157
+ return window.addEventListener("visibilitychange", t, !1), () => {
158
+ window.removeEventListener("visibilitychange", t);
159
+ };
160
+ }
161
+ };
162
+ }
163
+ onSubscribe() {
164
+ this.#e || this.setEventListener(this.#r);
165
+ }
166
+ onUnsubscribe() {
167
+ this.hasListeners() || (this.#e?.(), this.#e = void 0);
168
+ }
169
+ setEventListener(e) {
170
+ this.#r = e, this.#e?.(), this.#e = e((t) => {
171
+ typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
172
+ });
173
+ }
174
+ setFocused(e) {
175
+ this.#t !== e && (this.#t = e, this.onFocus());
176
+ }
177
+ onFocus() {
178
+ const e = this.isFocused();
179
+ this.listeners.forEach((t) => {
180
+ t(e);
181
+ });
182
+ }
183
+ isFocused() {
184
+ return typeof this.#t == "boolean" ? this.#t : globalThis.document?.visibilityState !== "hidden";
185
+ }
186
+ }, pe = new de();
187
+ function J() {
188
+ let e, t;
189
+ const s = new Promise((r, h) => {
190
+ e = r, t = h;
191
+ });
192
+ s.status = "pending", s.catch(() => {
193
+ });
194
+ function i(r) {
195
+ Object.assign(s, r), delete s.resolve, delete s.reject;
196
+ }
197
+ return s.resolve = (r) => {
198
+ i({
199
+ status: "fulfilled",
200
+ value: r
201
+ }), e(r);
202
+ }, s.reject = (r) => {
203
+ i({
204
+ status: "rejected",
205
+ reason: r
206
+ }), t(r);
207
+ }, s;
208
+ }
209
+ var ye = ue;
210
+ function ge() {
211
+ let e = [], t = 0, s = (o) => {
212
+ o();
213
+ }, i = (o) => {
214
+ o();
215
+ }, r = ye;
216
+ const h = (o) => {
217
+ t ? e.push(o) : r(() => {
218
+ s(o);
219
+ });
220
+ }, n = () => {
221
+ const o = e;
222
+ e = [], o.length && r(() => {
223
+ i(() => {
224
+ o.forEach((a) => {
225
+ s(a);
226
+ });
227
+ });
228
+ });
229
+ };
230
+ return {
231
+ batch: (o) => {
232
+ let a;
233
+ t++;
234
+ try {
235
+ a = o();
236
+ } finally {
237
+ t--, t || n();
238
+ }
239
+ return a;
240
+ },
241
+ /**
242
+ * All calls to the wrapped function will be batched.
243
+ */
244
+ batchCalls: (o) => (...a) => {
245
+ h(() => {
246
+ o(...a);
247
+ });
248
+ },
249
+ schedule: h,
250
+ /**
251
+ * Use this method to set a custom notify function.
252
+ * This can be used to for example wrap notifications with `React.act` while running tests.
253
+ */
254
+ setNotifyFunction: (o) => {
255
+ s = o;
256
+ },
257
+ /**
258
+ * Use this method to set a custom function to batch notifications together into a single tick.
259
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
260
+ */
261
+ setBatchNotifyFunction: (o) => {
262
+ i = o;
263
+ },
264
+ setScheduler: (o) => {
265
+ r = o;
266
+ }
267
+ };
268
+ }
269
+ var G = ge(), be = class extends k {
270
+ #t = !0;
271
+ #e;
272
+ #r;
273
+ constructor() {
274
+ super(), this.#r = (e) => {
275
+ if (!F && window.addEventListener) {
276
+ const t = () => e(!0), s = () => e(!1);
277
+ return window.addEventListener("online", t, !1), window.addEventListener("offline", s, !1), () => {
278
+ window.removeEventListener("online", t), window.removeEventListener("offline", s);
279
+ };
280
+ }
281
+ };
282
+ }
283
+ onSubscribe() {
284
+ this.#e || this.setEventListener(this.#r);
285
+ }
286
+ onUnsubscribe() {
287
+ this.hasListeners() || (this.#e?.(), this.#e = void 0);
288
+ }
289
+ setEventListener(e) {
290
+ this.#r = e, this.#e?.(), this.#e = e(this.setOnline.bind(this));
291
+ }
292
+ setOnline(e) {
293
+ this.#t !== e && (this.#t = e, this.listeners.forEach((s) => {
294
+ s(e);
295
+ }));
296
+ }
297
+ isOnline() {
298
+ return this.#t;
299
+ }
300
+ }, ve = new be();
301
+ function me(e) {
302
+ return (e ?? "online") === "online" ? ve.isOnline() : !0;
303
+ }
304
+ function Se(e, t) {
305
+ return {
306
+ fetchFailureCount: 0,
307
+ fetchFailureReason: null,
308
+ fetchStatus: me(t.networkMode) ? "fetching" : "paused",
309
+ ...e === void 0 && {
310
+ error: null,
311
+ status: "pending"
312
+ }
313
+ };
314
+ }
315
+ var Oe = class extends k {
316
+ constructor(e, t) {
317
+ super(), this.options = t, this.#t = e, this.#n = null, this.#i = J(), this.bindMethods(), this.setOptions(t);
318
+ }
319
+ #t;
320
+ #e = void 0;
321
+ #r = void 0;
322
+ #s = void 0;
323
+ #a;
324
+ #l;
325
+ #i;
326
+ #n;
327
+ #y;
328
+ #f;
329
+ // This property keeps track of the last query with defined data.
330
+ // It will be used to pass the previous data and query to the placeholder function between renders.
331
+ #d;
332
+ #c;
333
+ #u;
334
+ #o;
335
+ #p = /* @__PURE__ */ new Set();
336
+ bindMethods() {
337
+ this.refetch = this.refetch.bind(this);
338
+ }
339
+ onSubscribe() {
340
+ this.listeners.size === 1 && (this.#e.addObserver(this), K(this.#e, this.options) ? this.#h() : this.updateResult(), this.#m());
341
+ }
342
+ onUnsubscribe() {
343
+ this.hasListeners() || this.destroy();
344
+ }
345
+ shouldFetchOnReconnect() {
346
+ return U(
347
+ this.#e,
348
+ this.options,
349
+ this.options.refetchOnReconnect
350
+ );
351
+ }
352
+ shouldFetchOnWindowFocus() {
353
+ return U(
354
+ this.#e,
355
+ this.options,
356
+ this.options.refetchOnWindowFocus
357
+ );
358
+ }
359
+ destroy() {
360
+ this.listeners = /* @__PURE__ */ new Set(), this.#S(), this.#O(), this.#e.removeObserver(this);
361
+ }
362
+ setOptions(e) {
363
+ const t = this.options, s = this.#e;
364
+ if (this.options = this.#t.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof g(this.options.enabled, this.#e) != "boolean")
365
+ throw new Error(
366
+ "Expected enabled to be a boolean or a callback that returns a boolean"
367
+ );
368
+ this.#R(), this.#e.setOptions(this.options), t._defaulted && !D(this.options, t) && this.#t.getQueryCache().notify({
369
+ type: "observerOptionsUpdated",
370
+ query: this.#e,
371
+ observer: this
372
+ });
373
+ const i = this.hasListeners();
374
+ i && $(
375
+ this.#e,
376
+ s,
377
+ this.options,
378
+ t
379
+ ) && this.#h(), this.updateResult(), i && (this.#e !== s || g(this.options.enabled, this.#e) !== g(t.enabled, this.#e) || T(this.options.staleTime, this.#e) !== T(t.staleTime, this.#e)) && this.#g();
380
+ const r = this.#b();
381
+ i && (this.#e !== s || g(this.options.enabled, this.#e) !== g(t.enabled, this.#e) || r !== this.#o) && this.#v(r);
382
+ }
383
+ getOptimisticResult(e) {
384
+ const t = this.#t.getQueryCache().build(this.#t, e), s = this.createResult(t, e);
385
+ return Ee(this, s) && (this.#s = s, this.#l = this.options, this.#a = this.#e.state), s;
386
+ }
387
+ getCurrentResult() {
388
+ return this.#s;
389
+ }
390
+ trackResult(e, t) {
391
+ return new Proxy(e, {
392
+ get: (s, i) => (this.trackProp(i), t?.(i), i === "promise" && !this.options.experimental_prefetchInRender && this.#i.status === "pending" && this.#i.reject(
393
+ new Error(
394
+ "experimental_prefetchInRender feature flag is not enabled"
395
+ )
396
+ ), Reflect.get(s, i))
397
+ });
398
+ }
399
+ trackProp(e) {
400
+ this.#p.add(e);
401
+ }
402
+ getCurrentQuery() {
403
+ return this.#e;
404
+ }
405
+ refetch({ ...e } = {}) {
406
+ return this.fetch({
407
+ ...e
408
+ });
409
+ }
410
+ fetchOptimistic(e) {
411
+ const t = this.#t.defaultQueryOptions(e), s = this.#t.getQueryCache().build(this.#t, t);
412
+ return s.fetch().then(() => this.createResult(s, t));
413
+ }
414
+ fetch(e) {
415
+ return this.#h({
416
+ ...e,
417
+ cancelRefetch: e.cancelRefetch ?? !0
418
+ }).then(() => (this.updateResult(), this.#s));
419
+ }
420
+ #h(e) {
421
+ this.#R();
422
+ let t = this.#e.fetch(
423
+ this.options,
424
+ e
425
+ );
426
+ return e?.throwOnError || (t = t.catch(Q)), t;
427
+ }
428
+ #g() {
429
+ this.#S();
430
+ const e = T(
431
+ this.options.staleTime,
432
+ this.#e
433
+ );
434
+ if (F || this.#s.isStale || !z(e))
435
+ return;
436
+ const s = he(this.#s.dataUpdatedAt, e) + 1;
437
+ this.#c = N.setTimeout(() => {
438
+ this.#s.isStale || this.updateResult();
439
+ }, s);
440
+ }
441
+ #b() {
442
+ return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
443
+ }
444
+ #v(e) {
445
+ this.#O(), this.#o = e, !(F || g(this.options.enabled, this.#e) === !1 || !z(this.#o) || this.#o === 0) && (this.#u = N.setInterval(() => {
446
+ (this.options.refetchIntervalInBackground || pe.isFocused()) && this.#h();
447
+ }, this.#o));
448
+ }
449
+ #m() {
450
+ this.#g(), this.#v(this.#b());
451
+ }
452
+ #S() {
453
+ this.#c && (N.clearTimeout(this.#c), this.#c = void 0);
454
+ }
455
+ #O() {
456
+ this.#u && (N.clearInterval(this.#u), this.#u = void 0);
457
+ }
458
+ createResult(e, t) {
459
+ const s = this.#e, i = this.options, r = this.#s, h = this.#a, n = this.#l, a = e !== s ? e.state : this.#r, { state: l } = e;
460
+ let c = { ...l }, f = !1, u;
461
+ if (t._optimisticResults) {
462
+ const d = this.hasListeners(), E = !d && K(e, t), S = d && $(e, s, t, i);
463
+ (E || S) && (c = {
464
+ ...c,
465
+ ...Se(l.data, e.options)
466
+ }), t._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
467
+ }
468
+ let { error: O, errorUpdatedAt: R, status: v } = c;
469
+ u = c.data;
470
+ let M = !1;
471
+ if (t.placeholderData !== void 0 && u === void 0 && v === "pending") {
472
+ let d;
473
+ r?.isPlaceholderData && t.placeholderData === n?.placeholderData ? (d = r.data, M = !0) : d = typeof t.placeholderData == "function" ? t.placeholderData(
474
+ this.#d?.state.data,
475
+ this.#d
476
+ ) : t.placeholderData, d !== void 0 && (v = "success", u = W(
477
+ r?.data,
478
+ d,
479
+ t
480
+ ), f = !0);
481
+ }
482
+ if (t.select && u !== void 0 && !M)
483
+ if (r && u === h?.data && t.select === this.#y)
484
+ u = this.#f;
485
+ else
486
+ try {
487
+ this.#y = t.select, u = t.select(u), u = W(r?.data, u, t), this.#f = u, this.#n = null;
488
+ } catch (d) {
489
+ this.#n = d;
490
+ }
491
+ this.#n && (O = this.#n, u = this.#f, R = Date.now(), v = "error");
492
+ const m = c.fetchStatus === "fetching", C = v === "pending", I = v === "error", P = C && m, x = u !== void 0, y = {
493
+ status: v,
494
+ fetchStatus: c.fetchStatus,
495
+ isPending: C,
496
+ isSuccess: v === "success",
497
+ isError: I,
498
+ isInitialLoading: P,
499
+ isLoading: P,
500
+ data: u,
501
+ dataUpdatedAt: c.dataUpdatedAt,
502
+ error: O,
503
+ errorUpdatedAt: R,
504
+ failureCount: c.fetchFailureCount,
505
+ failureReason: c.fetchFailureReason,
506
+ errorUpdateCount: c.errorUpdateCount,
507
+ isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
508
+ isFetchedAfterMount: c.dataUpdateCount > a.dataUpdateCount || c.errorUpdateCount > a.errorUpdateCount,
509
+ isFetching: m,
510
+ isRefetching: m && !C,
511
+ isLoadingError: I && !x,
512
+ isPaused: c.fetchStatus === "paused",
513
+ isPlaceholderData: f,
514
+ isRefetchError: I && x,
515
+ isStale: q(e, t),
516
+ refetch: this.refetch,
517
+ promise: this.#i,
518
+ isEnabled: g(t.enabled, e) !== !1
519
+ };
520
+ if (this.options.experimental_prefetchInRender) {
521
+ const d = (p) => {
522
+ y.status === "error" ? p.reject(y.error) : y.data !== void 0 && p.resolve(y.data);
523
+ }, E = () => {
524
+ const p = this.#i = y.promise = J();
525
+ d(p);
526
+ }, S = this.#i;
527
+ switch (S.status) {
528
+ case "pending":
529
+ e.queryHash === s.queryHash && d(S);
530
+ break;
531
+ case "fulfilled":
532
+ (y.status === "error" || y.data !== S.value) && E();
533
+ break;
534
+ case "rejected":
535
+ (y.status !== "error" || y.error !== S.reason) && E();
536
+ break;
537
+ }
538
+ }
539
+ return y;
540
+ }
541
+ updateResult() {
542
+ const e = this.#s, t = this.createResult(this.#e, this.options);
543
+ if (this.#a = this.#e.state, this.#l = this.options, this.#a.data !== void 0 && (this.#d = this.#e), D(t, e))
544
+ return;
545
+ this.#s = t;
546
+ const s = () => {
547
+ if (!e)
548
+ return !0;
549
+ const { notifyOnChangeProps: i } = this.options, r = typeof i == "function" ? i() : i;
550
+ if (r === "all" || !r && !this.#p.size)
551
+ return !0;
552
+ const h = new Set(
553
+ r ?? this.#p
554
+ );
555
+ return this.options.throwOnError && h.add("error"), Object.keys(this.#s).some((n) => {
556
+ const o = n;
557
+ return this.#s[o] !== e[o] && h.has(o);
558
+ });
559
+ };
560
+ this.#E({ listeners: s() });
561
+ }
562
+ #R() {
563
+ const e = this.#t.getQueryCache().build(this.#t, this.options);
564
+ if (e === this.#e)
565
+ return;
566
+ const t = this.#e;
567
+ this.#e = e, this.#r = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
568
+ }
569
+ onQueryUpdate() {
570
+ this.updateResult(), this.hasListeners() && this.#m();
571
+ }
572
+ #E(e) {
573
+ G.batch(() => {
574
+ e.listeners && this.listeners.forEach((t) => {
575
+ t(this.#s);
576
+ }), this.#t.getQueryCache().notify({
577
+ query: this.#e,
578
+ type: "observerResultsUpdated"
579
+ });
580
+ });
581
+ }
582
+ };
583
+ function Re(e, t) {
584
+ return g(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
585
+ }
586
+ function K(e, t) {
587
+ return Re(e, t) || e.state.data !== void 0 && U(e, t, t.refetchOnMount);
588
+ }
589
+ function U(e, t, s) {
590
+ if (g(t.enabled, e) !== !1 && T(t.staleTime, e) !== "static") {
591
+ const i = typeof s == "function" ? s(e) : s;
592
+ return i === "always" || i !== !1 && q(e, t);
593
+ }
594
+ return !1;
595
+ }
596
+ function $(e, t, s, i) {
597
+ return (e !== t || g(i.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && q(e, s);
598
+ }
599
+ function q(e, t) {
600
+ return g(t.enabled, e) !== !1 && e.isStaleByTime(T(t.staleTime, e));
601
+ }
602
+ function Ee(e, t) {
603
+ return !D(e.getCurrentResult(), t);
604
+ }
605
+ var we = b.createContext(
606
+ void 0
607
+ ), Ce = (e) => {
608
+ const t = b.useContext(we);
609
+ if (!t)
610
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
611
+ return t;
612
+ }, Ie = b.createContext(!1), Te = () => b.useContext(Ie);
613
+ function Fe() {
614
+ let e = !1;
615
+ return {
616
+ clearReset: () => {
617
+ e = !1;
618
+ },
619
+ reset: () => {
620
+ e = !0;
621
+ },
622
+ isReset: () => e
623
+ };
624
+ }
625
+ var Me = b.createContext(Fe()), Pe = () => b.useContext(Me), xe = (e, t) => {
626
+ (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
627
+ }, _e = (e) => {
628
+ b.useEffect(() => {
629
+ e.clearReset();
630
+ }, [e]);
631
+ }, Ne = ({
632
+ result: e,
633
+ errorResetBoundary: t,
634
+ throwOnError: s,
635
+ query: i,
636
+ suspense: r
637
+ }) => e.isError && !t.isReset() && !e.isFetching && i && (r && e.data === void 0 || fe(s, [e.error, i])), Le = (e) => {
638
+ if (e.suspense) {
639
+ const s = (r) => r === "static" ? r : Math.max(r ?? 1e3, 1e3), i = e.staleTime;
640
+ e.staleTime = typeof i == "function" ? (...r) => s(i(...r)) : s(i), typeof e.gcTime == "number" && (e.gcTime = Math.max(
641
+ e.gcTime,
642
+ 1e3
643
+ ));
644
+ }
645
+ }, Qe = (e, t) => e.isLoading && e.isFetching && !t, je = (e, t) => e?.suspense && t.isPending, Z = (e, t, s) => t.fetchOptimistic(e).catch(() => {
646
+ s.clearReset();
647
+ });
648
+ function De(e, t, s) {
649
+ if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
650
+ throw new Error(
651
+ 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
652
+ );
653
+ const i = Te(), r = Pe(), h = Ce(), n = h.defaultQueryOptions(e);
654
+ h.getDefaultOptions().queries?._experimental_beforeQuery?.(
655
+ n
656
+ ), process.env.NODE_ENV !== "production" && (n.queryFn || console.error(
657
+ `[${n.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
658
+ )), n._optimisticResults = i ? "isRestoring" : "optimistic", Le(n), xe(n, r), _e(r);
659
+ const o = !h.getQueryCache().get(n.queryHash), [a] = b.useState(
660
+ () => new t(
661
+ h,
662
+ n
663
+ )
664
+ ), l = a.getOptimisticResult(n), c = !i && e.subscribed !== !1;
665
+ if (b.useSyncExternalStore(
666
+ b.useCallback(
667
+ (f) => {
668
+ const u = c ? a.subscribe(G.batchCalls(f)) : Q;
669
+ return a.updateResult(), u;
670
+ },
671
+ [a, c]
672
+ ),
673
+ () => a.getCurrentResult(),
674
+ () => a.getCurrentResult()
675
+ ), b.useEffect(() => {
676
+ a.setOptions(n);
677
+ }, [n, a]), je(n, l))
678
+ throw Z(n, a, r);
679
+ if (Ne({
680
+ result: l,
681
+ errorResetBoundary: r,
682
+ throwOnError: n.throwOnError,
683
+ query: h.getQueryCache().get(n.queryHash),
684
+ suspense: n.suspense
685
+ }))
686
+ throw l.error;
687
+ return h.getDefaultOptions().queries?._experimental_afterQuery?.(
688
+ n,
689
+ l
690
+ ), n.experimental_prefetchInRender && !F && Qe(l, i) && (o ? (
691
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
692
+ Z(n, a, r)
693
+ ) : (
694
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
695
+ h.getQueryCache().get(n.queryHash)?.promise
696
+ ))?.catch(Q).finally(() => {
697
+ a.updateResult();
698
+ }), n.notifyOnChangeProps ? l : a.trackResult(l);
699
+ }
700
+ function Ue(e, t) {
701
+ return De(e, Oe);
702
+ }
703
+ const Be = ({
704
+ children: e,
705
+ id: t,
706
+ data: s = [],
707
+ columns: i = [],
708
+ totalItems: r,
709
+ fetchData: h
710
+ }) => {
711
+ const [n, o] = w([]), [a, l] = w(0), [c, f] = w(), [u, O] = w(oe), [R, v] = w(r), M = te(
712
+ () => Math.ceil(R / u),
713
+ [R, u]
714
+ ), [m, C] = w({}), { data: I, isLoading: P, isFetching: x } = Ue({
715
+ queryKey: [
716
+ t,
717
+ a,
718
+ u,
719
+ c,
720
+ JSON.stringify(m)
721
+ ],
722
+ refetchOnMount: !1,
723
+ refetchOnWindowFocus: !1,
724
+ initialData: s,
725
+ queryFn: () => h({
726
+ page: Math.max(a + 1, 1),
727
+ pageSize: u,
728
+ termOfSearch: c,
729
+ ...Object.keys(m).length > 0 ? m : {}
730
+ }).then(({ data: p, totalItemsCount: L }) => (v(L), p))
731
+ }), A = _((p) => {
732
+ f(p), l(0);
733
+ }, []), y = _((p, L) => {
734
+ const X = p.toLowerCase().replace(/\s+/g, "_");
735
+ C((Y) => ({
736
+ ...Y,
737
+ [X]: L
738
+ }));
739
+ }, []), d = _((p) => l(p), []), E = _(
740
+ (p) => O(p),
741
+ []
742
+ ), S = se({
743
+ data: I,
744
+ columns: i,
745
+ state: {
746
+ sorting: n
747
+ },
748
+ onSortingChange: o,
749
+ getCoreRowModel: ie(),
750
+ getSortedRowModel: re()
751
+ });
752
+ return /* @__PURE__ */ ee(
753
+ ne.Provider,
754
+ {
755
+ value: {
756
+ sortedData: n,
757
+ table: S,
758
+ tableFetching: x,
759
+ tableLoading: P,
760
+ totalItems: R,
761
+ termOfSearch: c,
762
+ page: a,
763
+ multiselectSelected: m,
764
+ pageSize: u,
765
+ totalPages: M,
766
+ handlePage: d,
767
+ onPageSize: E,
768
+ onChangeTermOfSearch: A,
769
+ onSorting: o,
770
+ onSelectMultiselect: y
771
+ },
772
+ children: e
773
+ }
774
+ );
775
+ };
776
+ export {
777
+ Be as TableProvider
778
+ };