@leancodepl/antd-table-hooks 10.1.3
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/CHANGELOG.md +19 -0
- package/LICENSE +201 -0
- package/README.md +470 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +722 -0
- package/dist/lib/filters/index.d.ts +37 -0
- package/dist/lib/filters/index.d.ts.map +1 -0
- package/dist/lib/filters/types.d.ts +37 -0
- package/dist/lib/filters/types.d.ts.map +1 -0
- package/dist/lib/filters/useFilters.d.ts +41 -0
- package/dist/lib/filters/useFilters.d.ts.map +1 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/pagination/index.d.ts +53 -0
- package/dist/lib/pagination/index.d.ts.map +1 -0
- package/dist/lib/sorting/index.d.ts +77 -0
- package/dist/lib/sorting/index.d.ts.map +1 -0
- package/dist/lib/table/index.d.ts +113 -0
- package/dist/lib/table/index.d.ts.map +1 -0
- package/dist/lib/types.d.ts +6 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/package.json +64 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,722 @@
|
|
|
1
|
+
import { jsx as ot } from "react/jsx-runtime";
|
|
2
|
+
import { useState as E, useRef as it, useCallback as P, useMemo as j } from "react";
|
|
3
|
+
import x from "zod";
|
|
4
|
+
var $ = function(e, r) {
|
|
5
|
+
return $ = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
|
|
6
|
+
t.__proto__ = n;
|
|
7
|
+
} || function(t, n) {
|
|
8
|
+
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
|
|
9
|
+
}, $(e, r);
|
|
10
|
+
};
|
|
11
|
+
function D(e, r) {
|
|
12
|
+
if (typeof r != "function" && r !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
|
14
|
+
$(e, r);
|
|
15
|
+
function t() {
|
|
16
|
+
this.constructor = e;
|
|
17
|
+
}
|
|
18
|
+
e.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
|
|
19
|
+
}
|
|
20
|
+
function M(e) {
|
|
21
|
+
var r = typeof Symbol == "function" && Symbol.iterator, t = r && e[r], n = 0;
|
|
22
|
+
if (t) return t.call(e);
|
|
23
|
+
if (e && typeof e.length == "number") return {
|
|
24
|
+
next: function() {
|
|
25
|
+
return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
29
|
+
}
|
|
30
|
+
function k(e, r) {
|
|
31
|
+
var t = typeof Symbol == "function" && e[Symbol.iterator];
|
|
32
|
+
if (!t) return e;
|
|
33
|
+
var n = t.call(e), o, i = [], s;
|
|
34
|
+
try {
|
|
35
|
+
for (; (r === void 0 || r-- > 0) && !(o = n.next()).done; ) i.push(o.value);
|
|
36
|
+
} catch (c) {
|
|
37
|
+
s = { error: c };
|
|
38
|
+
} finally {
|
|
39
|
+
try {
|
|
40
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
41
|
+
} finally {
|
|
42
|
+
if (s) throw s.error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return i;
|
|
46
|
+
}
|
|
47
|
+
function I(e, r, t) {
|
|
48
|
+
if (t || arguments.length === 2) for (var n = 0, o = r.length, i; n < o; n++)
|
|
49
|
+
(i || !(n in r)) && (i || (i = Array.prototype.slice.call(r, 0, n)), i[n] = r[n]);
|
|
50
|
+
return e.concat(i || Array.prototype.slice.call(r));
|
|
51
|
+
}
|
|
52
|
+
function _(e) {
|
|
53
|
+
return typeof e == "function";
|
|
54
|
+
}
|
|
55
|
+
function N(e) {
|
|
56
|
+
var r = function(n) {
|
|
57
|
+
Error.call(n), n.stack = new Error().stack;
|
|
58
|
+
}, t = e(r);
|
|
59
|
+
return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
|
|
60
|
+
}
|
|
61
|
+
var U = N(function(e) {
|
|
62
|
+
return function(t) {
|
|
63
|
+
e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
|
|
64
|
+
` + t.map(function(n, o) {
|
|
65
|
+
return o + 1 + ") " + n.toString();
|
|
66
|
+
}).join(`
|
|
67
|
+
`) : "", this.name = "UnsubscriptionError", this.errors = t;
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
function R(e, r) {
|
|
71
|
+
if (e) {
|
|
72
|
+
var t = e.indexOf(r);
|
|
73
|
+
0 <= t && e.splice(t, 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
var T = (function() {
|
|
77
|
+
function e(r) {
|
|
78
|
+
this.initialTeardown = r, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
79
|
+
}
|
|
80
|
+
return e.prototype.unsubscribe = function() {
|
|
81
|
+
var r, t, n, o, i;
|
|
82
|
+
if (!this.closed) {
|
|
83
|
+
this.closed = !0;
|
|
84
|
+
var s = this._parentage;
|
|
85
|
+
if (s)
|
|
86
|
+
if (this._parentage = null, Array.isArray(s))
|
|
87
|
+
try {
|
|
88
|
+
for (var c = M(s), a = c.next(); !a.done; a = c.next()) {
|
|
89
|
+
var u = a.value;
|
|
90
|
+
u.remove(this);
|
|
91
|
+
}
|
|
92
|
+
} catch (l) {
|
|
93
|
+
r = { error: l };
|
|
94
|
+
} finally {
|
|
95
|
+
try {
|
|
96
|
+
a && !a.done && (t = c.return) && t.call(c);
|
|
97
|
+
} finally {
|
|
98
|
+
if (r) throw r.error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
s.remove(this);
|
|
103
|
+
var d = this.initialTeardown;
|
|
104
|
+
if (_(d))
|
|
105
|
+
try {
|
|
106
|
+
d();
|
|
107
|
+
} catch (l) {
|
|
108
|
+
i = l instanceof U ? l.errors : [l];
|
|
109
|
+
}
|
|
110
|
+
var m = this._finalizers;
|
|
111
|
+
if (m) {
|
|
112
|
+
this._finalizers = null;
|
|
113
|
+
try {
|
|
114
|
+
for (var b = M(m), y = b.next(); !y.done; y = b.next()) {
|
|
115
|
+
var S = y.value;
|
|
116
|
+
try {
|
|
117
|
+
B(S);
|
|
118
|
+
} catch (l) {
|
|
119
|
+
i = i ?? [], l instanceof U ? i = I(I([], k(i)), k(l.errors)) : i.push(l);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (l) {
|
|
123
|
+
n = { error: l };
|
|
124
|
+
} finally {
|
|
125
|
+
try {
|
|
126
|
+
y && !y.done && (o = b.return) && o.call(b);
|
|
127
|
+
} finally {
|
|
128
|
+
if (n) throw n.error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (i)
|
|
133
|
+
throw new U(i);
|
|
134
|
+
}
|
|
135
|
+
}, e.prototype.add = function(r) {
|
|
136
|
+
var t;
|
|
137
|
+
if (r && r !== this)
|
|
138
|
+
if (this.closed)
|
|
139
|
+
B(r);
|
|
140
|
+
else {
|
|
141
|
+
if (r instanceof e) {
|
|
142
|
+
if (r.closed || r._hasParent(this))
|
|
143
|
+
return;
|
|
144
|
+
r._addParent(this);
|
|
145
|
+
}
|
|
146
|
+
(this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(r);
|
|
147
|
+
}
|
|
148
|
+
}, e.prototype._hasParent = function(r) {
|
|
149
|
+
var t = this._parentage;
|
|
150
|
+
return t === r || Array.isArray(t) && t.includes(r);
|
|
151
|
+
}, e.prototype._addParent = function(r) {
|
|
152
|
+
var t = this._parentage;
|
|
153
|
+
this._parentage = Array.isArray(t) ? (t.push(r), t) : t ? [t, r] : r;
|
|
154
|
+
}, e.prototype._removeParent = function(r) {
|
|
155
|
+
var t = this._parentage;
|
|
156
|
+
t === r ? this._parentage = null : Array.isArray(t) && R(t, r);
|
|
157
|
+
}, e.prototype.remove = function(r) {
|
|
158
|
+
var t = this._finalizers;
|
|
159
|
+
t && R(t, r), r instanceof e && r._removeParent(this);
|
|
160
|
+
}, e.EMPTY = (function() {
|
|
161
|
+
var r = new e();
|
|
162
|
+
return r.closed = !0, r;
|
|
163
|
+
})(), e;
|
|
164
|
+
})(), Q = T.EMPTY;
|
|
165
|
+
function q(e) {
|
|
166
|
+
return e instanceof T || e && "closed" in e && _(e.remove) && _(e.add) && _(e.unsubscribe);
|
|
167
|
+
}
|
|
168
|
+
function B(e) {
|
|
169
|
+
_(e) ? e() : e.unsubscribe();
|
|
170
|
+
}
|
|
171
|
+
var st = {
|
|
172
|
+
Promise: void 0
|
|
173
|
+
}, ct = {
|
|
174
|
+
setTimeout: function(e, r) {
|
|
175
|
+
for (var t = [], n = 2; n < arguments.length; n++)
|
|
176
|
+
t[n - 2] = arguments[n];
|
|
177
|
+
return setTimeout.apply(void 0, I([e, r], k(t)));
|
|
178
|
+
},
|
|
179
|
+
clearTimeout: function(e) {
|
|
180
|
+
return clearTimeout(e);
|
|
181
|
+
},
|
|
182
|
+
delegate: void 0
|
|
183
|
+
};
|
|
184
|
+
function at(e) {
|
|
185
|
+
ct.setTimeout(function() {
|
|
186
|
+
throw e;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function H() {
|
|
190
|
+
}
|
|
191
|
+
function K(e) {
|
|
192
|
+
e();
|
|
193
|
+
}
|
|
194
|
+
var tt = (function(e) {
|
|
195
|
+
D(r, e);
|
|
196
|
+
function r(t) {
|
|
197
|
+
var n = e.call(this) || this;
|
|
198
|
+
return n.isStopped = !1, t ? (n.destination = t, q(t) && t.add(n)) : n.destination = ft, n;
|
|
199
|
+
}
|
|
200
|
+
return r.create = function(t, n, o) {
|
|
201
|
+
return new Y(t, n, o);
|
|
202
|
+
}, r.prototype.next = function(t) {
|
|
203
|
+
this.isStopped || this._next(t);
|
|
204
|
+
}, r.prototype.error = function(t) {
|
|
205
|
+
this.isStopped || (this.isStopped = !0, this._error(t));
|
|
206
|
+
}, r.prototype.complete = function() {
|
|
207
|
+
this.isStopped || (this.isStopped = !0, this._complete());
|
|
208
|
+
}, r.prototype.unsubscribe = function() {
|
|
209
|
+
this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
|
|
210
|
+
}, r.prototype._next = function(t) {
|
|
211
|
+
this.destination.next(t);
|
|
212
|
+
}, r.prototype._error = function(t) {
|
|
213
|
+
try {
|
|
214
|
+
this.destination.error(t);
|
|
215
|
+
} finally {
|
|
216
|
+
this.unsubscribe();
|
|
217
|
+
}
|
|
218
|
+
}, r.prototype._complete = function() {
|
|
219
|
+
try {
|
|
220
|
+
this.destination.complete();
|
|
221
|
+
} finally {
|
|
222
|
+
this.unsubscribe();
|
|
223
|
+
}
|
|
224
|
+
}, r;
|
|
225
|
+
})(T), ut = (function() {
|
|
226
|
+
function e(r) {
|
|
227
|
+
this.partialObserver = r;
|
|
228
|
+
}
|
|
229
|
+
return e.prototype.next = function(r) {
|
|
230
|
+
var t = this.partialObserver;
|
|
231
|
+
if (t.next)
|
|
232
|
+
try {
|
|
233
|
+
t.next(r);
|
|
234
|
+
} catch (n) {
|
|
235
|
+
C(n);
|
|
236
|
+
}
|
|
237
|
+
}, e.prototype.error = function(r) {
|
|
238
|
+
var t = this.partialObserver;
|
|
239
|
+
if (t.error)
|
|
240
|
+
try {
|
|
241
|
+
t.error(r);
|
|
242
|
+
} catch (n) {
|
|
243
|
+
C(n);
|
|
244
|
+
}
|
|
245
|
+
else
|
|
246
|
+
C(r);
|
|
247
|
+
}, e.prototype.complete = function() {
|
|
248
|
+
var r = this.partialObserver;
|
|
249
|
+
if (r.complete)
|
|
250
|
+
try {
|
|
251
|
+
r.complete();
|
|
252
|
+
} catch (t) {
|
|
253
|
+
C(t);
|
|
254
|
+
}
|
|
255
|
+
}, e;
|
|
256
|
+
})(), Y = (function(e) {
|
|
257
|
+
D(r, e);
|
|
258
|
+
function r(t, n, o) {
|
|
259
|
+
var i = e.call(this) || this, s;
|
|
260
|
+
return _(t) || !t ? s = {
|
|
261
|
+
next: t ?? void 0,
|
|
262
|
+
error: n ?? void 0,
|
|
263
|
+
complete: o ?? void 0
|
|
264
|
+
} : s = t, i.destination = new ut(s), i;
|
|
265
|
+
}
|
|
266
|
+
return r;
|
|
267
|
+
})(tt);
|
|
268
|
+
function C(e) {
|
|
269
|
+
at(e);
|
|
270
|
+
}
|
|
271
|
+
function lt(e) {
|
|
272
|
+
throw e;
|
|
273
|
+
}
|
|
274
|
+
var ft = {
|
|
275
|
+
closed: !0,
|
|
276
|
+
next: H,
|
|
277
|
+
error: lt,
|
|
278
|
+
complete: H
|
|
279
|
+
}, pt = (function() {
|
|
280
|
+
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
281
|
+
})();
|
|
282
|
+
function ht(e) {
|
|
283
|
+
return e;
|
|
284
|
+
}
|
|
285
|
+
function dt(e) {
|
|
286
|
+
return e.length === 0 ? ht : e.length === 1 ? e[0] : function(t) {
|
|
287
|
+
return e.reduce(function(n, o) {
|
|
288
|
+
return o(n);
|
|
289
|
+
}, t);
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
var J = (function() {
|
|
293
|
+
function e(r) {
|
|
294
|
+
r && (this._subscribe = r);
|
|
295
|
+
}
|
|
296
|
+
return e.prototype.lift = function(r) {
|
|
297
|
+
var t = new e();
|
|
298
|
+
return t.source = this, t.operator = r, t;
|
|
299
|
+
}, e.prototype.subscribe = function(r, t, n) {
|
|
300
|
+
var o = this, i = vt(r) ? r : new Y(r, t, n);
|
|
301
|
+
return K(function() {
|
|
302
|
+
var s = o, c = s.operator, a = s.source;
|
|
303
|
+
i.add(c ? c.call(i, a) : a ? o._subscribe(i) : o._trySubscribe(i));
|
|
304
|
+
}), i;
|
|
305
|
+
}, e.prototype._trySubscribe = function(r) {
|
|
306
|
+
try {
|
|
307
|
+
return this._subscribe(r);
|
|
308
|
+
} catch (t) {
|
|
309
|
+
r.error(t);
|
|
310
|
+
}
|
|
311
|
+
}, e.prototype.forEach = function(r, t) {
|
|
312
|
+
var n = this;
|
|
313
|
+
return t = G(t), new t(function(o, i) {
|
|
314
|
+
var s = new Y({
|
|
315
|
+
next: function(c) {
|
|
316
|
+
try {
|
|
317
|
+
r(c);
|
|
318
|
+
} catch (a) {
|
|
319
|
+
i(a), s.unsubscribe();
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
error: i,
|
|
323
|
+
complete: o
|
|
324
|
+
});
|
|
325
|
+
n.subscribe(s);
|
|
326
|
+
});
|
|
327
|
+
}, e.prototype._subscribe = function(r) {
|
|
328
|
+
var t;
|
|
329
|
+
return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(r);
|
|
330
|
+
}, e.prototype[pt] = function() {
|
|
331
|
+
return this;
|
|
332
|
+
}, e.prototype.pipe = function() {
|
|
333
|
+
for (var r = [], t = 0; t < arguments.length; t++)
|
|
334
|
+
r[t] = arguments[t];
|
|
335
|
+
return dt(r)(this);
|
|
336
|
+
}, e.prototype.toPromise = function(r) {
|
|
337
|
+
var t = this;
|
|
338
|
+
return r = G(r), new r(function(n, o) {
|
|
339
|
+
var i;
|
|
340
|
+
t.subscribe(function(s) {
|
|
341
|
+
return i = s;
|
|
342
|
+
}, function(s) {
|
|
343
|
+
return o(s);
|
|
344
|
+
}, function() {
|
|
345
|
+
return n(i);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
}, e.create = function(r) {
|
|
349
|
+
return new e(r);
|
|
350
|
+
}, e;
|
|
351
|
+
})();
|
|
352
|
+
function G(e) {
|
|
353
|
+
var r;
|
|
354
|
+
return (r = e ?? st.Promise) !== null && r !== void 0 ? r : Promise;
|
|
355
|
+
}
|
|
356
|
+
function bt(e) {
|
|
357
|
+
return e && _(e.next) && _(e.error) && _(e.complete);
|
|
358
|
+
}
|
|
359
|
+
function vt(e) {
|
|
360
|
+
return e && e instanceof tt || bt(e) && q(e);
|
|
361
|
+
}
|
|
362
|
+
var yt = N(function(e) {
|
|
363
|
+
return function() {
|
|
364
|
+
e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
365
|
+
};
|
|
366
|
+
}), et = (function(e) {
|
|
367
|
+
D(r, e);
|
|
368
|
+
function r() {
|
|
369
|
+
var t = e.call(this) || this;
|
|
370
|
+
return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
|
|
371
|
+
}
|
|
372
|
+
return r.prototype.lift = function(t) {
|
|
373
|
+
var n = new L(this, this);
|
|
374
|
+
return n.operator = t, n;
|
|
375
|
+
}, r.prototype._throwIfClosed = function() {
|
|
376
|
+
if (this.closed)
|
|
377
|
+
throw new yt();
|
|
378
|
+
}, r.prototype.next = function(t) {
|
|
379
|
+
var n = this;
|
|
380
|
+
K(function() {
|
|
381
|
+
var o, i;
|
|
382
|
+
if (n._throwIfClosed(), !n.isStopped) {
|
|
383
|
+
n.currentObservers || (n.currentObservers = Array.from(n.observers));
|
|
384
|
+
try {
|
|
385
|
+
for (var s = M(n.currentObservers), c = s.next(); !c.done; c = s.next()) {
|
|
386
|
+
var a = c.value;
|
|
387
|
+
a.next(t);
|
|
388
|
+
}
|
|
389
|
+
} catch (u) {
|
|
390
|
+
o = { error: u };
|
|
391
|
+
} finally {
|
|
392
|
+
try {
|
|
393
|
+
c && !c.done && (i = s.return) && i.call(s);
|
|
394
|
+
} finally {
|
|
395
|
+
if (o) throw o.error;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}, r.prototype.error = function(t) {
|
|
401
|
+
var n = this;
|
|
402
|
+
K(function() {
|
|
403
|
+
if (n._throwIfClosed(), !n.isStopped) {
|
|
404
|
+
n.hasError = n.isStopped = !0, n.thrownError = t;
|
|
405
|
+
for (var o = n.observers; o.length; )
|
|
406
|
+
o.shift().error(t);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}, r.prototype.complete = function() {
|
|
410
|
+
var t = this;
|
|
411
|
+
K(function() {
|
|
412
|
+
if (t._throwIfClosed(), !t.isStopped) {
|
|
413
|
+
t.isStopped = !0;
|
|
414
|
+
for (var n = t.observers; n.length; )
|
|
415
|
+
n.shift().complete();
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}, r.prototype.unsubscribe = function() {
|
|
419
|
+
this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
|
|
420
|
+
}, Object.defineProperty(r.prototype, "observed", {
|
|
421
|
+
get: function() {
|
|
422
|
+
var t;
|
|
423
|
+
return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
|
|
424
|
+
},
|
|
425
|
+
enumerable: !1,
|
|
426
|
+
configurable: !0
|
|
427
|
+
}), r.prototype._trySubscribe = function(t) {
|
|
428
|
+
return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
|
|
429
|
+
}, r.prototype._subscribe = function(t) {
|
|
430
|
+
return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
|
|
431
|
+
}, r.prototype._innerSubscribe = function(t) {
|
|
432
|
+
var n = this, o = this, i = o.hasError, s = o.isStopped, c = o.observers;
|
|
433
|
+
return i || s ? Q : (this.currentObservers = null, c.push(t), new T(function() {
|
|
434
|
+
n.currentObservers = null, R(c, t);
|
|
435
|
+
}));
|
|
436
|
+
}, r.prototype._checkFinalizedStatuses = function(t) {
|
|
437
|
+
var n = this, o = n.hasError, i = n.thrownError, s = n.isStopped;
|
|
438
|
+
o ? t.error(i) : s && t.complete();
|
|
439
|
+
}, r.prototype.asObservable = function() {
|
|
440
|
+
var t = new J();
|
|
441
|
+
return t.source = this, t;
|
|
442
|
+
}, r.create = function(t, n) {
|
|
443
|
+
return new L(t, n);
|
|
444
|
+
}, r;
|
|
445
|
+
})(J), L = (function(e) {
|
|
446
|
+
D(r, e);
|
|
447
|
+
function r(t, n) {
|
|
448
|
+
var o = e.call(this) || this;
|
|
449
|
+
return o.destination = t, o.source = n, o;
|
|
450
|
+
}
|
|
451
|
+
return r.prototype.next = function(t) {
|
|
452
|
+
var n, o;
|
|
453
|
+
(o = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || o === void 0 || o.call(n, t);
|
|
454
|
+
}, r.prototype.error = function(t) {
|
|
455
|
+
var n, o;
|
|
456
|
+
(o = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || o === void 0 || o.call(n, t);
|
|
457
|
+
}, r.prototype.complete = function() {
|
|
458
|
+
var t, n;
|
|
459
|
+
(n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
|
|
460
|
+
}, r.prototype._subscribe = function(t) {
|
|
461
|
+
var n, o;
|
|
462
|
+
return (o = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && o !== void 0 ? o : Q;
|
|
463
|
+
}, r;
|
|
464
|
+
})(et);
|
|
465
|
+
function z(e, r, t) {
|
|
466
|
+
const [n, o] = E(e);
|
|
467
|
+
e !== n && (o(e), r(e));
|
|
468
|
+
}
|
|
469
|
+
function xt({
|
|
470
|
+
filters: e,
|
|
471
|
+
onFiltersChange: r,
|
|
472
|
+
initialValues: t
|
|
473
|
+
}) {
|
|
474
|
+
const [n, o] = E(
|
|
475
|
+
() => V(e, t)
|
|
476
|
+
), i = it(t ?? {}), [s] = E(() => new et()), c = JSON.stringify(t);
|
|
477
|
+
z(c, () => {
|
|
478
|
+
o(V(e, t)), i.current = t ?? {};
|
|
479
|
+
});
|
|
480
|
+
const a = P(
|
|
481
|
+
(y) => Object.values(n).reduce((S, l) => l ? l(S) : S, y),
|
|
482
|
+
[n]
|
|
483
|
+
), u = j(
|
|
484
|
+
() => e.map(({ component: y, id: S }) => /* @__PURE__ */ ot(y, { applyFilter: (F, p) => {
|
|
485
|
+
i.current = { ...i.current, [S]: p }, o((f) => {
|
|
486
|
+
const g = { ...f, [S]: F };
|
|
487
|
+
return r?.(g, i.current), g;
|
|
488
|
+
});
|
|
489
|
+
}, initialValue: t?.[S], reset$: s }, S)),
|
|
490
|
+
[e, r, s, t]
|
|
491
|
+
), d = P(() => {
|
|
492
|
+
s.next(void 0);
|
|
493
|
+
}, [s]), m = j(() => Object.values(n).some(Boolean), [n]), b = {
|
|
494
|
+
filterComponents: u,
|
|
495
|
+
applyFilters: a,
|
|
496
|
+
resetFilters: d,
|
|
497
|
+
anyFilterSet: m
|
|
498
|
+
};
|
|
499
|
+
return { filters: b, ...b };
|
|
500
|
+
}
|
|
501
|
+
function V(e, r) {
|
|
502
|
+
return r ? Object.fromEntries(
|
|
503
|
+
e.flatMap((t) => {
|
|
504
|
+
const n = r[t.id];
|
|
505
|
+
if (n === void 0 || !t.buildApplyFilter) return [];
|
|
506
|
+
const o = t.buildApplyFilter(n);
|
|
507
|
+
return o ? [[t.id, o]] : [];
|
|
508
|
+
})
|
|
509
|
+
) : {};
|
|
510
|
+
}
|
|
511
|
+
function At() {
|
|
512
|
+
return function(e) {
|
|
513
|
+
return typeof e == "function" ? {
|
|
514
|
+
searchSchema: W(e()),
|
|
515
|
+
filters: e
|
|
516
|
+
} : {
|
|
517
|
+
searchSchema: W(e),
|
|
518
|
+
filters: e
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function W(e) {
|
|
523
|
+
return x.object(Object.fromEntries(e.flatMap((r) => r.searchSchema ?? [])));
|
|
524
|
+
}
|
|
525
|
+
function zt(e = {}) {
|
|
526
|
+
const { defaultSortKey: r, defaultSortDirection: t, onSortUpdate: n } = St(e), [o, i] = E(r), [s, c] = E(t);
|
|
527
|
+
return z(r, () => {
|
|
528
|
+
i(r);
|
|
529
|
+
}), z(t, () => {
|
|
530
|
+
c(t);
|
|
531
|
+
}), {
|
|
532
|
+
sortData: j(
|
|
533
|
+
() => ({
|
|
534
|
+
onChange: (u) => {
|
|
535
|
+
i(u?.columnKey), c(u?.order), n?.(u?.columnKey, u?.order);
|
|
536
|
+
},
|
|
537
|
+
data: {
|
|
538
|
+
order: s,
|
|
539
|
+
columnKey: o
|
|
540
|
+
}
|
|
541
|
+
}),
|
|
542
|
+
[n, s, o]
|
|
543
|
+
),
|
|
544
|
+
sortKey: o,
|
|
545
|
+
sortDirection: s,
|
|
546
|
+
isDescending: s === "descend"
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function St(e) {
|
|
550
|
+
return "sortKey" in e && "sortDirection" in e && "onSortUpdate" in e ? {
|
|
551
|
+
defaultSortKey: e.sortKey,
|
|
552
|
+
defaultSortDirection: e.sortDirection,
|
|
553
|
+
onSortUpdate: e.onSortUpdate
|
|
554
|
+
} : e;
|
|
555
|
+
}
|
|
556
|
+
function Ct(e = {}) {
|
|
557
|
+
const { initialDisplayPage: r, initialPageSize: t, onPaginationChange: n } = gt(e), [o, i] = E(r), [s, c] = E(t);
|
|
558
|
+
z(r, () => {
|
|
559
|
+
i(r);
|
|
560
|
+
}), z(t, () => {
|
|
561
|
+
c(t);
|
|
562
|
+
});
|
|
563
|
+
const a = P(
|
|
564
|
+
(d) => ({
|
|
565
|
+
current: o,
|
|
566
|
+
pageSize: s,
|
|
567
|
+
total: d,
|
|
568
|
+
showSizeChanger: !0,
|
|
569
|
+
pageSizeOptions: mt,
|
|
570
|
+
onChange: (m, b) => {
|
|
571
|
+
i(m), c(b), n?.({ displayPage: m, pageSize: b });
|
|
572
|
+
}
|
|
573
|
+
}),
|
|
574
|
+
[o, s, n]
|
|
575
|
+
), u = P(() => {
|
|
576
|
+
i(rt);
|
|
577
|
+
}, []);
|
|
578
|
+
return {
|
|
579
|
+
page: o - 1,
|
|
580
|
+
pageSize: s,
|
|
581
|
+
getTablePagination: a,
|
|
582
|
+
resetPage: u
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function gt(e) {
|
|
586
|
+
return "displayPage" in e && "pageSize" in e && "onPaginationChange" in e && !("initialDisplayPage" in e) ? {
|
|
587
|
+
initialDisplayPage: e.displayPage,
|
|
588
|
+
initialPageSize: e.pageSize,
|
|
589
|
+
onPaginationChange: e.onPaginationChange
|
|
590
|
+
} : {
|
|
591
|
+
initialDisplayPage: e.initialDisplayPage ?? rt,
|
|
592
|
+
initialPageSize: e.initialPageSize ?? _t,
|
|
593
|
+
onPaginationChange: e.onPaginationChange ?? (() => {
|
|
594
|
+
})
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
const rt = 1, mt = [10, 20, 50, 100], _t = 100;
|
|
598
|
+
function Kt({
|
|
599
|
+
queryParams: e,
|
|
600
|
+
setQueryParams: r,
|
|
601
|
+
definedFilters: t,
|
|
602
|
+
tableId: n,
|
|
603
|
+
defaultSortKey: o,
|
|
604
|
+
defaultSortDirection: i,
|
|
605
|
+
defaultPageSize: s = Z
|
|
606
|
+
}) {
|
|
607
|
+
const c = `${n}-displayPage`, a = `${n}-pageSize`, u = `${n}-sortKey`, d = `${n}-sortDescending`, m = j(() => {
|
|
608
|
+
const p = {};
|
|
609
|
+
for (const f of t) {
|
|
610
|
+
if (!f.fromSearchParams) continue;
|
|
611
|
+
const g = f.fromSearchParams(e);
|
|
612
|
+
g !== void 0 && (p[f.id] = g);
|
|
613
|
+
}
|
|
614
|
+
return Object.keys(p).length > 0 ? p : void 0;
|
|
615
|
+
}, [t, e]), b = j(
|
|
616
|
+
() => ({
|
|
617
|
+
displayPage: e[c] ?? X,
|
|
618
|
+
pageSize: e[a] ?? s
|
|
619
|
+
}),
|
|
620
|
+
[c, a, s, e]
|
|
621
|
+
), y = j(() => {
|
|
622
|
+
const p = e[u], f = e[d];
|
|
623
|
+
return {
|
|
624
|
+
sortKey: p ?? o,
|
|
625
|
+
sortDirection: f !== void 0 ? f ? "descend" : "ascend" : i
|
|
626
|
+
};
|
|
627
|
+
}, [u, d, o, i, e]), S = P(
|
|
628
|
+
(p) => {
|
|
629
|
+
const f = new Set(
|
|
630
|
+
t.flatMap(({ searchSchema: v }) => v?.map(([h]) => h) ?? [])
|
|
631
|
+
), g = /* @__PURE__ */ new Set([...f, c]), A = Object.fromEntries(Object.entries(e).filter(([v]) => !g.has(v))), O = {};
|
|
632
|
+
for (const v of t) {
|
|
633
|
+
if (!v.toSearchParams) continue;
|
|
634
|
+
const h = v.toSearchParams(p?.[v.id]);
|
|
635
|
+
Object.assign(O, h);
|
|
636
|
+
}
|
|
637
|
+
const w = Object.fromEntries(
|
|
638
|
+
Object.entries(O).filter(
|
|
639
|
+
([v, h]) => h != null && h !== "" && (Array.isArray(h) ? h.length > 0 : !0) && (typeof h == "object" ? Object.keys(h).length > 0 : !0)
|
|
640
|
+
)
|
|
641
|
+
);
|
|
642
|
+
r({
|
|
643
|
+
...A,
|
|
644
|
+
...w
|
|
645
|
+
});
|
|
646
|
+
},
|
|
647
|
+
[t, e, r, c]
|
|
648
|
+
), l = P(
|
|
649
|
+
({ displayPage: p, pageSize: f }) => {
|
|
650
|
+
const g = /* @__PURE__ */ new Set([c, a]), A = Object.fromEntries(
|
|
651
|
+
Object.entries(e).filter(([w]) => !g.has(w))
|
|
652
|
+
), O = Object.fromEntries(
|
|
653
|
+
Object.entries({
|
|
654
|
+
[c]: p === X ? void 0 : p,
|
|
655
|
+
[a]: f === Z ? void 0 : f
|
|
656
|
+
}).filter(([w, v]) => v !== void 0)
|
|
657
|
+
);
|
|
658
|
+
r({
|
|
659
|
+
...A,
|
|
660
|
+
...O
|
|
661
|
+
});
|
|
662
|
+
},
|
|
663
|
+
[c, a, e, r]
|
|
664
|
+
), F = P(
|
|
665
|
+
(p, f) => {
|
|
666
|
+
const g = /* @__PURE__ */ new Set([u, d]), A = Object.fromEntries(Object.entries(e).filter(([h]) => !g.has(h))), O = p === o && f === i, w = f === "descend" ? !0 : f === "ascend" ? !1 : void 0, v = Object.fromEntries(
|
|
667
|
+
Object.entries({
|
|
668
|
+
[u]: O ? void 0 : p,
|
|
669
|
+
[d]: O ? void 0 : w
|
|
670
|
+
}).filter(([h, nt]) => nt !== void 0)
|
|
671
|
+
);
|
|
672
|
+
r({
|
|
673
|
+
...A,
|
|
674
|
+
...v
|
|
675
|
+
});
|
|
676
|
+
},
|
|
677
|
+
[u, d, o, i, e, r]
|
|
678
|
+
);
|
|
679
|
+
return {
|
|
680
|
+
filters: {
|
|
681
|
+
values: m,
|
|
682
|
+
onFiltersChange: S
|
|
683
|
+
},
|
|
684
|
+
pagination: {
|
|
685
|
+
...b,
|
|
686
|
+
onPaginationChange: l
|
|
687
|
+
},
|
|
688
|
+
sorting: {
|
|
689
|
+
...y,
|
|
690
|
+
onSortUpdate: F
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function Ot(e) {
|
|
695
|
+
const r = x.coerce.number().optional();
|
|
696
|
+
return x.object({
|
|
697
|
+
[`${e}-displayPage`]: r,
|
|
698
|
+
[`${e}-pageSize`]: r
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
function Pt(e, r) {
|
|
702
|
+
const t = r.optional(), n = x.coerce.boolean().optional();
|
|
703
|
+
return x.object({
|
|
704
|
+
[`${e}-sortKey`]: t,
|
|
705
|
+
[`${e}-sortDescending`]: n
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
const X = 1, Z = 100, Dt = (e, r, t) => x.object({
|
|
709
|
+
...e.shape,
|
|
710
|
+
...Ot(r).shape,
|
|
711
|
+
...Pt(r, t).shape
|
|
712
|
+
});
|
|
713
|
+
export {
|
|
714
|
+
Ot as buildPaginationSearchSchema,
|
|
715
|
+
Pt as buildSortingSearchSchema,
|
|
716
|
+
At as defineFilters,
|
|
717
|
+
Dt as tableSearchSchema,
|
|
718
|
+
xt as useFilters,
|
|
719
|
+
Ct as usePagination,
|
|
720
|
+
zt as useSorting,
|
|
721
|
+
Kt as useTable
|
|
722
|
+
};
|