@gisce/react-formiga-table
Advanced tools
Comparing version 1.6.0-alpha.2 to 1.6.0-alpha.3
import { jsx as g, jsxs as _, Fragment as pe } from "react/jsx-runtime"; | ||
import W, { useState as T, useRef as K, useEffect as O, useCallback as b, forwardRef as he, useImperativeHandle as me, memo as Z, useMemo as ce } from "react"; | ||
import W, { useState as T, useRef as K, useEffect as O, useCallback as b, forwardRef as he, useImperativeHandle as ye, memo as Z, useMemo as ce } from "react"; | ||
import Ae from "use-deep-compare-effect"; | ||
@@ -9,3 +9,3 @@ import Me from "style-object-to-css-string"; | ||
import { useCustomCompareMemo as Pe } from "use-custom-compare"; | ||
import ye from "lodash/debounce"; | ||
import me from "lodash/debounce"; | ||
import { useDeepCompareCallback as ae } from "use-deep-compare"; | ||
@@ -42,3 +42,3 @@ const $e = ({ | ||
[s] | ||
), m = b( | ||
), y = b( | ||
(f) => s.includes(f), | ||
@@ -51,3 +51,3 @@ [s] | ||
(f) => { | ||
const c = o.find((y) => y.id === f); | ||
const c = o.find((m) => m.id === f); | ||
return c ? c[n] !== void 0 && c[n].length > 0 : !1; | ||
@@ -58,3 +58,3 @@ }, | ||
(f) => { | ||
const c = o.find((y) => y.id === f); | ||
const c = o.find((m) => m.id === f); | ||
return c ? c.isLoading : !1; | ||
@@ -68,4 +68,4 @@ }, | ||
return []; | ||
const y = c[n]; | ||
return y ? o.filter((I) => y.includes(I.id)) : []; | ||
const m = c[n]; | ||
return m ? o.filter((I) => m.includes(I.id)) : []; | ||
}, | ||
@@ -75,7 +75,7 @@ [n, o] | ||
async (f) => { | ||
const c = o.find((y) => y.id === f.id); | ||
const c = o.find((m) => m.id === f.id); | ||
if (!c) | ||
return !1; | ||
if (!c.isLoading) { | ||
if (!m(f.id) && !k(c.id)) { | ||
if (!y(f.id) && !k(c.id)) { | ||
u( | ||
@@ -91,4 +91,4 @@ G( | ||
try { | ||
const y = await (t == null ? void 0 : t(c)) || []; | ||
y.forEach((I) => { | ||
const m = await (t == null ? void 0 : t(c)) || []; | ||
m.forEach((I) => { | ||
r.current.set(I.id, c.level + 1); | ||
@@ -103,3 +103,3 @@ }), u( | ||
...o, | ||
...y.map((I) => Y({ | ||
...m.map((I) => Y({ | ||
entry: I, | ||
@@ -112,4 +112,4 @@ childField: n, | ||
), l.push(c.id), i([...l]); | ||
} catch (y) { | ||
console.error(y), u( | ||
} catch (m) { | ||
console.error(m), u( | ||
G( | ||
@@ -130,3 +130,3 @@ { | ||
o, | ||
m, | ||
y, | ||
k, | ||
@@ -139,8 +139,8 @@ p, | ||
), C = b( | ||
(f) => S(f.id) ? "loading" : v(f.id) ? m(f.id) ? "collapse" : "expand" : "none", | ||
[S, v, m] | ||
(f) => S(f.id) ? "loading" : v(f.id) ? y(f.id) ? "collapse" : "expand" : "none", | ||
[S, v, y] | ||
), w = b(() => { | ||
const c = o.filter((y) => y.level === 0).map((y) => y.id); | ||
return s.forEach((y) => { | ||
const I = o.find((D) => D.id === y); | ||
const c = o.filter((m) => m.level === 0).map((m) => m.id); | ||
return s.forEach((m) => { | ||
const I = o.find((D) => D.id === m); | ||
I && I.child_id && I.child_id.forEach((D) => { | ||
@@ -152,3 +152,3 @@ c.includes(D) || c.push(D); | ||
return { | ||
keyIsOpened: m, | ||
keyIsOpened: y, | ||
onExpandableIconClicked: h, | ||
@@ -226,5 +226,5 @@ getExpandableStatusForRow: C, | ||
if (p.nativeEvent.shiftKey) { | ||
const m = e.findIndex((x) => x === u), k = e.findIndex((x) => x === n), d = e.findIndex( | ||
const y = e.findIndex((x) => x === u), k = e.findIndex((x) => x === n), d = e.findIndex( | ||
(x) => x === i | ||
), v = Math.min(m, k), S = Math.max(m, k); | ||
), v = Math.min(y, k), S = Math.max(y, k); | ||
if (v > -1 && S > -1) { | ||
@@ -449,3 +449,3 @@ t(a, e.slice(v, S + 1)), d > S && t( | ||
u && /* @__PURE__ */ g("th", { style: { ...p } }, "th-status"), | ||
n.map((m) => /* @__PURE__ */ g( | ||
n.map((y) => /* @__PURE__ */ g( | ||
"th", | ||
@@ -455,3 +455,3 @@ { | ||
onClick: r ? () => { | ||
l(m.key); | ||
l(y.key); | ||
} : void 0, | ||
@@ -468,3 +468,3 @@ children: /* @__PURE__ */ _("div", { className: "ctx", children: [ | ||
}, | ||
children: m.title | ||
children: y.title | ||
} | ||
@@ -477,12 +477,12 @@ ), | ||
style: { | ||
visibility: i(m.key) !== void 0 ? void 0 : "hidden", | ||
visibility: i(y.key) !== void 0 ? void 0 : "hidden", | ||
marginLeft: "auto" | ||
}, | ||
children: i(m.key) !== void 0 && i(m.key).desc ? " ▼" : " ▲" | ||
children: i(y.key) !== void 0 && i(y.key).desc ? " ▼" : " ▲" | ||
}, | ||
m.key | ||
y.key | ||
) }) | ||
] }) | ||
}, | ||
m.key | ||
y.key | ||
)) | ||
@@ -502,3 +502,3 @@ ] }), de = ({ | ||
}) => { | ||
const m = a(e.key) !== void 0 ? { | ||
const y = a(e.key) !== void 0 ? { | ||
backgroundColor: u ? "#E6F7FF" : "#fafafa" | ||
@@ -514,3 +514,3 @@ } : u ? { | ||
value: t[e.key] | ||
}) : e.render ? k = e.render(t[e.key]) : k = t[e.key], /* @__PURE__ */ _("td", { style: m, children: [ | ||
}) : e.render ? k = e.render(t[e.key]) : k = t[e.key], /* @__PURE__ */ _("td", { style: y, children: [ | ||
/* @__PURE__ */ g( | ||
@@ -608,3 +608,3 @@ je, | ||
onExpandableIconClicked: p, | ||
getExpandableStatusForRow: m, | ||
getExpandableStatusForRow: y, | ||
keyIsOpened: k, | ||
@@ -626,3 +626,3 @@ getChildsForParent: d, | ||
expandableOpts: u, | ||
getExpandableStatusForRow: m, | ||
getExpandableStatusForRow: y, | ||
onExpandableIconClicked: p, | ||
@@ -647,3 +647,3 @@ getColumnSorter: s, | ||
keyIsOpened: p, | ||
getChildsForParent: m, | ||
getChildsForParent: y, | ||
onRowStyle: k, | ||
@@ -676,4 +676,4 @@ onRowStatus: d, | ||
}, | ||
onDoubleClick: (y) => { | ||
y.stopPropagation(), y.preventDefault(); | ||
onDoubleClick: (m) => { | ||
m.stopPropagation(), m.preventDefault(); | ||
}, | ||
@@ -693,4 +693,4 @@ children: /* @__PURE__ */ g( | ||
value: w, | ||
onChange: (y) => { | ||
l(e.id, y); | ||
onChange: (m) => { | ||
l(e.id, m); | ||
} | ||
@@ -721,6 +721,6 @@ } | ||
) }, `status-${e.id}`), | ||
t.map((y, I) => /* @__PURE__ */ g(ue, { children: /* @__PURE__ */ g( | ||
t.map((m, I) => /* @__PURE__ */ g(ue, { children: /* @__PURE__ */ g( | ||
de, | ||
{ | ||
column: y, | ||
column: m, | ||
columnIdx: I, | ||
@@ -736,3 +736,3 @@ row: e, | ||
} | ||
) }, `${y.key}-${e.id}`)) | ||
) }, `${m.key}-${e.id}`)) | ||
] | ||
@@ -744,4 +744,4 @@ }, | ||
return i !== void 0 && p(e.id) && (f = f.concat( | ||
(c = m(e.id)) == null ? void 0 : c.map((y) => be({ | ||
row: y.data, | ||
(c = y(e.id)) == null ? void 0 : c.map((m) => be({ | ||
row: m.data, | ||
columns: t, | ||
@@ -758,4 +758,4 @@ onRowStyle: k, | ||
keyIsOpened: p, | ||
getChildsForParent: m, | ||
level: y.level, | ||
getChildsForParent: y, | ||
level: m.level, | ||
onCellRender: S, | ||
@@ -777,3 +777,3 @@ onRowStatus: d | ||
onRowSelectionChange: p, | ||
onChangeSort: m, | ||
onChangeSort: y, | ||
sorter: k, | ||
@@ -793,3 +793,3 @@ expandableOpts: d, | ||
}); | ||
me(t, () => ({ | ||
ye(t, () => ({ | ||
unselectAll: () => { | ||
@@ -799,12 +799,12 @@ w([]); | ||
})); | ||
const y = Be( | ||
l.map((H) => H.id), | ||
const m = Be( | ||
l.map((B) => B.id), | ||
c | ||
), { localSorter: I, getColumnSorter: D, handleColumnClick: B } = Fe(k), { | ||
), { localSorter: I, getColumnSorter: D, handleColumnClick: F } = Fe(k), { | ||
keyIsOpened: q, | ||
onExpandableIconClicked: J, | ||
getExpandableStatusForRow: F, | ||
getChildsForParent: z, | ||
getExpandableStatusForRow: z, | ||
getChildsForParent: X, | ||
getAllVisibleKeys: P, | ||
getLevelForKey: X | ||
getLevelForKey: Q | ||
} = $e({ | ||
@@ -818,3 +818,3 @@ dataSource: l, | ||
}, [C]), O(() => { | ||
m == null || m(I); | ||
y == null || y(I); | ||
}, [I]); | ||
@@ -840,3 +840,3 @@ const R = b(() => C.length === 0 ? !1 : d ? P().length === C.length : l.length === C.length, [l.length, d, C.length]), $ = b(() => { | ||
toggleAllRowsSelected: $, | ||
handleColumnClick: B, | ||
handleColumnClick: F, | ||
getColumnSorter: D, | ||
@@ -860,9 +860,9 @@ sortEnabled: d === void 0, | ||
isRowSelected: f, | ||
toggleRowSelected: y, | ||
toggleRowSelected: m, | ||
expandableOpts: d, | ||
onExpandableIconClicked: J, | ||
getExpandableStatusForRow: F, | ||
getExpandableStatusForRow: z, | ||
keyIsOpened: q, | ||
getChildsForParent: z, | ||
getLevelForKey: X, | ||
getChildsForParent: X, | ||
getLevelForKey: Q, | ||
onCellRender: v, | ||
@@ -941,7 +941,7 @@ cellStyle: h == null ? void 0 : h.cellStyle, | ||
a | ||
), u = K(!1), p = K([]), m = K(!1), k = K(null); | ||
), u = K(!1), p = K([]), y = K(!1), k = K(null); | ||
O(() => { | ||
u.current = r; | ||
}, [r]), O(() => { | ||
o(a), a && (i([]), m.current = !0); | ||
o(a), a && (i([]), y.current = !0); | ||
}, [a]), O(() => { | ||
@@ -953,10 +953,10 @@ n == null || n(r); | ||
let h = !1; | ||
r ? h = !1 : !r && l.length === 0 ? h = !0 : !r && l.length === s ? h = !1 : (r || l.length > 0) && (h = !0), m.current = !0, (C = e == null ? void 0 : e.current) == null || C.api.forEachNode((w) => { | ||
r ? h = !1 : !r && l.length === 0 ? h = !0 : !r && l.length === s ? h = !1 : (r || l.length > 0) && (h = !0), y.current = !0, (C = e == null ? void 0 : e.current) == null || C.api.forEachNode((w) => { | ||
w.setSelected(h); | ||
}), o(h), k.current && clearTimeout(k.current), k.current = setTimeout(() => { | ||
m.current = !1; | ||
y.current = !1; | ||
}, 1e3); | ||
}, [r, l.length, s, e]), v = b( | ||
(h) => { | ||
if (m.current) { | ||
if (y.current) { | ||
t == null || t([]), i([]); | ||
@@ -975,3 +975,3 @@ return; | ||
), S = b( | ||
ye((h) => { | ||
me((h) => { | ||
v == null || v(h); | ||
@@ -1040,3 +1040,3 @@ }, Je), | ||
}); | ||
}, [e, u]), m = ae(() => { | ||
}, [e, u]), y = ae(() => { | ||
u(() => { | ||
@@ -1050,5 +1050,5 @@ var S, x, h, C; | ||
if (v > 0) { | ||
const w = v / (d.length - r.length), c = ((h = e == null ? void 0 : e.current) == null ? void 0 : h.api.getColumnState()).map((y) => ({ | ||
...y, | ||
width: r.includes(y.colId) ? y.width : y.width + w | ||
const w = v / (d.length - r.length), c = ((h = e == null ? void 0 : e.current) == null ? void 0 : h.api.getColumnState()).map((m) => ({ | ||
...m, | ||
width: r.includes(m.colId) ? m.width : m.width + w | ||
})); | ||
@@ -1068,4 +1068,4 @@ (C = e == null ? void 0 : e.current) == null || C.api.applyColumnState({ state: c }); | ||
} | ||
!i.current && !l.current && (l.current = !0, m()); | ||
}, [m, p, s, a]) | ||
!i.current && !l.current && (l.current = !0, y()); | ||
}, [y, p, s, a]) | ||
}; | ||
@@ -1084,3 +1084,3 @@ }, fe = 50, Se = he( | ||
onChangeFirstVisibleRowIndex: p, | ||
onGetFirstVisibleRowIndex: m, | ||
onGetFirstVisibleRowIndex: y, | ||
onGetSelectedRowKeys: k, | ||
@@ -1095,6 +1095,6 @@ totalRows: d, | ||
hasStatusColumn: f = !1 | ||
} = e, c = K(null), y = K(!0), I = K(!1), D = K(null), B = K(!1), q = x ? i + h : i, J = x ? i - h : i, F = b( | ||
ye((E) => { | ||
if (!B.current) { | ||
B.current = !0; | ||
} = e, c = K(null), m = K(!0), I = K(!1), D = K(null), F = K(!1), q = x ? i + h : i, J = x ? i - h : i, z = b( | ||
me((E) => { | ||
if (!F.current) { | ||
F.current = !0; | ||
return; | ||
@@ -1105,8 +1105,12 @@ } | ||
[o] | ||
), z = b(() => { | ||
var L; | ||
const E = (L = c == null ? void 0 : c.current) == null ? void 0 : L.api.getColumnState(); | ||
F(E); | ||
}, [F]); | ||
me(t, () => ({ | ||
), X = b( | ||
(E) => { | ||
var H; | ||
console.log({ e: E }); | ||
const L = (H = c == null ? void 0 : c.current) == null ? void 0 : H.api.getColumnState(); | ||
z(L); | ||
}, | ||
[z] | ||
); | ||
ye(t, () => ({ | ||
unselectAll: () => { | ||
@@ -1123,6 +1127,6 @@ var E, L; | ||
onHeaderCheckboxChange: P, | ||
onSelectionChangedDebounced: X, | ||
onSelectionChangedDebounced: Q, | ||
selectedRowKeysPendingToRender: R, | ||
allRowSelectedMode: $, | ||
internalSelectedRowKeys: H, | ||
internalSelectedRowKeys: B, | ||
setSelectedRowKeysPendingToRender: j | ||
@@ -1139,7 +1143,7 @@ } = Xe({ | ||
}, [$]); | ||
const Q = qe(s, "key"), { applyColumnState: te } = Ge({ | ||
const V = qe(s, "key"), { applyColumnState: te } = Ge({ | ||
gridRef: c, | ||
containerRef: D, | ||
hasStatusColumn: f, | ||
columns: Q, | ||
columns: V, | ||
onGetColumnsState: u | ||
@@ -1160,4 +1164,4 @@ }), we = ce(() => ({}), []), Ee = ce(() => { | ||
totalRows: d, | ||
selectedRowKeysLength: H.length, | ||
allRowSelected: d === H.length && d > 0, | ||
selectedRowKeysLength: B.length, | ||
allRowSelected: d === B.length && d > 0, | ||
allRowSelectedMode: $, | ||
@@ -1167,3 +1171,3 @@ onHeaderCheckboxChange: P | ||
) | ||
}, L = Q.map((N) => ({ | ||
}, L = V.map((N) => ({ | ||
field: N.key, | ||
@@ -1191,5 +1195,5 @@ sortable: !1, | ||
$, | ||
Q, | ||
V, | ||
f, | ||
H.length, | ||
B.length, | ||
P, | ||
@@ -1202,5 +1206,5 @@ w, | ||
(re = c.current) == null || re.api.showLoadingOverlay(); | ||
const { startRow: L, endRow: V } = E, N = await n(L, V); | ||
const { startRow: L, endRow: H } = E, N = await n(L, H); | ||
let U = -1; | ||
N.length < V - L && (U = L + N.length); | ||
N.length < H - L && (U = L + N.length); | ||
const De = f ? await Promise.all( | ||
@@ -1255,11 +1259,11 @@ N.map(async (A) => { | ||
(E) => { | ||
const L = m == null ? void 0 : m(); | ||
const L = y == null ? void 0 : y(); | ||
L && E.api.ensureIndexVisible(L, "top"); | ||
}, | ||
[m] | ||
[y] | ||
), Ne = b( | ||
(E) => { | ||
y.current || p == null || p( | ||
m.current || p == null || p( | ||
E.api.getFirstDisplayedRowIndex() | ||
), y.current = !1; | ||
), m.current = !1; | ||
}, | ||
@@ -1298,7 +1302,6 @@ [p] | ||
rowSelection: "multiple", | ||
onColumnMoved: z, | ||
onColumnResized: z, | ||
onColumnResized: X, | ||
rowModelType: "infinite", | ||
cacheBlockSize: 20, | ||
onSelectionChanged: X, | ||
onSelectionChanged: Q, | ||
cacheOverflowSize: 2, | ||
@@ -1305,0 +1308,0 @@ maxConcurrentDatasourceRequests: 1, |
{ | ||
"name": "@gisce/react-formiga-table", | ||
"version": "1.6.0-alpha.2", | ||
"version": "1.6.0-alpha.3", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": "20.5.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
375124
6763