@gisce/react-formiga-table
Advanced tools
Comparing version 1.6.0-alpha.7 to 1.6.0-alpha.8
@@ -16,3 +16,3 @@ import { jsx as g, jsxs as P, Fragment as me } from "react/jsx-runtime"; | ||
}) => { | ||
const [s, a] = N([]), [l, i] = N([]), r = K(/* @__PURE__ */ new Map()), [o, u] = N( | ||
const [s, a] = N([]), [i, c] = N([]), r = K(/* @__PURE__ */ new Map()), [o, u] = N( | ||
e.map( | ||
@@ -39,3 +39,3 @@ (f) => Y({ | ||
(f) => { | ||
s.indexOf(f) === -1 ? (s.push(f), a([...s])) : a(s.filter((c) => c !== f)); | ||
s.indexOf(f) === -1 ? (s.push(f), a([...s])) : a(s.filter((l) => l !== f)); | ||
}, | ||
@@ -47,8 +47,8 @@ [s] | ||
), k = C( | ||
(f) => l.includes(f), | ||
[l] | ||
(f) => i.includes(f), | ||
[i] | ||
), d = (f) => r.current.get(f) || 0, v = C( | ||
(f) => { | ||
const c = o.find((y) => y.id === f); | ||
return c ? c[n] !== void 0 && c[n].length > 0 : !1; | ||
const l = o.find((y) => y.id === f); | ||
return l ? l[n] !== void 0 && l[n].length > 0 : !1; | ||
}, | ||
@@ -58,4 +58,4 @@ [n, o] | ||
(f) => { | ||
const c = o.find((y) => y.id === f); | ||
return c ? c.isLoading : !1; | ||
const l = o.find((y) => y.id === f); | ||
return l ? l.isLoading : !1; | ||
}, | ||
@@ -65,6 +65,6 @@ [o] | ||
(f) => { | ||
const c = o.find((I) => I.id === f); | ||
if (!c) | ||
const l = o.find((I) => I.id === f); | ||
if (!l) | ||
return []; | ||
const y = c[n]; | ||
const y = l[n]; | ||
return y ? o.filter((I) => y.includes(I.id)) : []; | ||
@@ -75,11 +75,11 @@ }, | ||
async (f) => { | ||
const c = o.find((y) => y.id === f.id); | ||
if (!c) | ||
const l = o.find((y) => y.id === f.id); | ||
if (!l) | ||
return !1; | ||
if (!c.isLoading) { | ||
if (!m(f.id) && !k(c.id)) { | ||
if (!l.isLoading) { | ||
if (!m(f.id) && !k(l.id)) { | ||
u( | ||
G( | ||
{ | ||
...c, | ||
...l, | ||
isLoading: !0 | ||
@@ -91,9 +91,9 @@ }, | ||
try { | ||
const y = await (t == null ? void 0 : t(c)) || []; | ||
const y = await (t == null ? void 0 : t(l)) || []; | ||
y.forEach((I) => { | ||
r.current.set(I.id, c.level + 1); | ||
r.current.set(I.id, l.level + 1); | ||
}), u( | ||
G( | ||
{ | ||
...c, | ||
...l, | ||
isLoading: !1 | ||
@@ -110,3 +110,3 @@ }, | ||
) | ||
), l.push(c.id), i([...l]); | ||
), i.push(l.id), c([...i]); | ||
} catch (y) { | ||
@@ -116,3 +116,3 @@ console.error(y), u( | ||
{ | ||
...c, | ||
...l, | ||
isLoading: !1 | ||
@@ -134,3 +134,3 @@ }, | ||
t, | ||
l, | ||
i, | ||
n | ||
@@ -142,9 +142,9 @@ ] | ||
), w = C(() => { | ||
const c = o.filter((y) => y.level === 0).map((y) => y.id); | ||
const l = o.filter((y) => y.level === 0).map((y) => y.id); | ||
return s.forEach((y) => { | ||
const I = o.find((A) => A.id === y); | ||
I && I.child_id && I.child_id.forEach((A) => { | ||
c.includes(A) || c.push(A); | ||
l.includes(A) || l.push(A); | ||
}); | ||
}), c; | ||
}), l; | ||
}, [s, o]); | ||
@@ -196,3 +196,3 @@ return { | ||
[t, n] | ||
), l = C( | ||
), i = C( | ||
(r) => { | ||
@@ -208,3 +208,3 @@ if (t.find( | ||
[t, n] | ||
), i = C( | ||
), c = C( | ||
(r) => t.find( | ||
@@ -217,9 +217,9 @@ (u) => r.id === u | ||
selectedRowKeys: t, | ||
isRowSelected: i, | ||
isRowSelected: c, | ||
toggleAllRowsSelected: s, | ||
toggleRowSelected: l, | ||
toggleRowSelected: i, | ||
changeSelected: a | ||
}; | ||
}, Re = (e, t) => { | ||
const [n, s] = N(null), [a, l] = N(!1), [i, r] = N(null); | ||
const [n, s] = N(null), [a, i] = N(!1), [c, r] = N(null); | ||
return C( | ||
@@ -229,3 +229,3 @@ (u, p) => { | ||
const m = e.findIndex((x) => x === u), k = e.findIndex((x) => x === n), d = e.findIndex( | ||
(x) => x === i | ||
(x) => x === c | ||
), v = Math.min(m, k), S = Math.max(m, k); | ||
@@ -243,3 +243,3 @@ if (v > -1 && S > -1) { | ||
} else | ||
s(u), r(null), l(p.target.checked); | ||
s(u), r(null), i(p.target.checked); | ||
t(p.target.checked, [u]); | ||
@@ -253,4 +253,4 @@ }, | ||
a, | ||
l, | ||
i, | ||
c, | ||
r | ||
@@ -261,4 +261,4 @@ ] | ||
const [t, n] = N(e), s = C( | ||
(l) => { | ||
if (t && l === t.id) | ||
(i) => { | ||
if (t && i === t.id) | ||
return t; | ||
@@ -268,6 +268,6 @@ }, | ||
), a = C( | ||
(l) => { | ||
(i) => { | ||
if (!t) { | ||
n({ | ||
id: l, | ||
id: i, | ||
desc: !1 | ||
@@ -277,5 +277,5 @@ }); | ||
} | ||
if (t.id !== l) { | ||
if (t.id !== i) { | ||
n({ | ||
id: l, | ||
id: i, | ||
desc: !1 | ||
@@ -287,3 +287,3 @@ }); | ||
n({ | ||
id: l, | ||
id: i, | ||
desc: !0 | ||
@@ -417,4 +417,4 @@ }); | ||
selectedRowKeys: a, | ||
handleColumnClick: l, | ||
getColumnSorter: i, | ||
handleColumnClick: i, | ||
getColumnSorter: c, | ||
sortEnabled: r, | ||
@@ -463,3 +463,3 @@ readonly: o, | ||
onClick: r ? () => { | ||
l(m.key); | ||
i(m.key); | ||
} : void 0, | ||
@@ -484,6 +484,6 @@ children: /* @__PURE__ */ P("div", { className: "ctx", children: [ | ||
style: { | ||
visibility: i(m.key) !== void 0 ? void 0 : "hidden", | ||
visibility: c(m.key) !== void 0 ? void 0 : "hidden", | ||
marginLeft: "auto" | ||
}, | ||
children: i(m.key) !== void 0 && i(m.key).desc ? " ▼" : " ▲" | ||
children: c(m.key) !== void 0 && c(m.key).desc ? " ▼" : " ▲" | ||
}, | ||
@@ -502,4 +502,4 @@ m.key | ||
getColumnSorter: a, | ||
expandableOpts: l, | ||
getExpandableStatusForRow: i, | ||
expandableOpts: i, | ||
getExpandableStatusForRow: c, | ||
onExpandableIconClicked: r, | ||
@@ -527,4 +527,4 @@ onCellRender: o, | ||
columnIdx: n, | ||
expandableOpts: l, | ||
getExpandableStatusForRow: i, | ||
expandableOpts: i, | ||
getExpandableStatusForRow: c, | ||
onExpandableIconClicked: r, | ||
@@ -553,14 +553,14 @@ level: s | ||
onExpandableIconClicked: a, | ||
level: l | ||
level: i | ||
}) { | ||
if (!n) | ||
return null; | ||
const i = s(e); | ||
if (i === "none" || t !== 0) | ||
return /* @__PURE__ */ g("div", { style: { display: "inline-block", width: 19 + l * 25 } }); | ||
const c = s(e); | ||
if (c === "none" || t !== 0) | ||
return /* @__PURE__ */ g("div", { style: { display: "inline-block", width: 19 + i * 25 } }); | ||
let r; | ||
return i === "expand" ? r = n.expandIcon : i === "collapse" ? r = n.collapseIcon : i === "loading" && (r = n.loadingIcon), /* @__PURE__ */ g("div", { style: { display: "inline-block" }, children: /* @__PURE__ */ g( | ||
return c === "expand" ? r = n.expandIcon : c === "collapse" ? r = n.collapseIcon : c === "loading" && (r = n.loadingIcon), /* @__PURE__ */ g("div", { style: { display: "inline-block" }, children: /* @__PURE__ */ g( | ||
r, | ||
{ | ||
style: { marginRight: 5, marginLeft: l * 25 }, | ||
style: { marginRight: 5, marginLeft: i * 25 }, | ||
onClick: () => { | ||
@@ -610,4 +610,4 @@ a(e); | ||
onRowStyle: a, | ||
onRowStatus: l, | ||
onRowDoubleClick: i, | ||
onRowStatus: i, | ||
onRowDoubleClick: c, | ||
isRowSelected: r, | ||
@@ -628,4 +628,4 @@ toggleRowSelected: o, | ||
onRowStyle: a, | ||
onRowStatus: l, | ||
onRowDoubleClick: i, | ||
onRowStatus: i, | ||
onRowDoubleClick: c, | ||
onRowSelectionChange: e, | ||
@@ -649,4 +649,4 @@ isRowSelected: r, | ||
isRowSelected: a, | ||
toggleRowSelected: l, | ||
expandableOpts: i, | ||
toggleRowSelected: i, | ||
expandableOpts: c, | ||
getExpandableStatusForRow: r, | ||
@@ -664,3 +664,3 @@ onExpandableIconClicked: o, | ||
}) { | ||
var c; | ||
var l; | ||
const b = k ? k(e) : "", w = a(e); | ||
@@ -702,3 +702,3 @@ let f = [ | ||
onChange: (y) => { | ||
l(e.id, y); | ||
i(e.id, y); | ||
} | ||
@@ -721,3 +721,3 @@ } | ||
onCellRender: () => d(e), | ||
expandableOpts: i, | ||
expandableOpts: c, | ||
getExpandableStatusForRow: r, | ||
@@ -737,3 +737,3 @@ onExpandableIconClicked: o, | ||
getColumnSorter: u, | ||
expandableOpts: i, | ||
expandableOpts: c, | ||
getExpandableStatusForRow: r, | ||
@@ -751,4 +751,4 @@ onExpandableIconClicked: o, | ||
]; | ||
return i !== void 0 && p(e.id) && (f = f.concat( | ||
(c = m(e.id)) == null ? void 0 : c.map((y) => ke({ | ||
return c !== void 0 && p(e.id) && (f = f.concat( | ||
(l = m(e.id)) == null ? void 0 : l.map((y) => ke({ | ||
row: y.data, | ||
@@ -760,4 +760,4 @@ columns: t, | ||
isRowSelected: a, | ||
toggleRowSelected: l, | ||
expandableOpts: i, | ||
toggleRowSelected: i, | ||
expandableOpts: c, | ||
getExpandableStatusForRow: r, | ||
@@ -779,4 +779,4 @@ onExpandableIconClicked: o, | ||
loadingComponent: a, | ||
dataSource: l, | ||
columns: i, | ||
dataSource: i, | ||
columns: c, | ||
onRowDoubleClick: r, | ||
@@ -797,3 +797,3 @@ onRowStyle: o, | ||
isRowSelected: f, | ||
changeSelected: c | ||
changeSelected: l | ||
} = ze({ | ||
@@ -808,4 +808,4 @@ selectionRowKeysProps: x | ||
const y = Re( | ||
l.map((B) => B.id), | ||
c | ||
i.map((B) => B.id), | ||
l | ||
), { localSorter: I, getColumnSorter: A, handleColumnClick: F } = je(k), { | ||
@@ -819,3 +819,3 @@ keyIsOpened: J, | ||
} = Fe({ | ||
dataSource: l, | ||
dataSource: i, | ||
onFetchChildrenForRecord: d == null ? void 0 : d.onFetchChildrenForRecord, | ||
@@ -829,3 +829,3 @@ childField: d == null ? void 0 : d.childField | ||
}, [I]); | ||
const j = C(() => b.length === 0 ? !1 : d ? O().length === b.length : l.length === b.length, [l.length, d, b.length]), H = C(() => { | ||
const j = C(() => b.length === 0 ? !1 : d ? O().length === b.length : i.length === b.length, [i.length, d, b.length]), H = C(() => { | ||
w(O()); | ||
@@ -845,3 +845,3 @@ }, [w, O]); | ||
allRowsAreSelected: j(), | ||
columns: i, | ||
columns: c, | ||
onRowSelectionChange: p, | ||
@@ -861,4 +861,4 @@ selectedRowKeys: b, | ||
{ | ||
dataSource: l, | ||
columns: i, | ||
dataSource: i, | ||
columns: c, | ||
onRowSelectionChange: p, | ||
@@ -891,4 +891,4 @@ getColumnSorter: A, | ||
(n, s) => { | ||
const a = n[0], l = s[0], i = a.map((o) => o[t]).sort((o, u) => o.localeCompare(u)).join(","), r = l.map((o) => o[t]).sort((o, u) => o.localeCompare(u)).join(","); | ||
return i === r; | ||
const a = n[0], i = s[0], c = a.map((o) => o[t]).sort((o, u) => o.localeCompare(u)).join(","), r = i.map((o) => o[t]).sort((o, u) => o.localeCompare(u)).join(","); | ||
return c === r; | ||
} | ||
@@ -934,5 +934,5 @@ ), ve = Z( | ||
}) => { | ||
const l = e === 0, i = e > 0 && t !== e; | ||
const i = e === 0, c = e > 0 && t !== e; | ||
let r = !1; | ||
return a || t === e && t > 0 || n ? r = !0 : l ? r = !1 : i && (r = null), /* @__PURE__ */ g(ve, { value: r, onChange: s }); | ||
return a || t === e && t > 0 || n ? r = !0 : i ? r = !1 : c && (r = null), /* @__PURE__ */ g(ve, { value: r, onChange: s }); | ||
} | ||
@@ -948,3 +948,3 @@ ); | ||
}) => { | ||
const [l, i] = N( | ||
const [i, c] = N( | ||
[] | ||
@@ -957,3 +957,3 @@ ), [r, o] = N( | ||
}, [r]), _(() => { | ||
o(a), a && (i([]), m.current = !0); | ||
o(a), a && (c([]), m.current = !0); | ||
}, [a]), _(() => { | ||
@@ -965,3 +965,3 @@ 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, (b = e == null ? void 0 : e.current) == null || b.api.forEachNode((w) => { | ||
r ? h = !1 : !r && i.length === 0 ? h = !0 : !r && i.length === s ? h = !1 : (r || i.length > 0) && (h = !0), m.current = !0, (b = e == null ? void 0 : e.current) == null || b.api.forEachNode((w) => { | ||
w.setSelected(h); | ||
@@ -971,6 +971,6 @@ }), o(h), k.current && clearTimeout(k.current), k.current = setTimeout(() => { | ||
}, 1e3); | ||
}, [r, l.length, s, e]), v = C( | ||
}, [r, i.length, s, e]), v = C( | ||
(h) => { | ||
if (m.current) { | ||
t == null || t([]), i([]); | ||
t == null || t([]), c([]); | ||
return; | ||
@@ -984,3 +984,3 @@ } | ||
p.current | ||
), t == null || t(w), i(w); | ||
), t == null || t(w), c(w); | ||
}, | ||
@@ -997,3 +997,3 @@ [t] | ||
return { | ||
internalSelectedRowKeys: l, | ||
internalSelectedRowKeys: i, | ||
onHeaderCheckboxChange: d, | ||
@@ -1015,6 +1015,6 @@ allRowSelectedMode: r, | ||
const n = t.map( | ||
(i) => i.colId | ||
(c) => c.colId | ||
), s = [...e].sort(), a = [ | ||
...n.filter( | ||
(i) => !Ge.includes(i) | ||
(c) => !Ge.includes(c) | ||
) | ||
@@ -1031,3 +1031,3 @@ ].sort(); | ||
}) => { | ||
const l = K(!1), i = K(), r = we; | ||
const i = K(!1), c = K(), r = we; | ||
n && r.push(ee); | ||
@@ -1053,5 +1053,5 @@ const o = C( | ||
"1- Applying column state: ", | ||
i.current | ||
c.current | ||
), (d = e == null ? void 0 : e.current) == null || d.api.applyColumnState({ | ||
state: i.current, | ||
state: c.current, | ||
applyOrder: !0 | ||
@@ -1069,7 +1069,7 @@ }); | ||
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) => ({ | ||
const w = v / (d.length - r.length), l = ((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 | ||
})); | ||
console.log("2- Applying column state: ", c), (b = e == null ? void 0 : e.current) == null || b.api.applyColumnState({ state: c }); | ||
console.log("2- Applying column state: ", l), (b = e == null ? void 0 : e.current) == null || b.api.applyColumnState({ state: l }); | ||
} | ||
@@ -1080,12 +1080,12 @@ }); | ||
applyColumnState: ue(() => { | ||
if (i.current = Ze({ | ||
if (c.current = Ze({ | ||
actualColumnKeys: s.map((d) => d.key), | ||
persistedColumnState: a == null ? void 0 : a() | ||
}), i.current) { | ||
}), c.current) { | ||
p(); | ||
return; | ||
} | ||
!i.current && !l.current && (l.current = !0, m()); | ||
!c.current && !i.current && (i.current = !0, m()); | ||
}, [m, p, s, a]), | ||
columnsPersistedStateRef: i | ||
columnsPersistedStateRef: c | ||
}; | ||
@@ -1099,4 +1099,4 @@ }, he = 50, Ee = ye( | ||
onRowDoubleClick: a, | ||
onRowSelectionChange: l, | ||
height: i = 600, | ||
onRowSelectionChange: i, | ||
height: c = 600, | ||
onRowStyle: r, | ||
@@ -1116,4 +1116,5 @@ onColumnChanged: o, | ||
hasStatusColumn: f = !1 | ||
} = e, c = K(null), y = K(!0), I = K(!1), A = K(null), F = K(!1), J = x ? i + h : i, X = x ? i - h : i, z = C( | ||
} = e, l = K(null), y = K(!0), I = K(!1), A = K(null), F = K(!1), J = x ? c + h : c, X = x ? c - h : c, z = C( | ||
Ce((E) => { | ||
var L; | ||
if (!F.current) { | ||
@@ -1123,3 +1124,3 @@ F.current = !0; | ||
} | ||
o == null || o(E); | ||
(L = l.current) == null || L.api.applyColumnState({ state: E }), o == null || o(E); | ||
}, he), | ||
@@ -1131,3 +1132,3 @@ [o] | ||
console.log({ event: E }); | ||
const L = ($ = c == null ? void 0 : c.current) == null ? void 0 : $.api.getColumnState(); | ||
const L = ($ = l == null ? void 0 : l.current) == null ? void 0 : $.api.getColumnState(); | ||
z(L); | ||
@@ -1140,7 +1141,7 @@ }, | ||
var E, L; | ||
U([]), (L = (E = c.current) == null ? void 0 : E.api) == null || L.deselectAll(); | ||
U([]), (L = (E = l.current) == null ? void 0 : E.api) == null || L.deselectAll(); | ||
}, | ||
refresh: () => { | ||
var E, L; | ||
(L = (E = c.current) == null ? void 0 : E.api) == null || L.purgeInfiniteCache(); | ||
(L = (E = l.current) == null ? void 0 : E.api) == null || L.purgeInfiniteCache(); | ||
} | ||
@@ -1156,4 +1157,4 @@ })); | ||
} = Ye({ | ||
gridRef: c, | ||
onRowSelectionChange: l, | ||
gridRef: l, | ||
onRowSelectionChange: i, | ||
onAllRowSelectedModeChange: v, | ||
@@ -1167,3 +1168,3 @@ totalRows: d, | ||
const V = Qe(s, "key"), { applyColumnState: te, columnsPersistedStateRef: Ie } = tt({ | ||
gridRef: c, | ||
gridRef: l, | ||
containerRef: A, | ||
@@ -1230,3 +1231,3 @@ hasStatusColumn: f, | ||
var oe, le, ie, ce; | ||
(oe = c.current) == null || oe.api.showLoadingOverlay(); | ||
(oe = l.current) == null || oe.api.showLoadingOverlay(); | ||
const { startRow: L, endRow: $ } = E, D = await n(L, $); | ||
@@ -1245,3 +1246,3 @@ let W = -1; | ||
if (E.successCallback(Me, W), I.current) | ||
(le = c == null ? void 0 : c.current) == null || le.api.forEachNode((T) => { | ||
(le = l == null ? void 0 : l.current) == null || le.api.forEachNode((T) => { | ||
T.setSelected(!0); | ||
@@ -1251,3 +1252,3 @@ }); | ||
const T = k == null ? void 0 : k(); | ||
U(T || []), T && T.length > 0 && ((ie = c == null ? void 0 : c.current) == null || ie.api.forEachNode((M) => { | ||
U(T || []), T && T.length > 0 && ((ie = l == null ? void 0 : l.current) == null || ie.api.forEachNode((M) => { | ||
var ae; | ||
@@ -1261,3 +1262,3 @@ (ae = M == null ? void 0 : M.data) != null && ae.id && T.includes(M.data.id) && (M.setSelected(!0), U( | ||
} | ||
(ce = c.current) == null || ce.api.hideOverlay(), te(); | ||
(ce = l.current) == null || ce.api.hideOverlay(), te(); | ||
}, | ||
@@ -1275,3 +1276,3 @@ [ | ||
console.log("-----"), console.log("InfiniteTable render"), console.log({ | ||
internalState: (se = (re = c.current) == null ? void 0 : re.api) == null ? void 0 : se.getColumnState(), | ||
internalState: (se = (re = l.current) == null ? void 0 : re.api) == null ? void 0 : se.getColumnState(), | ||
columnsPersistedStateRef: Ie.current | ||
@@ -1323,3 +1324,3 @@ }), console.log("-----"); | ||
{ | ||
ref: c, | ||
ref: l, | ||
columnDefs: Ke, | ||
@@ -1326,0 +1327,0 @@ defaultColDef: Le, |
{ | ||
"name": "@gisce/react-formiga-table", | ||
"version": "1.6.0-alpha.7", | ||
"version": "1.6.0-alpha.8", | ||
"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
378305
6805