@konstructio/ui 0.1.2-alpha.6 → 0.1.2-alpha.8
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/{Modal-D-NOEWMX.js → Modal-B8jrP02v.js} +20 -20
- package/dist/components/Alert/Alert.js +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
- package/dist/components/AlertDialog/components/index.js +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Command/Command.js +2 -2
- package/dist/components/Command/components/Command.js +1 -1
- package/dist/components/Command/components/CommandEmpty.js +1 -1
- package/dist/components/Command/components/CommandGroup.js +1 -1
- package/dist/components/Command/components/CommandInput.js +1 -1
- package/dist/components/Command/components/CommandItem.js +1 -1
- package/dist/components/Command/components/CommandList.js +1 -1
- package/dist/components/Command/components/CommandSeparator.js +1 -1
- package/dist/components/Command/components/DialogContent.js +1 -1
- package/dist/components/Command/components/DialogOverlay.js +1 -1
- package/dist/components/Modal/Modal.js +2 -2
- package/dist/components/Modal/components/Wrapper/Wrapper.js +2 -2
- package/dist/components/Modal/components/index.js +1 -1
- package/dist/components/NumberInput/NumberInput.js +1 -1
- package/dist/components/Range/Range.js +1 -1
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Tabs/components/Content.js +1 -1
- package/dist/components/Tabs/components/List.js +1 -1
- package/dist/components/Tabs/components/Trigger.js +1 -1
- package/dist/components/Toast/Toast.js +54 -53
- package/dist/components/VirtualizedTable/VirtualizedTable.js +72 -58
- package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +4 -3
- package/dist/components/VirtualizedTable/contexts/table.provider.js +64 -760
- package/dist/components/index.js +1 -1
- package/dist/{index-B7t8D14s.js → index-0XtjXVpJ.js} +2 -2
- package/dist/index-BVRIAMfe.js +36 -0
- package/dist/{index-os7vysFS.js → index-Bn4c-gww.js} +1 -1
- package/dist/{index-Cd2vhaop.js → index-CffpTFMi.js} +1 -1
- package/dist/{index-Bnb0ezr3.js → index-DQJhMz8c.js} +1 -1
- package/dist/index-DdXGVVBv.js +15 -0
- package/dist/{index-DzIBBMjs.js → index-amYX3uxF.js} +3 -3
- package/dist/{index-C84F4YyO.js → index-l3NwplN0.js} +1 -1
- package/dist/{index-DBbEcSUG.js → index-sp5ZfG6g.js} +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +1 -1
- package/dist/package.json +6 -2
- package/package.json +6 -2
- package/dist/index-BITvcJAz.js +0 -423
- package/dist/index-ti1b9kqV.js +0 -14
|
@@ -1,778 +1,82 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { TableContext as
|
|
6
|
-
import { DEFAULT_PAGE_SIZE as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
1
|
+
import { jsx as z } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as E } from "@tanstack/react-query";
|
|
3
|
+
import { u as _, g as j, a as k } from "../../../index-Dx2grAuN.js";
|
|
4
|
+
import { useState as t, useMemo as q, useCallback as s } from "react";
|
|
5
|
+
import { TableContext as A } from "./table.context.js";
|
|
6
|
+
import { DEFAULT_PAGE_SIZE as K } from "../constants/pagination.js";
|
|
7
|
+
const Z = ({
|
|
8
|
+
children: u,
|
|
9
|
+
id: d,
|
|
10
|
+
data: S = [],
|
|
11
|
+
columns: f = [],
|
|
12
|
+
totalItems: h,
|
|
13
|
+
fetchData: p
|
|
710
14
|
}) => {
|
|
711
|
-
const [
|
|
712
|
-
() => Math.ceil(
|
|
713
|
-
[
|
|
714
|
-
), [
|
|
15
|
+
const [i, g] = t([]), [n, m] = t(0), [r, C] = t(), [o, M] = t(K), [c, b] = t(h), P = q(
|
|
16
|
+
() => Math.ceil(c / o),
|
|
17
|
+
[c, o]
|
|
18
|
+
), [a, w] = t({}), { data: y, isLoading: O, isFetching: T } = E({
|
|
715
19
|
queryKey: [
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
JSON.stringify(
|
|
20
|
+
d,
|
|
21
|
+
n,
|
|
22
|
+
o,
|
|
23
|
+
r,
|
|
24
|
+
JSON.stringify(a)
|
|
721
25
|
],
|
|
722
26
|
refetchOnMount: !1,
|
|
723
27
|
refetchOnWindowFocus: !1,
|
|
724
|
-
initialData:
|
|
725
|
-
queryFn: () =>
|
|
726
|
-
page: Math.max(
|
|
727
|
-
pageSize:
|
|
728
|
-
termOfSearch:
|
|
729
|
-
...Object.keys(
|
|
730
|
-
}).then(({ data:
|
|
731
|
-
}),
|
|
732
|
-
|
|
733
|
-
}, []),
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
...
|
|
737
|
-
[
|
|
28
|
+
initialData: S,
|
|
29
|
+
queryFn: () => p({
|
|
30
|
+
page: Math.max(n + 1, 1),
|
|
31
|
+
pageSize: o,
|
|
32
|
+
termOfSearch: r,
|
|
33
|
+
...Object.keys(a).length > 0 ? a : {}
|
|
34
|
+
}).then(({ data: e, totalItemsCount: l }) => (b(l), e))
|
|
35
|
+
}), F = s((e) => {
|
|
36
|
+
C(e), m(0);
|
|
37
|
+
}, []), I = s((e, l) => {
|
|
38
|
+
const L = e.toLowerCase().replace(/\s+/g, "_");
|
|
39
|
+
w((v) => ({
|
|
40
|
+
...v,
|
|
41
|
+
[L]: l
|
|
738
42
|
}));
|
|
739
|
-
}, []),
|
|
740
|
-
(
|
|
43
|
+
}, []), R = s((e) => m(e), []), x = s(
|
|
44
|
+
(e) => M(e),
|
|
741
45
|
[]
|
|
742
|
-
),
|
|
743
|
-
data:
|
|
744
|
-
columns:
|
|
46
|
+
), D = _({
|
|
47
|
+
data: y,
|
|
48
|
+
columns: f,
|
|
745
49
|
state: {
|
|
746
|
-
sorting:
|
|
50
|
+
sorting: i
|
|
747
51
|
},
|
|
748
|
-
onSortingChange:
|
|
749
|
-
getCoreRowModel:
|
|
750
|
-
getSortedRowModel:
|
|
52
|
+
onSortingChange: g,
|
|
53
|
+
getCoreRowModel: k(),
|
|
54
|
+
getSortedRowModel: j()
|
|
751
55
|
});
|
|
752
|
-
return /* @__PURE__ */
|
|
753
|
-
|
|
56
|
+
return /* @__PURE__ */ z(
|
|
57
|
+
A.Provider,
|
|
754
58
|
{
|
|
755
59
|
value: {
|
|
756
|
-
sortedData:
|
|
757
|
-
table:
|
|
758
|
-
tableFetching:
|
|
759
|
-
tableLoading:
|
|
760
|
-
totalItems:
|
|
761
|
-
termOfSearch:
|
|
762
|
-
page:
|
|
763
|
-
multiselectSelected:
|
|
764
|
-
pageSize:
|
|
765
|
-
totalPages:
|
|
766
|
-
handlePage:
|
|
767
|
-
onPageSize:
|
|
768
|
-
onChangeTermOfSearch:
|
|
769
|
-
onSorting:
|
|
770
|
-
onSelectMultiselect:
|
|
60
|
+
sortedData: i,
|
|
61
|
+
table: D,
|
|
62
|
+
tableFetching: T,
|
|
63
|
+
tableLoading: O,
|
|
64
|
+
totalItems: c,
|
|
65
|
+
termOfSearch: r,
|
|
66
|
+
page: n,
|
|
67
|
+
multiselectSelected: a,
|
|
68
|
+
pageSize: o,
|
|
69
|
+
totalPages: P,
|
|
70
|
+
handlePage: R,
|
|
71
|
+
onPageSize: x,
|
|
72
|
+
onChangeTermOfSearch: F,
|
|
73
|
+
onSorting: g,
|
|
74
|
+
onSelectMultiselect: I
|
|
771
75
|
},
|
|
772
|
-
children:
|
|
76
|
+
children: u
|
|
773
77
|
}
|
|
774
78
|
);
|
|
775
79
|
};
|
|
776
80
|
export {
|
|
777
|
-
|
|
81
|
+
Z as TableProvider
|
|
778
82
|
};
|