@redi.run/redi-components 0.0.45 → 0.0.46
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/index.d.ts +1 -0
- package/dist/redi-components.js +192 -181
- package/dist/redi-components.umd.cjs +28 -28
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/redi-components.js
CHANGED
|
@@ -1846,15 +1846,15 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
1846
1846
|
console.error("cannot use native zlib: " + (e.message || e));
|
|
1847
1847
|
}
|
|
1848
1848
|
}
|
|
1849
|
-
function
|
|
1849
|
+
function Ih(e, t) {
|
|
1850
1850
|
if (!I) return ag(e, t);
|
|
1851
1851
|
var n = I.InflateRaw, i = new n(), a = i._processChunk(e.slice(e.l), i._finishFlushFlag);
|
|
1852
1852
|
return e.l += i.bytesRead, a;
|
|
1853
1853
|
}
|
|
1854
|
-
function
|
|
1854
|
+
function L(e) {
|
|
1855
1855
|
return I ? I.deflateRawSync(e) : Qh(e);
|
|
1856
1856
|
}
|
|
1857
|
-
var
|
|
1857
|
+
var Lh = [
|
|
1858
1858
|
16,
|
|
1859
1859
|
17,
|
|
1860
1860
|
18,
|
|
@@ -1874,7 +1874,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
1874
1874
|
14,
|
|
1875
1875
|
1,
|
|
1876
1876
|
15
|
|
1877
|
-
],
|
|
1877
|
+
], R = [
|
|
1878
1878
|
3,
|
|
1879
1879
|
4,
|
|
1880
1880
|
5,
|
|
@@ -2037,7 +2037,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
2037
2037
|
for (var e = V ? new Uint8Array(32768) : [], t = 0, n = 0; t < B.length - 1; ++t) for (; n < B[t + 1]; ++n) e[n] = t;
|
|
2038
2038
|
for (; n < 32768; ++n) e[n] = 29;
|
|
2039
2039
|
var i = V ? new Uint8Array(259) : [];
|
|
2040
|
-
for (t = 0, n = 0; t <
|
|
2040
|
+
for (t = 0, n = 0; t < R.length - 1; ++t) for (; n < R[t + 1]; ++n) i[n] = t;
|
|
2041
2041
|
function a(e, t) {
|
|
2042
2042
|
for (var n = 0; n < e.length;) {
|
|
2043
2043
|
var i = Math.min(65535, e.length - n), a = n + i == e.length;
|
|
@@ -2062,7 +2062,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
2062
2062
|
if (f > 2) {
|
|
2063
2063
|
u = i[f], u <= 22 ? a = G(n, a, H[u + 1] >> 1) - 1 : (G(n, a, 3), a += 5, G(n, a, H[u - 23] >> 5), a += 3);
|
|
2064
2064
|
var p = u < 8 ? 0 : u - 4 >> 2;
|
|
2065
|
-
p > 0 && (Yh(n, a, f -
|
|
2065
|
+
p > 0 && (Yh(n, a, f - R[u]), a += p), u = e[o - d], a = G(n, a, H[u] >> 3), a -= 3;
|
|
2066
2066
|
var m = u < 4 ? 0 : u - 2 >> 1;
|
|
2067
2067
|
m > 0 && (Yh(n, a, o - d - B[u]), a += m);
|
|
2068
2068
|
for (var h = 0; h < f; ++h) s[l] = o & 32767, l = (l << 5 ^ t[o]) & 32767, ++o;
|
|
@@ -2109,7 +2109,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
2109
2109
|
0,
|
|
2110
2110
|
0,
|
|
2111
2111
|
0
|
|
2112
|
-
], l = 1, u = V ? new Uint8Array(8) : q(8), d = V ? new Uint8Array(8) : q(8), f = s.length, p = 0; p < a; ++p) s[
|
|
2112
|
+
], l = 1, u = V ? new Uint8Array(8) : q(8), d = V ? new Uint8Array(8) : q(8), f = s.length, p = 0; p < a; ++p) s[Lh[p]] = o = W(e, t), l < o && (l = o), u[o]++, t += 3;
|
|
2113
2113
|
var m = 0;
|
|
2114
2114
|
for (u[0] = 0, p = 1; p <= l; ++p) d[p] = m = m + u[p - 1] << 1;
|
|
2115
2115
|
for (p = 0; p < f; ++p) (m = s[p]) != 0 && (c[p] = d[m]++);
|
|
@@ -2157,7 +2157,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
2157
2157
|
f -= 257;
|
|
2158
2158
|
var p = f < 8 ? 0 : f - 4 >> 2;
|
|
2159
2159
|
p > 5 && (p = 0);
|
|
2160
|
-
var m = o +
|
|
2160
|
+
var m = o + R[f];
|
|
2161
2161
|
p > 0 && (m += Kh(e, n, p), n += p), d = Kh(e, n, l), f = i >>> 1 == 1 ? Xh[d] : eg[d], n += f & 15, f >>>= 4;
|
|
2162
2162
|
var h = f < 4 ? 0 : f - 2 >> 1, g = B[f];
|
|
2163
2163
|
for (h > 0 && (g += Kh(e, n, h), n += h), !t && s < m && (a = K(a, m + 100), s = a.length); o < m;) a[o] = a[o - g], ++o;
|
|
@@ -2209,7 +2209,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
2209
2209
|
var y = e.slice(e.l, e.l + f);
|
|
2210
2210
|
switch (l) {
|
|
2211
2211
|
case 8:
|
|
2212
|
-
y =
|
|
2212
|
+
y = Ih(e, p);
|
|
2213
2213
|
break;
|
|
2214
2214
|
case 0: break;
|
|
2215
2215
|
default: throw Error("Unsupported ZIP Compression method " + l);
|
|
@@ -2227,7 +2227,7 @@ var CRC32 = /* @__PURE__ */ (function() {
|
|
|
2227
2227
|
for (d = 0; d < h.length; ++d) b.write_shift(1, h.charCodeAt(d) & 127);
|
|
2228
2228
|
b = b.slice(0, b.l), _[p] = CRC32.buf(g.content, 0);
|
|
2229
2229
|
var x = g.content;
|
|
2230
|
-
c == 8 && (x =
|
|
2230
|
+
c == 8 && (x = L(x)), s = new_buf(30), s.write_shift(4, 67324752), s.write_shift(2, 20), s.write_shift(2, l), s.write_shift(2, c), g.mt ? a(s, g.mt) : s.write_shift(4, 0), s.write_shift(-4, l & 8 ? 0 : _[p]), s.write_shift(4, l & 8 ? 0 : x.length), s.write_shift(4, l & 8 ? 0 : g.content.length), s.write_shift(2, b.length), s.write_shift(2, 0), f += s.length, i.push(s), f += b.length, i.push(b), f += x.length, i.push(x), l & 8 && (s = new_buf(12), s.write_shift(-4, _[p]), s.write_shift(4, x.length), s.write_shift(4, g.content.length), f += s.l, i.push(s)), s = new_buf(46), s.write_shift(4, 33639248), s.write_shift(2, 0), s.write_shift(2, 20), s.write_shift(2, l), s.write_shift(2, c), s.write_shift(4, 0), s.write_shift(-4, _[p]), s.write_shift(4, x.length), s.write_shift(4, g.content.length), s.write_shift(2, b.length), s.write_shift(2, 0), s.write_shift(2, 0), s.write_shift(2, 0), s.write_shift(2, 0), s.write_shift(4, 0), s.write_shift(4, y), v += s.l, o.push(s), v += b.length, o.push(b), ++p;
|
|
2231
2231
|
}
|
|
2232
2232
|
return s = new_buf(22), s.write_shift(4, 101010256), s.write_shift(2, 0), s.write_shift(2, 0), s.write_shift(2, p), s.write_shift(2, p), s.write_shift(4, v), s.write_shift(4, f), s.write_shift(2, 0), bconcat([
|
|
2233
2233
|
bconcat(i),
|
|
@@ -13039,23 +13039,16 @@ var buildThemePalette$1 = (e) => {
|
|
|
13039
13039
|
className: AdvancedTable_module_default.filterModal,
|
|
13040
13040
|
ref: h,
|
|
13041
13041
|
children: [
|
|
13042
|
-
/* @__PURE__ */
|
|
13042
|
+
/* @__PURE__ */ jsx("div", {
|
|
13043
13043
|
className: AdvancedTable_module_default.filterModalHeader,
|
|
13044
|
-
children:
|
|
13044
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
13045
13045
|
type: "text",
|
|
13046
13046
|
className: AdvancedTable_module_default.filterSearchInput,
|
|
13047
13047
|
placeholder: `Buscar texto en ${e.toLowerCase()}...`,
|
|
13048
|
-
value: n,
|
|
13049
|
-
onChange: (e) => a(e.target.value),
|
|
13050
|
-
autoFocus: !0
|
|
13051
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
13052
|
-
type: "text",
|
|
13053
|
-
className: AdvancedTable_module_default.filterSearchInput,
|
|
13054
|
-
placeholder: "Buscar opciones...",
|
|
13055
13048
|
value: p,
|
|
13056
13049
|
onChange: (e) => m(e.target.value),
|
|
13057
13050
|
style: { marginTop: "8px" }
|
|
13058
|
-
})
|
|
13051
|
+
})
|
|
13059
13052
|
}),
|
|
13060
13053
|
/* @__PURE__ */ jsxs("div", {
|
|
13061
13054
|
className: AdvancedTable_module_default.filterOptions,
|
|
@@ -13113,7 +13106,7 @@ var buildThemePalette$1 = (e) => {
|
|
|
13113
13106
|
});
|
|
13114
13107
|
};
|
|
13115
13108
|
const useAdvancedTable = (e) => {
|
|
13116
|
-
let { data: t, columns: n, defaultSort: a, defaultFilters:
|
|
13109
|
+
let { data: t, columns: n, defaultSort: a, defaultFilters: u = {}, defaultPageSize: d = 10, pageSizeOptions: f = [
|
|
13117
13110
|
10,
|
|
13118
13111
|
25,
|
|
13119
13112
|
50,
|
|
@@ -13122,74 +13115,92 @@ const useAdvancedTable = (e) => {
|
|
|
13122
13115
|
300,
|
|
13123
13116
|
400,
|
|
13124
13117
|
500
|
|
13125
|
-
], initialConfig:
|
|
13118
|
+
], initialConfig: p, onConfigChange: m, onPaginationChange: h, onFiltersChange: g, fetchData: _, rowKey: v = "id", onRowSelectionChange: y } = e, [b, x] = useState(p?.sort || a || void 0), [S, C] = useState(p?.filters || u), [w, T] = useState(p?.columnOrder || n.map((e) => e.id)), [E, D] = useState(p?.hiddenColumns || []), [O, k] = useState(p?.pinnedColumns || []), [A, j] = useState([]), [M, N] = useState({}), [P, F] = useState({
|
|
13126
13119
|
page: 1,
|
|
13127
|
-
pageSize:
|
|
13128
|
-
total:
|
|
13129
|
-
}), [
|
|
13130
|
-
if (
|
|
13131
|
-
|
|
13120
|
+
pageSize: p?.pagination?.pageSize || d,
|
|
13121
|
+
total: p?.pagination?.total || t.length
|
|
13122
|
+
}), [Dh, I] = useState([]), [Oh, kh] = useState(0), [Ah, jh] = useState(!1), [Mh, Nh] = useState(0), Ph = useCallback(async () => {
|
|
13123
|
+
if (_) {
|
|
13124
|
+
jh(!0);
|
|
13132
13125
|
try {
|
|
13133
13126
|
let e = {
|
|
13134
|
-
page_number:
|
|
13135
|
-
page_size:
|
|
13127
|
+
page_number: P.page,
|
|
13128
|
+
page_size: P.pageSize
|
|
13136
13129
|
};
|
|
13137
|
-
|
|
13130
|
+
b && (e.order_by = `${b.direction === "desc" ? "-" : ""}${b.column}`), Object.entries(S).forEach(([t, n]) => {
|
|
13138
13131
|
n.value && (e[t] = n.value);
|
|
13139
13132
|
});
|
|
13140
|
-
let t = await
|
|
13141
|
-
|
|
13133
|
+
let t = await _(e);
|
|
13134
|
+
I(t.items), kh(t.total_items);
|
|
13142
13135
|
} catch (e) {
|
|
13143
13136
|
console.error("Failed to fetch data:", e);
|
|
13144
13137
|
} finally {
|
|
13145
|
-
|
|
13138
|
+
jh(!1);
|
|
13146
13139
|
}
|
|
13147
13140
|
}
|
|
13148
13141
|
}, [
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
]);
|
|
13142
|
+
_,
|
|
13143
|
+
P.page,
|
|
13144
|
+
P.pageSize,
|
|
13145
|
+
b,
|
|
13146
|
+
S
|
|
13147
|
+
]), Fh = useRef(!0), Ih = useRef(S), L = useRef(b), Lh = useRef(P.page), Rh = useRef(P.pageSize), R = useRef(Mh);
|
|
13155
13148
|
useEffect(() => {
|
|
13156
|
-
|
|
13149
|
+
if (_) {
|
|
13150
|
+
let e = !1, t = JSON.stringify(S) !== JSON.stringify(Ih.current);
|
|
13151
|
+
if (Fh.current) e = !0, Fh.current = !1;
|
|
13152
|
+
else if (Mh !== R.current) e = !0, R.current = Mh;
|
|
13153
|
+
else if (P.page !== Lh.current || P.pageSize !== Rh.current) e = !0;
|
|
13154
|
+
else if (JSON.stringify(b) !== JSON.stringify(L.current)) e = !0;
|
|
13155
|
+
else if (t) {
|
|
13156
|
+
let t = Object.keys(Ih.current), i = Object.keys(S), a = Array.from(new Set([...t, ...i]));
|
|
13157
|
+
for (let t of a) if (JSON.stringify(Ih.current[t]) !== JSON.stringify(S[t]) && n.find((e) => e.id === t)?.shouldBeRefetch === !0) {
|
|
13158
|
+
e = !0;
|
|
13159
|
+
break;
|
|
13160
|
+
}
|
|
13161
|
+
}
|
|
13162
|
+
Lh.current = P.page, Rh.current = P.pageSize, L.current = b, Ih.current = S, e && Ph();
|
|
13163
|
+
}
|
|
13157
13164
|
}, [
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13165
|
+
Ph,
|
|
13166
|
+
Mh,
|
|
13167
|
+
_,
|
|
13168
|
+
P.page,
|
|
13169
|
+
P.pageSize,
|
|
13170
|
+
b,
|
|
13171
|
+
S,
|
|
13172
|
+
n
|
|
13161
13173
|
]), useEffect(() => {
|
|
13162
|
-
|
|
13174
|
+
_ && F((e) => ({
|
|
13163
13175
|
...e,
|
|
13164
|
-
total:
|
|
13176
|
+
total: Oh
|
|
13165
13177
|
}));
|
|
13166
|
-
}, [
|
|
13178
|
+
}, [Oh, _]), useEffect(() => {
|
|
13167
13179
|
let e = n.map((e) => e.id);
|
|
13168
|
-
|
|
13180
|
+
T((t) => {
|
|
13169
13181
|
let n = t.filter((t) => e.includes(t)), i = e.filter((e) => !n.includes(e));
|
|
13170
13182
|
return [...n, ...i];
|
|
13171
|
-
}),
|
|
13183
|
+
}), D((t) => t.filter((t) => e.includes(t))), k((t) => t.filter((t) => e.includes(t)));
|
|
13172
13184
|
}, [n]);
|
|
13173
|
-
let
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
return Object.entries(x).forEach(([t, i]) => {
|
|
13185
|
+
let z = useMemo(() => {
|
|
13186
|
+
let e = [];
|
|
13187
|
+
return e = _ ? [...Dh] : [...t], Object.entries(S).forEach(([t, i]) => {
|
|
13177
13188
|
let a = n.find((e) => e.id === t);
|
|
13178
|
-
a && (e = e.filter((e) => {
|
|
13189
|
+
a && (_ && a.shouldBeRefetch || (e = e.filter((e) => {
|
|
13179
13190
|
let t = typeof a.accessor == "function" ? a.accessor(e) : e[a.accessor], n = String(t || "").toLowerCase(), o = !0;
|
|
13180
13191
|
return i.type === "text" && i.value && (o &&= n.includes(String(i.value).toLowerCase())), i.type === "select" && i.value && (o &&= n === String(i.value).toLowerCase()), i.type === "multiselect" && Array.isArray(i.value) && i.value.length > 0 && (o &&= i.value.some((e) => n === String(e).toLowerCase())), o;
|
|
13181
|
-
}));
|
|
13192
|
+
})));
|
|
13182
13193
|
}), e;
|
|
13183
13194
|
}, [
|
|
13184
13195
|
t,
|
|
13185
|
-
|
|
13196
|
+
S,
|
|
13186
13197
|
n,
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
]),
|
|
13190
|
-
if (
|
|
13191
|
-
let e = n.find((e) => e.id ===
|
|
13192
|
-
return e ? [...
|
|
13198
|
+
_,
|
|
13199
|
+
Dh
|
|
13200
|
+
]), zh = useMemo(() => {
|
|
13201
|
+
if (_ || !b) return z;
|
|
13202
|
+
let e = n.find((e) => e.id === b.column);
|
|
13203
|
+
return e ? [...z].sort((t, n) => {
|
|
13193
13204
|
let i = typeof e.accessor == "function" ? e.accessor(t) : t[e.accessor], a = typeof e.accessor == "function" ? e.accessor(n) : n[e.accessor];
|
|
13194
13205
|
if (i == null) return 1;
|
|
13195
13206
|
if (a == null) return -1;
|
|
@@ -13201,159 +13212,159 @@ const useAdvancedTable = (e) => {
|
|
|
13201
13212
|
let e = String(i).toLowerCase(), t = String(a).toLowerCase();
|
|
13202
13213
|
o = e.localeCompare(t);
|
|
13203
13214
|
}
|
|
13204
|
-
return
|
|
13205
|
-
}) :
|
|
13215
|
+
return b.direction === "desc" ? o * -1 : o;
|
|
13216
|
+
}) : z;
|
|
13206
13217
|
}, [
|
|
13207
|
-
|
|
13208
|
-
|
|
13218
|
+
z,
|
|
13219
|
+
b,
|
|
13209
13220
|
n,
|
|
13210
|
-
|
|
13211
|
-
]),
|
|
13212
|
-
if (
|
|
13213
|
-
let e = (
|
|
13214
|
-
return
|
|
13221
|
+
_
|
|
13222
|
+
]), B = useMemo(() => {
|
|
13223
|
+
if (_) return zh;
|
|
13224
|
+
let e = (P.page - 1) * P.pageSize, t = e + P.pageSize;
|
|
13225
|
+
return zh.slice(e, t);
|
|
13215
13226
|
}, [
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13227
|
+
zh,
|
|
13228
|
+
P.page,
|
|
13229
|
+
P.pageSize,
|
|
13230
|
+
_
|
|
13220
13231
|
]);
|
|
13221
13232
|
useEffect(() => {
|
|
13222
|
-
|
|
13233
|
+
_ || F((e) => ({
|
|
13223
13234
|
...e,
|
|
13224
|
-
total:
|
|
13225
|
-
page: Math.min(e.page, Math.ceil(
|
|
13235
|
+
total: z.length,
|
|
13236
|
+
page: Math.min(e.page, Math.ceil(z.length / e.pageSize) || 1)
|
|
13226
13237
|
}));
|
|
13227
|
-
}, [
|
|
13228
|
-
|
|
13238
|
+
}, [z.length, _]), useEffect(() => {
|
|
13239
|
+
m?.({
|
|
13229
13240
|
columns: n,
|
|
13230
|
-
sort:
|
|
13231
|
-
filters:
|
|
13232
|
-
pagination:
|
|
13233
|
-
columnOrder:
|
|
13234
|
-
hiddenColumns:
|
|
13235
|
-
pinnedColumns:
|
|
13241
|
+
sort: b,
|
|
13242
|
+
filters: S,
|
|
13243
|
+
pagination: P,
|
|
13244
|
+
columnOrder: w,
|
|
13245
|
+
hiddenColumns: E,
|
|
13246
|
+
pinnedColumns: O
|
|
13236
13247
|
});
|
|
13237
13248
|
}, [
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13249
|
+
b,
|
|
13250
|
+
S,
|
|
13251
|
+
w,
|
|
13252
|
+
E,
|
|
13253
|
+
O,
|
|
13254
|
+
P.pageSize,
|
|
13255
|
+
m,
|
|
13256
|
+
P,
|
|
13246
13257
|
n
|
|
13247
13258
|
]), useEffect(() => {
|
|
13248
|
-
|
|
13249
|
-
}, [
|
|
13250
|
-
|
|
13251
|
-
}, [
|
|
13252
|
-
let
|
|
13253
|
-
|
|
13259
|
+
h?.(P);
|
|
13260
|
+
}, [P, h]), useEffect(() => {
|
|
13261
|
+
g?.(S);
|
|
13262
|
+
}, [S, g]);
|
|
13263
|
+
let Bh = useCallback((e) => {
|
|
13264
|
+
x((t) => t?.column === e ? t.direction === "asc" ? {
|
|
13254
13265
|
column: e,
|
|
13255
13266
|
direction: "desc"
|
|
13256
13267
|
} : void 0 : {
|
|
13257
13268
|
column: e,
|
|
13258
13269
|
direction: "asc"
|
|
13259
13270
|
});
|
|
13260
|
-
}, []),
|
|
13261
|
-
|
|
13271
|
+
}, []), V = useCallback((e, t, n = "text") => {
|
|
13272
|
+
C((i) => ({
|
|
13262
13273
|
...i,
|
|
13263
13274
|
[e]: {
|
|
13264
13275
|
type: n,
|
|
13265
13276
|
value: t,
|
|
13266
13277
|
options: i[e]?.options
|
|
13267
13278
|
}
|
|
13268
|
-
})),
|
|
13279
|
+
})), F((e) => ({
|
|
13269
13280
|
...e,
|
|
13270
13281
|
page: 1
|
|
13271
13282
|
}));
|
|
13272
|
-
}, []),
|
|
13273
|
-
|
|
13283
|
+
}, []), H = useCallback((e) => {
|
|
13284
|
+
C((t) => {
|
|
13274
13285
|
let n = { ...t };
|
|
13275
13286
|
return delete n[e], n;
|
|
13276
13287
|
});
|
|
13277
|
-
}, []),
|
|
13278
|
-
|
|
13279
|
-
}, []),
|
|
13280
|
-
|
|
13288
|
+
}, []), U = useCallback(() => {
|
|
13289
|
+
C({});
|
|
13290
|
+
}, []), Vh = useCallback((e) => {
|
|
13291
|
+
F((t) => ({
|
|
13281
13292
|
...t,
|
|
13282
13293
|
page: e
|
|
13283
13294
|
}));
|
|
13284
|
-
}, []),
|
|
13285
|
-
|
|
13295
|
+
}, []), Hh = useCallback((e) => {
|
|
13296
|
+
F((t) => ({
|
|
13286
13297
|
...t,
|
|
13287
13298
|
pageSize: e,
|
|
13288
13299
|
page: 1
|
|
13289
13300
|
}));
|
|
13290
|
-
}, []),
|
|
13291
|
-
|
|
13292
|
-
}, []),
|
|
13293
|
-
|
|
13294
|
-
}, []),
|
|
13295
|
-
|
|
13296
|
-
}, []),
|
|
13297
|
-
|
|
13301
|
+
}, []), W = useCallback((e) => {
|
|
13302
|
+
T(e);
|
|
13303
|
+
}, []), Uh = useCallback((e) => {
|
|
13304
|
+
D((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
13305
|
+
}, []), Wh = useCallback((e) => {
|
|
13306
|
+
k((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
13307
|
+
}, []), Gh = useCallback((e) => {
|
|
13308
|
+
j((t) => {
|
|
13298
13309
|
let n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
|
|
13299
|
-
return
|
|
13310
|
+
return y?.(n), n;
|
|
13300
13311
|
});
|
|
13301
|
-
}, [
|
|
13302
|
-
|
|
13303
|
-
let n = e.map((e) => typeof
|
|
13312
|
+
}, [y]), Kh = useCallback((e) => {
|
|
13313
|
+
j((t) => {
|
|
13314
|
+
let n = e.map((e) => typeof v == "function" ? v(e) : e[v]), i = n.every((e) => t.includes(e)), a;
|
|
13304
13315
|
if (i) a = t.filter((e) => !n.includes(e));
|
|
13305
13316
|
else {
|
|
13306
13317
|
let e = n.filter((e) => !t.includes(e));
|
|
13307
13318
|
a = [...t, ...e];
|
|
13308
13319
|
}
|
|
13309
|
-
return
|
|
13320
|
+
return y?.(a), a;
|
|
13310
13321
|
});
|
|
13311
|
-
}, [
|
|
13312
|
-
|
|
13322
|
+
}, [v, y]), qh = useCallback((e, t) => {
|
|
13323
|
+
N((n) => ({
|
|
13313
13324
|
...n,
|
|
13314
13325
|
[e]: Math.max(50, t)
|
|
13315
13326
|
}));
|
|
13316
|
-
}, []),
|
|
13317
|
-
let e = new Map(n.map((e) => [e.id, e])), t =
|
|
13318
|
-
return [...t, ...a].filter((e) => !
|
|
13327
|
+
}, []), Jh = useMemo(() => {
|
|
13328
|
+
let e = new Map(n.map((e) => [e.id, e])), t = w.map((t) => e.get(t)).filter(Boolean), i = new Set(t.map((e) => e.id)), a = n.filter((e) => !i.has(e.id));
|
|
13329
|
+
return [...t, ...a].filter((e) => !E.includes(e.id));
|
|
13319
13330
|
}, [
|
|
13320
|
-
|
|
13331
|
+
w,
|
|
13321
13332
|
n,
|
|
13322
|
-
|
|
13323
|
-
]),
|
|
13324
|
-
|
|
13333
|
+
E
|
|
13334
|
+
]), G = useCallback(() => {
|
|
13335
|
+
Nh((e) => e + 1);
|
|
13325
13336
|
}, []);
|
|
13326
13337
|
return {
|
|
13327
13338
|
state: {
|
|
13328
13339
|
data: t,
|
|
13329
|
-
filteredData:
|
|
13330
|
-
paginatedData:
|
|
13331
|
-
sortConfig:
|
|
13332
|
-
filters:
|
|
13333
|
-
pagination:
|
|
13334
|
-
columnOrder:
|
|
13335
|
-
hiddenColumns:
|
|
13336
|
-
pinnedColumns:
|
|
13337
|
-
selectedRows:
|
|
13338
|
-
columnWidths:
|
|
13339
|
-
loading:
|
|
13340
|
+
filteredData: z,
|
|
13341
|
+
paginatedData: B,
|
|
13342
|
+
sortConfig: b,
|
|
13343
|
+
filters: S,
|
|
13344
|
+
pagination: P,
|
|
13345
|
+
columnOrder: w,
|
|
13346
|
+
hiddenColumns: E,
|
|
13347
|
+
pinnedColumns: O,
|
|
13348
|
+
selectedRows: A,
|
|
13349
|
+
columnWidths: M,
|
|
13350
|
+
loading: Ah
|
|
13340
13351
|
},
|
|
13341
|
-
orderedColumns:
|
|
13342
|
-
pageSizeOptions:
|
|
13343
|
-
handleSort:
|
|
13344
|
-
handleFilter:
|
|
13345
|
-
clearFilter:
|
|
13346
|
-
clearAllFilters:
|
|
13347
|
-
handlePageChange:
|
|
13348
|
-
handlePageSizeChange:
|
|
13349
|
-
handleColumnReorder:
|
|
13350
|
-
handleToggleColumn:
|
|
13351
|
-
handleTogglePin:
|
|
13352
|
-
handleRowSelect:
|
|
13353
|
-
handleSelectAll:
|
|
13354
|
-
handleColumnResize:
|
|
13352
|
+
orderedColumns: Jh,
|
|
13353
|
+
pageSizeOptions: f,
|
|
13354
|
+
handleSort: Bh,
|
|
13355
|
+
handleFilter: V,
|
|
13356
|
+
clearFilter: H,
|
|
13357
|
+
clearAllFilters: U,
|
|
13358
|
+
handlePageChange: Vh,
|
|
13359
|
+
handlePageSizeChange: Hh,
|
|
13360
|
+
handleColumnReorder: W,
|
|
13361
|
+
handleToggleColumn: Uh,
|
|
13362
|
+
handleTogglePin: Wh,
|
|
13363
|
+
handleRowSelect: Gh,
|
|
13364
|
+
handleSelectAll: Kh,
|
|
13365
|
+
handleColumnResize: qh,
|
|
13355
13366
|
allColumns: n,
|
|
13356
|
-
refresh:
|
|
13367
|
+
refresh: G
|
|
13357
13368
|
};
|
|
13358
13369
|
};
|
|
13359
13370
|
var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilters: i = {}, defaultPageSize: a = 10, pageSizeOptions: u = [
|
|
@@ -13379,7 +13390,7 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13379
13390
|
clearAllFilters: "Limpiar todos los filtros",
|
|
13380
13391
|
noData: "No hay datos disponibles"
|
|
13381
13392
|
}, enableColumnReordering: A = !0, enableColumnPinning: j = !1, enableColumnResizing: M = !1, enableRowSelection: N = !1, stickyActionsColumn: P = !1, rowKey: F = "id", onRowSelectionChange: Dh, renderActions: I, actionsColumnLabel: Oh, loading: kh = !1, fetchData: Ah, onRefresh: jh, onPaginationChange: Mh, onFiltersChange: Nh }) => {
|
|
13382
|
-
let [
|
|
13393
|
+
let [Ph, Fh] = useState(null), [Ih, L] = useState(null), [Lh, Rh] = useState(!1), [R, z] = useState(null), zh = useRef(null), [B, Bh] = useState(t), { state: V, orderedColumns: H, handleSort: U, handleFilter: Vh, clearAllFilters: Hh, handlePageChange: W, handlePageSizeChange: Uh, handleColumnReorder: Wh, handleToggleColumn: Gh, handleTogglePin: Kh, handleRowSelect: qh, handleSelectAll: Jh, handleColumnResize: G, refresh: Yh } = useAdvancedTable({
|
|
13383
13394
|
data: e,
|
|
13384
13395
|
columns: B,
|
|
13385
13396
|
defaultSort: n,
|
|
@@ -13400,11 +13411,11 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13400
13411
|
return N && n.unshift({
|
|
13401
13412
|
id: "selection-synthetic",
|
|
13402
13413
|
label: "",
|
|
13403
|
-
accessor: (e) => e,
|
|
13414
|
+
accessor: (e) => e[F],
|
|
13404
13415
|
width: 50,
|
|
13405
13416
|
minWidth: 50,
|
|
13406
13417
|
render: ({ row: e }) => {
|
|
13407
|
-
let t =
|
|
13418
|
+
let t = e[F];
|
|
13408
13419
|
return /* @__PURE__ */ jsx("input", {
|
|
13409
13420
|
type: "checkbox",
|
|
13410
13421
|
className: "w-4 h-4 accent-redi-primary cursor-pointer",
|
|
@@ -13422,7 +13433,7 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13422
13433
|
}), I && n.push({
|
|
13423
13434
|
id: "actions-synthetic",
|
|
13424
13435
|
label: Oh || "",
|
|
13425
|
-
accessor: (e) => e,
|
|
13436
|
+
accessor: (e) => e[F],
|
|
13426
13437
|
render: ({ row: e, column: t, index: n }) => I({
|
|
13427
13438
|
row: e,
|
|
13428
13439
|
index: n,
|
|
@@ -13462,28 +13473,28 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13462
13473
|
startWidth: n
|
|
13463
13474
|
}, document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
13464
13475
|
}, rg = (e, t) => {
|
|
13465
|
-
|
|
13476
|
+
Fh(t), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/html", "");
|
|
13466
13477
|
}, ig = (e, t) => {
|
|
13467
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move",
|
|
13478
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", L(t);
|
|
13468
13479
|
}, ag = () => {
|
|
13469
|
-
|
|
13480
|
+
L(null);
|
|
13470
13481
|
}, og = (e, t) => {
|
|
13471
|
-
if (e.preventDefault(),
|
|
13472
|
-
let n = Z[
|
|
13482
|
+
if (e.preventDefault(), Ph === null) return;
|
|
13483
|
+
let n = Z[Ph].id, i = Z[t].id;
|
|
13473
13484
|
if (n === i) {
|
|
13474
|
-
|
|
13485
|
+
Fh(null), L(null);
|
|
13475
13486
|
return;
|
|
13476
13487
|
}
|
|
13477
13488
|
let a = e.currentTarget.getBoundingClientRect(), o = e.clientX - a.left > a.width / 2, s = [...V.columnOrder], c = s.indexOf(n), l = s.indexOf(i);
|
|
13478
|
-
c === -1 || l === -1 || (s.splice(c, 1), l = s.indexOf(i), o ? s.splice(l + 1, 0, n) : s.splice(l, 0, n), Wh(s),
|
|
13489
|
+
c === -1 || l === -1 || (s.splice(c, 1), l = s.indexOf(i), o ? s.splice(l + 1, 0, n) : s.splice(l, 0, n), Wh(s), Fh(null), L(null));
|
|
13479
13490
|
}, sg = () => {
|
|
13480
|
-
|
|
13491
|
+
Fh(null), L(null);
|
|
13481
13492
|
}, cg = () => {
|
|
13482
13493
|
if (!T) return;
|
|
13483
13494
|
let e = Z.filter((e) => !e.isAction);
|
|
13484
13495
|
exportToExcel(V.filteredData, e, "table-data.xlsx");
|
|
13485
13496
|
}, lg = (e) => {
|
|
13486
|
-
|
|
13497
|
+
z(R === e ? null : e);
|
|
13487
13498
|
}, ug = (t) => {
|
|
13488
13499
|
let n = B.find((e) => e.id === t);
|
|
13489
13500
|
if (!n) return [];
|
|
@@ -13499,12 +13510,12 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13499
13510
|
}, dg = Object.values(J).some((e) => e.type === "text" && e.value || e.type === "select" && e.value || e.type === "multiselect" && Array.isArray(e.value) && e.value.length > 0);
|
|
13500
13511
|
useEffect(() => {
|
|
13501
13512
|
let e = (e) => {
|
|
13502
|
-
zh.current && !zh.current.contains(e.target) &&
|
|
13513
|
+
zh.current && !zh.current.contains(e.target) && Rh(!1);
|
|
13503
13514
|
};
|
|
13504
|
-
return
|
|
13515
|
+
return Lh && document.addEventListener("mousedown", e), () => {
|
|
13505
13516
|
document.removeEventListener("mousedown", e);
|
|
13506
13517
|
};
|
|
13507
|
-
}, [
|
|
13518
|
+
}, [Lh]);
|
|
13508
13519
|
let Q = Math.ceil(Y.total / Y.pageSize), fg = (e) => Qh[e.id] ? Qh[e.id] : e.width ? e.width : e.isAction ? 100 : 150 + (e.filterable ? 50 : 0);
|
|
13509
13520
|
return /* @__PURE__ */ jsxs("div", {
|
|
13510
13521
|
className: `w-full bg-redi-background border border-solid border-gray-500 rounded-xl overflow-hidden font-family-base shadow ${O}`,
|
|
@@ -13526,12 +13537,12 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13526
13537
|
className: "relative",
|
|
13527
13538
|
children: [/* @__PURE__ */ jsxs(Button_default, {
|
|
13528
13539
|
level: "secondary",
|
|
13529
|
-
onClick: () =>
|
|
13540
|
+
onClick: () => Rh(!Lh),
|
|
13530
13541
|
children: [/* @__PURE__ */ jsx(EyeIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
13531
13542
|
className: "hidden md:block",
|
|
13532
13543
|
children: k.configuration
|
|
13533
13544
|
})]
|
|
13534
|
-
}),
|
|
13545
|
+
}), Lh && /* @__PURE__ */ jsx("div", {
|
|
13535
13546
|
className: "absolute top-full left-0 bg-white border border-solid border-gray-300 rounded-md shadow-lg z-1000 mt-2 min-w-2xs max-w-xs opacity-100 visible p-4",
|
|
13536
13547
|
ref: zh,
|
|
13537
13548
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -13659,9 +13670,9 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13659
13670
|
};
|
|
13660
13671
|
return /* @__PURE__ */ jsx("th", {
|
|
13661
13672
|
className: `bg-gray-50 border-b border-solid border-gray-200 text-left font-semibold text-redi-text p-0 sticky top-0 z-10 select-none hover:bg-gray-200
|
|
13662
|
-
${
|
|
13663
|
-
${
|
|
13664
|
-
${
|
|
13673
|
+
${Ph === t ? "opacity-50 bg-gray-300" : ""}
|
|
13674
|
+
${Ih === t ? "bg-redi-primary-bg border-l border-solid border-redi-primary" : ""}
|
|
13675
|
+
${Ih === t ? "bg-redi-primary-bg border-l border-solid border-redi-primary" : ""}
|
|
13665
13676
|
${i ? "shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]" : ""}
|
|
13666
13677
|
`,
|
|
13667
13678
|
style: o,
|
|
@@ -13718,7 +13729,7 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13718
13729
|
},
|
|
13719
13730
|
"aria-label": `Filter by ${e.label}`,
|
|
13720
13731
|
children: /* @__PURE__ */ jsx(FilterIcon, { size: 16 })
|
|
13721
|
-
}),
|
|
13732
|
+
}), R === e.id && /* @__PURE__ */ jsx(AdvancedFilter_default, {
|
|
13722
13733
|
columnId: e.id,
|
|
13723
13734
|
label: e.label,
|
|
13724
13735
|
options: ug(e.id),
|
|
@@ -13726,7 +13737,7 @@ var AdvancedTable_default = ({ data: e, columns: t, defaultSort: n, defaultFilte
|
|
|
13726
13737
|
selectedValues: J[e.id]?.type === "multiselect" && Array.isArray(J[e.id]?.value) ? J[e.id].value : [],
|
|
13727
13738
|
onTextChange: (t) => Vh(e.id, t, "text"),
|
|
13728
13739
|
onSelectionChange: (t) => Vh(e.id, t, "multiselect"),
|
|
13729
|
-
onClose: () =>
|
|
13740
|
+
onClose: () => z(null)
|
|
13730
13741
|
})]
|
|
13731
13742
|
})
|
|
13732
13743
|
})]
|