@gisce/react-formiga-table
Advanced tools
Comparing version 1.4.0-alpha.2 to 1.4.0-alpha.3
@@ -1,3 +0,3 @@ | ||
import { jsx as h, jsxs as D, Fragment as ae } from "react/jsx-runtime"; | ||
import W, { useState as N, useRef as L, useEffect as T, useCallback as k, forwardRef as de, useImperativeHandle as ue, memo as V, useMemo as oe } from "react"; | ||
import { jsx as h, jsxs as T, Fragment as ae } from "react/jsx-runtime"; | ||
import W, { useState as N, useRef as L, useEffect as D, useCallback as C, forwardRef as de, useImperativeHandle as ue, memo as V, useMemo as oe } from "react"; | ||
import Ie from "use-deep-compare-effect"; | ||
@@ -24,3 +24,3 @@ import Ee from "style-object-to-css-string"; | ||
); | ||
T(() => { | ||
D(() => { | ||
c( | ||
@@ -36,3 +36,3 @@ e.map( | ||
}, [e]); | ||
const d = k( | ||
const d = C( | ||
(f) => { | ||
@@ -42,9 +42,9 @@ s.indexOf(f) === -1 ? (s.push(f), a([...s])) : a(s.filter((y) => y !== f)); | ||
[s] | ||
), u = k( | ||
), u = C( | ||
(f) => s.includes(f), | ||
[s] | ||
), C = k( | ||
), k = C( | ||
(f) => l.includes(f), | ||
[l] | ||
), g = (f) => r.current.get(f) || 0, x = k( | ||
), b = (f) => r.current.get(f) || 0, x = C( | ||
(f) => { | ||
@@ -55,3 +55,3 @@ const y = o.find((m) => m.id === f); | ||
[n, o] | ||
), S = k( | ||
), S = C( | ||
(f) => { | ||
@@ -62,3 +62,3 @@ const y = o.find((m) => m.id === f); | ||
[o] | ||
), w = k( | ||
), w = C( | ||
(f) => { | ||
@@ -72,3 +72,3 @@ const y = o.find((E) => E.id === f); | ||
[n, o] | ||
), p = k( | ||
), p = C( | ||
async (f) => { | ||
@@ -79,3 +79,3 @@ const y = o.find((m) => m.id === f.id); | ||
if (!y.isLoading) { | ||
if (!u(f.id) && !C(y.id)) { | ||
if (!u(f.id) && !k(y.id)) { | ||
c( | ||
@@ -128,3 +128,3 @@ U( | ||
u, | ||
C, | ||
k, | ||
d, | ||
@@ -135,6 +135,6 @@ t, | ||
] | ||
), b = k( | ||
), g = C( | ||
(f) => S(f.id) ? "loading" : x(f.id) ? u(f.id) ? "collapse" : "expand" : "none", | ||
[S, x, u] | ||
), I = k(() => { | ||
), I = C(() => { | ||
const y = o.filter((m) => m.level === 0).map((m) => m.id); | ||
@@ -151,6 +151,6 @@ return s.forEach((m) => { | ||
onExpandableIconClicked: p, | ||
getExpandableStatusForRow: b, | ||
getExpandableStatusForRow: g, | ||
getChildsForParent: w, | ||
getAllVisibleKeys: I, | ||
getLevelForKey: g | ||
getLevelForKey: b | ||
}; | ||
@@ -180,3 +180,3 @@ }; | ||
}, [e]); | ||
const s = k( | ||
const s = C( | ||
(r) => { | ||
@@ -190,3 +190,3 @@ if (t.length === r.length || t.length > 0) { | ||
[t, n] | ||
), a = k( | ||
), a = C( | ||
(r, o) => { | ||
@@ -196,3 +196,3 @@ o.length !== 0 && n(r ? [.../* @__PURE__ */ new Set([...t, ...o])] : t.filter((c) => !o.includes(c))); | ||
[t, n] | ||
), l = k( | ||
), l = C( | ||
(r) => { | ||
@@ -208,3 +208,3 @@ if (t.find( | ||
[t, n] | ||
), i = k( | ||
), i = C( | ||
(r) => t.find( | ||
@@ -224,15 +224,15 @@ (c) => r.id === c | ||
const [n, s] = N(null), [a, l] = N(!1), [i, r] = N(null); | ||
return k( | ||
return C( | ||
(c, d) => { | ||
if (d.nativeEvent.shiftKey) { | ||
const u = e.findIndex((w) => w === c), C = e.findIndex((w) => w === n), g = e.findIndex( | ||
const u = e.findIndex((w) => w === c), k = e.findIndex((w) => w === n), b = e.findIndex( | ||
(w) => w === i | ||
), x = Math.min(u, C), S = Math.max(u, C); | ||
), x = Math.min(u, k), S = Math.max(u, k); | ||
if (x > -1 && S > -1) { | ||
t(a, e.slice(x, S + 1)), g > S && t( | ||
t(a, e.slice(x, S + 1)), b > S && t( | ||
!a, | ||
e.slice(S + 1, g + 1) | ||
), g < x && t( | ||
e.slice(S + 1, b + 1) | ||
), b < x && t( | ||
!a, | ||
e.slice(g, x) | ||
e.slice(b, x) | ||
), r(c); | ||
@@ -257,3 +257,3 @@ return; | ||
}, Me = (e) => { | ||
const [t, n] = N(e), s = k( | ||
const [t, n] = N(e), s = C( | ||
(l) => { | ||
@@ -264,3 +264,3 @@ if (t && l === t.id) | ||
[t] | ||
), a = k( | ||
), a = C( | ||
(l) => { | ||
@@ -418,3 +418,3 @@ if (!t) { | ||
headerStyle: d | ||
}) => /* @__PURE__ */ D(ae, { children: [ | ||
}) => /* @__PURE__ */ T(ae, { children: [ | ||
e && !o && /* @__PURE__ */ h( | ||
@@ -460,3 +460,3 @@ "th", | ||
} : void 0, | ||
children: /* @__PURE__ */ D("div", { className: "ctx", children: [ | ||
children: /* @__PURE__ */ T("div", { className: "ctx", children: [ | ||
/* @__PURE__ */ h( | ||
@@ -508,4 +508,4 @@ "div", | ||
} : {}; | ||
let C; | ||
return o ? C = o({ | ||
let k; | ||
return o ? k = o({ | ||
column: e, | ||
@@ -515,3 +515,3 @@ columnIdx: n, | ||
value: t[e.key] | ||
}) : e.render ? C = e.render(t[e.key]) : C = t[e.key], /* @__PURE__ */ D("td", { style: u, children: [ | ||
}) : e.render ? k = e.render(t[e.key]) : k = t[e.key], /* @__PURE__ */ T("td", { style: u, children: [ | ||
/* @__PURE__ */ h( | ||
@@ -528,3 +528,3 @@ ze, | ||
), | ||
/* @__PURE__ */ D("div", { style: { display: "inline-block", width: "100%", ...d }, children: [ | ||
/* @__PURE__ */ T("div", { style: { display: "inline-block", width: "100%", ...d }, children: [ | ||
/* @__PURE__ */ h( | ||
@@ -538,3 +538,3 @@ "div", | ||
), | ||
C | ||
k | ||
] }) | ||
@@ -578,3 +578,3 @@ ] }); | ||
render() { | ||
return this.state.hasError ? /* @__PURE__ */ D( | ||
return this.state.hasError ? /* @__PURE__ */ T( | ||
"div", | ||
@@ -590,3 +590,3 @@ { | ||
/* @__PURE__ */ h("strong", { style: { color: "red" }, children: "Something went wrong." }), | ||
/* @__PURE__ */ h("details", { style: { whiteSpace: "pre-wrap" }, children: /* @__PURE__ */ D("pre", { children: [ | ||
/* @__PURE__ */ h("details", { style: { whiteSpace: "pre-wrap" }, children: /* @__PURE__ */ T("pre", { children: [ | ||
this.state.error && this.state.error.toString(), | ||
@@ -614,4 +614,4 @@ /* @__PURE__ */ h("br", {}), | ||
getExpandableStatusForRow: u, | ||
keyIsOpened: C, | ||
getChildsForParent: g, | ||
keyIsOpened: k, | ||
getChildsForParent: b, | ||
getLevelForKey: x, | ||
@@ -621,4 +621,4 @@ onCellRender: S, | ||
readonly: p | ||
}) => /* @__PURE__ */ h(ae, { children: t.filter((b) => x(b.id) === 0).map((b) => pe({ | ||
row: b, | ||
}) => /* @__PURE__ */ h(ae, { children: t.filter((g) => x(g.id) === 0).map((g) => pe({ | ||
row: g, | ||
columns: n, | ||
@@ -635,4 +635,4 @@ onRowStyle: a, | ||
getColumnSorter: s, | ||
keyIsOpened: C, | ||
getChildsForParent: g, | ||
keyIsOpened: k, | ||
getChildsForParent: b, | ||
cellStyle: w, | ||
@@ -654,4 +654,4 @@ readonly: p | ||
getChildsForParent: u, | ||
onRowStyle: C, | ||
onRowStatus: g, | ||
onRowStyle: k, | ||
onRowStatus: b, | ||
level: x = 0, | ||
@@ -663,8 +663,8 @@ onCellRender: S, | ||
var y; | ||
const b = C ? C(e) : "", I = a(e); | ||
const g = k ? k(e) : "", I = a(e); | ||
let f = [ | ||
/* @__PURE__ */ D( | ||
/* @__PURE__ */ T( | ||
"tr", | ||
{ | ||
style: b, | ||
style: g, | ||
onDoubleClick: () => { | ||
@@ -709,3 +709,3 @@ n == null || n(e); | ||
), | ||
g && /* @__PURE__ */ h(le, { children: /* @__PURE__ */ h( | ||
b && /* @__PURE__ */ h(le, { children: /* @__PURE__ */ h( | ||
ie, | ||
@@ -718,3 +718,3 @@ { | ||
columnIdx: -1, | ||
onCellRender: () => g(e), | ||
onCellRender: () => b(e), | ||
expandableOpts: i, | ||
@@ -752,3 +752,3 @@ getExpandableStatusForRow: r, | ||
columns: t, | ||
onRowStyle: C, | ||
onRowStyle: k, | ||
onRowDoubleClick: n, | ||
@@ -766,3 +766,3 @@ onRowSelectionChange: s, | ||
onCellRender: S, | ||
onRowStatus: g | ||
onRowStatus: b | ||
})) | ||
@@ -783,4 +783,4 @@ )), f; | ||
onChangeSort: u, | ||
sorter: C, | ||
expandableOpts: g, | ||
sorter: k, | ||
expandableOpts: b, | ||
onCellRender: x, | ||
@@ -791,3 +791,3 @@ readonly: S, | ||
} = e, { | ||
selectedRowKeys: b, | ||
selectedRowKeys: g, | ||
toggleAllRowsSelected: I, | ||
@@ -807,3 +807,3 @@ isRowSelected: f, | ||
y | ||
), { localSorter: E, getColumnSorter: A, handleColumnClick: J } = Me(C), { | ||
), { localSorter: E, getColumnSorter: A, handleColumnClick: J } = Me(k), { | ||
keyIsOpened: F, | ||
@@ -817,11 +817,11 @@ onExpandableIconClicked: _, | ||
dataSource: l, | ||
onFetchChildrenForRecord: g == null ? void 0 : g.onFetchChildrenForRecord, | ||
childField: g == null ? void 0 : g.childField | ||
onFetchChildrenForRecord: b == null ? void 0 : b.onFetchChildrenForRecord, | ||
childField: b == null ? void 0 : b.childField | ||
}); | ||
T(() => { | ||
d == null || d(b); | ||
}, [b]), T(() => { | ||
D(() => { | ||
d == null || d(g); | ||
}, [g]), D(() => { | ||
u == null || u(E); | ||
}, [E]); | ||
const R = k(() => b.length === 0 ? !1 : g ? H().length === b.length : l.length === b.length, [l.length, g, b.length]), $ = k(() => { | ||
const R = C(() => g.length === 0 ? !1 : b ? H().length === g.length : l.length === g.length, [l.length, b, g.length]), $ = C(() => { | ||
I(H()); | ||
@@ -836,3 +836,3 @@ }, [I, H]); | ||
containerStyle: p == null ? void 0 : p.containerStyle, | ||
children: /* @__PURE__ */ D("table", { style: p == null ? void 0 : p.tableStyle, children: [ | ||
children: /* @__PURE__ */ T("table", { style: p == null ? void 0 : p.tableStyle, children: [ | ||
/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ h("tr", { children: /* @__PURE__ */ h( | ||
@@ -844,7 +844,7 @@ Pe, | ||
onRowSelectionChange: d, | ||
selectedRowKeys: b, | ||
selectedRowKeys: g, | ||
toggleAllRowsSelected: $, | ||
handleColumnClick: J, | ||
getColumnSorter: A, | ||
sortEnabled: g === void 0, | ||
sortEnabled: b === void 0, | ||
readonly: S, | ||
@@ -867,3 +867,3 @@ status: !!c, | ||
toggleRowSelected: m, | ||
expandableOpts: g, | ||
expandableOpts: b, | ||
onExpandableIconClicked: _, | ||
@@ -897,3 +897,3 @@ getExpandableStatusForRow: B, | ||
const n = W.useRef(); | ||
return T(() => { | ||
return D(() => { | ||
const s = n.current; | ||
@@ -948,23 +948,19 @@ e === !0 ? (s.checked = !0, s.indeterminate = !1) : e === !1 ? (s.checked = !1, s.indeterminate = !1) : e === null && (s.checked = !1, s.indeterminate = !0); | ||
a | ||
), c = L(!1), d = L([]), u = L(!1), C = L(null); | ||
T(() => { | ||
), c = L(!1), d = L([]), u = L(!1), k = L(null); | ||
D(() => { | ||
c.current = r; | ||
}, [r]), T(() => { | ||
}, [r]), D(() => { | ||
o(a), a && (i([]), u.current = !0); | ||
}, [a]), T(() => { | ||
}, [a]), D(() => { | ||
n == null || n(r); | ||
}, [r]); | ||
const g = k(() => { | ||
var b; | ||
const b = C(() => { | ||
var g; | ||
let p = !1; | ||
r ? p = !1 : !r && l.length === 0 ? p = !0 : !r && l.length === s ? p = !1 : (r || l.length > 0) && (p = !0), u.current = !0, (b = e == null ? void 0 : e.current) == null || b.api.forEachNode((I) => { | ||
r ? p = !1 : !r && l.length === 0 ? p = !0 : !r && l.length === s ? p = !1 : (r || l.length > 0) && (p = !0), u.current = !0, (g = e == null ? void 0 : e.current) == null || g.api.forEachNode((I) => { | ||
I.setSelected(p); | ||
}), o(p), C.current && clearTimeout(C.current), C.current = setTimeout(() => { | ||
}), o(p), k.current && clearTimeout(k.current), k.current = setTimeout(() => { | ||
u.current = !1; | ||
}, 1e3); | ||
}, [r, l.length, s, e]); | ||
T(() => () => { | ||
C.current && clearTimeout(C.current); | ||
}, [g]); | ||
const x = k( | ||
}, [r, l.length, s, e]), x = C( | ||
(p) => { | ||
@@ -984,3 +980,3 @@ if (u.current) { | ||
[t] | ||
), S = k( | ||
), S = C( | ||
fe((p) => { | ||
@@ -990,3 +986,3 @@ x == null || x(p); | ||
[x] | ||
), w = k((p) => { | ||
), w = C((p) => { | ||
d.current = p; | ||
@@ -996,3 +992,3 @@ }, []); | ||
internalSelectedRowKeys: l, | ||
onHeaderCheckboxChange: g, | ||
onHeaderCheckboxChange: b, | ||
allRowSelectedMode: r, | ||
@@ -1008,3 +1004,3 @@ onSelectionChangedDebounced: S, | ||
}) => { | ||
const s = L(!1), a = k( | ||
const s = L(!1), a = C( | ||
(i) => { | ||
@@ -1022,3 +1018,3 @@ var c; | ||
return { | ||
autoSizeColumnsIfNecessary: k(() => { | ||
autoSizeColumnsIfNecessary: C(() => { | ||
!n.current && !s.current && (s.current = !0, setTimeout(() => { | ||
@@ -1032,6 +1028,6 @@ var o, c, d, u; | ||
if (r > 0) { | ||
const C = r / (i.length - 1), x = ((d = e == null ? void 0 : e.current) == null ? void 0 : d.api.getColumnState()).map((S) => ({ | ||
const k = r / (i.length - 1), x = ((d = e == null ? void 0 : e.current) == null ? void 0 : d.api.getColumnState()).map((S) => ({ | ||
...S, | ||
// colId 0 is the checkbox column | ||
width: S.colId !== "0" ? S.width + C : S.width | ||
width: S.colId !== "0" ? S.width + k : S.width | ||
})); | ||
@@ -1069,4 +1065,4 @@ (u = e == null ? void 0 : e.current) == null || u.api.applyColumnState({ state: x }); | ||
onGetFirstVisibleRowIndex: u, | ||
onGetSelectedRowKeys: C, | ||
totalRows: g, | ||
onGetSelectedRowKeys: k, | ||
totalRows: b, | ||
onAllRowSelectedModeChange: x, | ||
@@ -1076,7 +1072,7 @@ allRowSelectedMode: S, | ||
footerHeight: p = 50 | ||
} = e, b = L(null), I = L(!0), f = L(!1), y = L(), m = L(null), E = L(!1), A = w ? i + p : i, J = w ? i - p : i, { autoSizeColumnsIfNecessary: F } = je({ | ||
gridRef: b, | ||
} = e, g = L(null), I = L(!0), f = L(!1), y = L(), m = L(null), E = L(!1), A = w ? i + p : i, J = w ? i - p : i, { autoSizeColumnsIfNecessary: F } = je({ | ||
gridRef: g, | ||
containerRef: m, | ||
columnsPersistedStateRef: y | ||
}), _ = k( | ||
}), _ = C( | ||
fe((v) => { | ||
@@ -1090,3 +1086,3 @@ if (!E.current) { | ||
[o] | ||
), B = k( | ||
), B = C( | ||
(v) => { | ||
@@ -1101,7 +1097,7 @@ const K = v.api.getColumnState(); | ||
var v, K; | ||
P([]), (K = (v = b.current) == null ? void 0 : v.api) == null || K.deselectAll(); | ||
P([]), (K = (v = g.current) == null ? void 0 : v.api) == null || K.deselectAll(); | ||
}, | ||
refresh: () => { | ||
var v, K; | ||
(K = (v = b.current) == null ? void 0 : v.api) == null || K.purgeInfiniteCache(); | ||
(K = (v = g.current) == null ? void 0 : v.api) == null || K.purgeInfiniteCache(); | ||
} | ||
@@ -1117,9 +1113,9 @@ })); | ||
} = Be({ | ||
gridRef: b, | ||
gridRef: g, | ||
onRowSelectionChange: l, | ||
onAllRowSelectedModeChange: x, | ||
totalRows: g, | ||
totalRows: b, | ||
allRowSelectedModeProps: S | ||
}); | ||
T(() => { | ||
D(() => { | ||
f.current = R; | ||
@@ -1139,5 +1135,5 @@ }, [R]); | ||
{ | ||
totalRows: g, | ||
totalRows: b, | ||
selectedRowKeysLength: $.length, | ||
allRowSelected: g === $.length && g > 0, | ||
allRowSelected: b === $.length && b > 0, | ||
allRowSelectedMode: R, | ||
@@ -1159,16 +1155,16 @@ onHeaderCheckboxChange: j | ||
j, | ||
g | ||
]), X = k( | ||
b | ||
]), X = C( | ||
async (v) => { | ||
var ee, te, ne, re; | ||
(ee = b.current) == null || ee.api.showLoadingOverlay(); | ||
(ee = g.current) == null || ee.api.showLoadingOverlay(); | ||
const { startRow: K, endRow: Y } = v, G = await n(K, Y); | ||
let Z = -1; | ||
if (G.length < Y - K && (Z = K + G.length), v.successCallback(G, Z), f.current) | ||
(te = b == null ? void 0 : b.current) == null || te.api.forEachNode((z) => { | ||
(te = g == null ? void 0 : g.current) == null || te.api.forEachNode((z) => { | ||
z.setSelected(!0); | ||
}); | ||
else { | ||
const z = C == null ? void 0 : C(); | ||
P(z || []), z && z.length > 0 && ((ne = b == null ? void 0 : b.current) == null || ne.api.forEachNode((M) => { | ||
const z = k == null ? void 0 : k(); | ||
P(z || []), z && z.length > 0 && ((ne = g == null ? void 0 : g.current) == null || ne.api.forEachNode((M) => { | ||
var se; | ||
@@ -1182,7 +1178,7 @@ (se = M == null ? void 0 : M.data) != null && se.id && z.includes(M.data.id) && (M.setSelected(!0), P( | ||
} | ||
(re = b.current) == null || re.api.hideOverlay(), F(); | ||
(re = g.current) == null || re.api.hideOverlay(), F(); | ||
}, | ||
[ | ||
F, | ||
C, | ||
k, | ||
n, | ||
@@ -1192,3 +1188,3 @@ O, | ||
] | ||
), ke = k( | ||
), ke = C( | ||
(v) => { | ||
@@ -1206,3 +1202,3 @@ y.current = Oe({ | ||
[q, X, c] | ||
), ve = k( | ||
), ve = C( | ||
({ data: v }) => { | ||
@@ -1212,3 +1208,3 @@ a == null || a(v); | ||
[a] | ||
), xe = k( | ||
), xe = C( | ||
(v) => { | ||
@@ -1219,3 +1215,3 @@ const K = u == null ? void 0 : u(); | ||
[u] | ||
), Se = k( | ||
), Se = C( | ||
(v) => { | ||
@@ -1228,3 +1224,3 @@ I.current || d == null || d( | ||
); | ||
return /* @__PURE__ */ D( | ||
return /* @__PURE__ */ T( | ||
"div", | ||
@@ -1247,3 +1243,3 @@ { | ||
{ | ||
ref: b, | ||
ref: g, | ||
columnDefs: Ce, | ||
@@ -1250,0 +1246,0 @@ defaultColDef: be, |
{ | ||
"name": "@gisce/react-formiga-table", | ||
"version": "1.4.0-alpha.2", | ||
"version": "1.4.0-alpha.3", | ||
"engines": { | ||
@@ -127,3 +127,9 @@ "node": "20.5.0" | ||
], | ||
"@semantic-release/github", | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
"successComment": false, | ||
"failComment": false | ||
} | ||
], | ||
"@semantic-release/git" | ||
@@ -130,0 +136,0 @@ ] |
@@ -81,8 +81,2 @@ import { AgGridReact } from "ag-grid-react"; | ||
useEffect(() => { | ||
return () => { | ||
timeoutRef.current && clearTimeout(timeoutRef.current); | ||
}; | ||
}, [onHeaderCheckboxChange]); | ||
const onSelectionChanged = useCallback( | ||
@@ -89,0 +83,0 @@ (event: { api: { getSelectedNodes: () => any } }) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
366374
6606