New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gisce/react-formiga-table

Package Overview
Dependencies
Maintainers
0
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gisce/react-formiga-table - npm Package Compare versions

Comparing version 1.3.0-alpha.4 to 1.3.0-alpha.5

dist/components/InfiniteTable/columnStateHelper.d.ts

1148

dist/react-formiga-table.es.js

@@ -1,31 +0,31 @@

import { jsx as p, jsxs as M, Fragment as le } from "react/jsx-runtime";
import O, { useState as T, useRef as K, useEffect as L, useCallback as k, forwardRef as ce, useImperativeHandle as de, memo as G, useMemo as ne } from "react";
import { jsx as p, jsxs as M, Fragment as ie } from "react/jsx-runtime";
import j, { useState as T, useRef as L, useEffect as A, useCallback as C, forwardRef as ce, useImperativeHandle as ae, memo as V, useMemo as J } from "react";
import ve from "use-deep-compare-effect";
import Ce from "style-object-to-css-string";
import xe from "styled-components";
import { AgGridReact as Re } from "ag-grid-react";
import xe from "style-object-to-css-string";
import Se from "styled-components";
import { AgGridReact as we } from "ag-grid-react";
import "ag-grid-community/styles/ag-grid.css";
import { useCustomCompareMemo as we } from "use-custom-compare";
import ae from "lodash/debounce";
const Se = ({
import { useCustomCompareMemo as Ie } from "use-custom-compare";
import de from "lodash/debounce";
const Ee = ({
dataSource: e,
onFetchChildrenForRecord: t,
childField: r = "child_id"
childField: n = "child_id"
}) => {
const [s, c] = T([]), [i, u] = T([]), n = K(/* @__PURE__ */ new Map()), [o, l] = T(
const [s, a] = T([]), [l, i] = T([]), r = L(/* @__PURE__ */ new Map()), [o, c] = T(
e.map(
(d) => V({
entry: d,
childField: r,
idLevelMap: n.current
(f) => Q({
entry: f,
childField: n,
idLevelMap: r.current
})
)
);
L(() => {
l(
A(() => {
c(
e.map(
(d) => V({
entry: d,
childField: r,
idLevelMap: n.current
(f) => Q({
entry: f,
childField: n,
idLevelMap: r.current
})

@@ -35,45 +35,45 @@ )

}, [e]);
const a = k(
(d) => {
s.indexOf(d) === -1 ? (s.push(d), c([...s])) : c(s.filter((g) => g !== d));
const d = C(
(f) => {
s.indexOf(f) === -1 ? (s.push(f), a([...s])) : a(s.filter((y) => y !== f));
},
[s]
), f = k(
(d) => s.includes(d),
), u = C(
(f) => s.includes(f),
[s]
), v = k(
(d) => i.includes(d),
[i]
), m = (d) => n.current.get(d) || 0, w = k(
(d) => {
const g = o.find((y) => y.id === d);
return g ? g[r] !== void 0 && g[r].length > 0 : !1;
), b = C(
(f) => l.includes(f),
[l]
), g = (f) => r.current.get(f) || 0, S = C(
(f) => {
const y = o.find((m) => m.id === f);
return y ? y[n] !== void 0 && y[n].length > 0 : !1;
},
[r, o]
), E = k(
(d) => {
const g = o.find((y) => y.id === d);
return g ? g.isLoading : !1;
[n, o]
), w = C(
(f) => {
const y = o.find((m) => m.id === f);
return y ? y.isLoading : !1;
},
[o]
), b = k(
(d) => {
const g = o.find((S) => S.id === d);
if (!g)
), k = C(
(f) => {
const y = o.find((E) => E.id === f);
if (!y)
return [];
const y = g[r];
return y ? o.filter((S) => y.includes(S.id)) : [];
const m = y[n];
return m ? o.filter((E) => m.includes(E.id)) : [];
},
[r, o]
), h = k(
async (d) => {
const g = o.find((y) => y.id === d.id);
if (!g)
[n, o]
), h = C(
async (f) => {
const y = o.find((m) => m.id === f.id);
if (!y)
return !1;
if (!g.isLoading) {
if (!f(d.id) && !v(g.id)) {
l(
W(
if (!y.isLoading) {
if (!u(f.id) && !b(y.id)) {
c(
U(
{
...g,
...y,
isLoading: !0

@@ -85,9 +85,9 @@ },

try {
const y = await (t == null ? void 0 : t(g)) || [];
y.forEach((S) => {
n.current.set(S.id, g.level + 1);
}), l(
W(
const m = await (t == null ? void 0 : t(y)) || [];
m.forEach((E) => {
r.current.set(E.id, y.level + 1);
}), c(
U(
{
...g,
...y,
isLoading: !1

@@ -97,15 +97,15 @@ },

...o,
...y.map((S) => V({
entry: S,
childField: r,
idLevelMap: n.current
...m.map((E) => Q({
entry: E,
childField: n,
idLevelMap: r.current
}))
]
)
), i.push(g.id), u([...i]);
} catch (y) {
console.error(y), l(
W(
), l.push(y.id), i([...l]);
} catch (m) {
console.error(m), c(
U(
{
...g,
...y,
isLoading: !1

@@ -118,3 +118,3 @@ },

}
a(d.id);
d(f.id);
}

@@ -124,34 +124,34 @@ },

o,
f,
v,
a,
u,
b,
d,
t,
i,
r
l,
n
]
), R = k(
(d) => E(d.id) ? "loading" : w(d.id) ? f(d.id) ? "collapse" : "expand" : "none",
[E, w, f]
), x = k(() => {
const g = o.filter((y) => y.level === 0).map((y) => y.id);
return s.forEach((y) => {
const S = o.find((D) => D.id === y);
S && S.child_id && S.child_id.forEach((D) => {
g.includes(D) || g.push(D);
), I = C(
(f) => w(f.id) ? "loading" : S(f.id) ? u(f.id) ? "collapse" : "expand" : "none",
[w, S, u]
), x = C(() => {
const y = o.filter((m) => m.level === 0).map((m) => m.id);
return s.forEach((m) => {
const E = o.find((N) => N.id === m);
E && E.child_id && E.child_id.forEach((N) => {
y.includes(N) || y.push(N);
});
}), g;
}), y;
}, [s, o]);
return {
keyIsOpened: f,
keyIsOpened: u,
onExpandableIconClicked: h,
getExpandableStatusForRow: R,
getChildsForParent: b,
getExpandableStatusForRow: I,
getChildsForParent: k,
getAllVisibleKeys: x,
getLevelForKey: m
getLevelForKey: g
};
};
function V({
function Q({
entry: e,
childField: t,
idLevelMap: r
idLevelMap: n
}) {

@@ -162,43 +162,43 @@ return {

isLoading: !1,
level: r.get(e.id) || 0,
level: n.get(e.id) || 0,
data: e
};
}
const W = (e, t) => t.map((r) => r.id === e.id ? e : r), Ee = ({
const U = (e, t) => t.map((n) => n.id === e.id ? e : n), Ke = ({
selectionRowKeysProps: e = []
}) => {
const [t, r] = T(
const [t, n] = T(
e
);
ve(() => {
r(e);
n(e);
}, [e]);
const s = k(
(n) => {
if (t.length === n.length || t.length > 0) {
r([]);
const s = C(
(r) => {
if (t.length === r.length || t.length > 0) {
n([]);
return;
}
r(n);
n(r);
},
[t, r]
), c = k(
(n, o) => {
o.length !== 0 && r(n ? [.../* @__PURE__ */ new Set([...t, ...o])] : t.filter((l) => !o.includes(l)));
[t, n]
), a = C(
(r, o) => {
o.length !== 0 && n(r ? [.../* @__PURE__ */ new Set([...t, ...o])] : t.filter((c) => !o.includes(c)));
},
[t, r]
), i = k(
(n) => {
[t, n]
), l = C(
(r) => {
if (t.find(
(l) => n.id === l
(c) => r.id === c
) === void 0) {
r([...t, n.id]);
n([...t, r.id]);
return;
}
r([...t.filter((l) => l !== n.id)]);
n([...t.filter((c) => c !== r.id)]);
},
[t, r]
), u = k(
(n) => t.find(
(l) => n.id === l
[t, n]
), i = C(
(r) => t.find(
(c) => r.id === c
) !== void 0,

@@ -209,28 +209,28 @@ [t]

selectedRowKeys: t,
isRowSelected: u,
isRowSelected: i,
toggleAllRowsSelected: s,
toggleRowSelected: i,
changeSelected: c
toggleRowSelected: l,
changeSelected: a
};
}, Ie = (e, t) => {
const [r, s] = T(null), [c, i] = T(!1), [u, n] = T(null);
return k(
(l, a) => {
if (a.nativeEvent.shiftKey) {
const f = e.findIndex((b) => b === l), v = e.findIndex((b) => b === r), m = e.findIndex(
(b) => b === u
), w = Math.min(f, v), E = Math.max(f, v);
if (w > -1 && E > -1) {
t(c, e.slice(w, E + 1)), m > E && t(
!c,
e.slice(E + 1, m + 1)
), m < w && t(
!c,
e.slice(m, w)
), n(l);
}, Le = (e, t) => {
const [n, s] = T(null), [a, l] = T(!1), [i, r] = T(null);
return C(
(c, d) => {
if (d.nativeEvent.shiftKey) {
const u = e.findIndex((k) => k === c), b = e.findIndex((k) => k === n), g = e.findIndex(
(k) => k === i
), S = Math.min(u, b), w = Math.max(u, b);
if (S > -1 && w > -1) {
t(a, e.slice(S, w + 1)), g > w && t(
!a,
e.slice(w + 1, g + 1)
), g < S && t(
!a,
e.slice(g, S)
), r(c);
return;
}
} else
s(l), n(null), i(a.target.checked);
t(a.target.checked, [l]);
s(c), r(null), l(d.target.checked);
t(d.target.checked, [c]);
},

@@ -240,22 +240,22 @@ [

e,
r,
n,
s,
c,
a,
l,
i,
u,
n
r
]
);
}, Ke = (e) => {
const [t, r] = T(e), s = k(
(i) => {
if (t && i === t.id)
}, Ne = (e) => {
const [t, n] = T(e), s = C(
(l) => {
if (t && l === t.id)
return t;
},
[t]
), c = k(
(i) => {
), a = C(
(l) => {
if (!t) {
r({
id: i,
n({
id: l,
desc: !1

@@ -265,5 +265,5 @@ });

}
if (t.id !== i) {
r({
id: i,
if (t.id !== l) {
n({
id: l,
desc: !1

@@ -274,4 +274,4 @@ });

if (t.desc === !1) {
r({
id: i,
n({
id: l,
desc: !0

@@ -281,3 +281,3 @@ });

}
t.desc === !0 && r(void 0);
t.desc === !0 && n(void 0);
},

@@ -289,9 +289,9 @@ [t]

getColumnSorter: s,
handleColumnClick: c
handleColumnClick: a
};
}, Le = xe.div`
}, Ae = Se.div`
overflow-x: auto;
height: ${({ height: e }) => `${e}px` || "auto"};
border-bottom: 1px solid #f0f0f0;
${(e) => Ce(e.containerStyle ?? {})}
${(e) => xe(e.containerStyle ?? {})}

@@ -385,5 +385,5 @@ table {

}) => {
const r = O.useRef();
return O.useEffect(() => {
const s = r.current;
const n = j.useRef();
return j.useEffect(() => {
const s = n.current;
e === !0 ? (s.checked = !0, s.indeterminate = !1) : e === !1 ? (s.checked = !1, s.indeterminate = !1) : e === null && (s.checked = !1, s.indeterminate = !0);

@@ -396,3 +396,3 @@ }), /* @__PURE__ */ p(

},
ref: r,
ref: n,
type: "checkbox",

@@ -406,12 +406,12 @@ onChange: t,

allRowsAreSelected: t,
columns: r,
columns: n,
toggleAllRowsSelected: s,
selectedRowKeys: c,
handleColumnClick: i,
getColumnSorter: u,
sortEnabled: n,
selectedRowKeys: a,
handleColumnClick: l,
getColumnSorter: i,
sortEnabled: r,
readonly: o,
status: l = !1,
headerStyle: a
}) => /* @__PURE__ */ M(le, { children: [
status: c = !1,
headerStyle: d
}) => /* @__PURE__ */ M(ie, { children: [
e && !o && /* @__PURE__ */ p(

@@ -425,3 +425,3 @@ "th",

backgroundColor: "#f2f2f2",
...a,
...d,
cursor: "auto"

@@ -441,3 +441,3 @@ },

{
value: t ? !0 : c.length === 0 ? !1 : null,
value: t ? !0 : a.length === 0 ? !1 : null,
onChange: s

@@ -451,9 +451,9 @@ }

),
l && /* @__PURE__ */ p("th", { style: { ...a } }, "th-status"),
r.map((f) => /* @__PURE__ */ p(
c && /* @__PURE__ */ p("th", { style: { ...d } }, "th-status"),
n.map((u) => /* @__PURE__ */ p(
"th",
{
style: { ...a },
onClick: n ? () => {
i(f.key);
style: { ...d },
onClick: r ? () => {
l(u.key);
} : void 0,

@@ -468,5 +468,5 @@ children: /* @__PURE__ */ M("div", { className: "ctx", children: [

justifyContent: "space-between",
...a == null ? void 0 : a.rftLabel
...d == null ? void 0 : d.rftLabel
},
children: f.title
children: u.title
}

@@ -479,12 +479,12 @@ ),

style: {
visibility: u(f.key) !== void 0 ? void 0 : "hidden",
visibility: i(u.key) !== void 0 ? void 0 : "hidden",
marginLeft: "auto"
},
children: u(f.key) !== void 0 && u(f.key).desc ? " ▼" : " ▲"
children: i(u.key) !== void 0 && i(u.key).desc ? " ▼" : " ▲"
},
f.key
u.key
) })
] })
},
f.key
u.key
))

@@ -494,24 +494,24 @@ ] }), se = ({

row: t,
columnIdx: r,
columnIdx: n,
level: s,
getColumnSorter: c,
expandableOpts: i,
getExpandableStatusForRow: u,
onExpandableIconClicked: n,
getColumnSorter: a,
expandableOpts: l,
getExpandableStatusForRow: i,
onExpandableIconClicked: r,
onCellRender: o,
rowIsSelected: l,
cellStyle: a
rowIsSelected: c,
cellStyle: d
}) => {
const f = c(e.key) !== void 0 ? {
backgroundColor: l ? "#E6F7FF" : "#fafafa"
} : l ? {
backgroundColor: l ? "#E6F7FF" : void 0
const u = a(e.key) !== void 0 ? {
backgroundColor: c ? "#E6F7FF" : "#fafafa"
} : c ? {
backgroundColor: c ? "#E6F7FF" : void 0
} : {};
let v;
return o ? v = o({
let b;
return o ? b = o({
column: e,
columnIdx: r,
columnIdx: n,
rowKey: t.id,
value: t[e.key]
}) : e.render ? v = e.render(t[e.key]) : v = t[e.key], /* @__PURE__ */ M("td", { style: f, children: [
}) : e.render ? b = e.render(t[e.key]) : b = t[e.key], /* @__PURE__ */ M("td", { style: u, children: [
/* @__PURE__ */ p(

@@ -521,10 +521,10 @@ De,

row: t,
columnIdx: r,
expandableOpts: i,
getExpandableStatusForRow: u,
onExpandableIconClicked: n,
columnIdx: n,
expandableOpts: l,
getExpandableStatusForRow: i,
onExpandableIconClicked: r,
level: s
}
),
/* @__PURE__ */ M("div", { style: { display: "inline-block", width: "100%", ...a }, children: [
/* @__PURE__ */ M("div", { style: { display: "inline-block", width: "100%", ...d }, children: [
/* @__PURE__ */ p(

@@ -534,7 +534,7 @@ "div",

className: "rft-label",
style: { display: "none", ...a == null ? void 0 : a.rftLabel },
style: { display: "none", ...d == null ? void 0 : d.rftLabel },
children: e.title
}
),
v
b
] })

@@ -546,19 +546,19 @@ ] });

columnIdx: t,
expandableOpts: r,
expandableOpts: n,
getExpandableStatusForRow: s,
onExpandableIconClicked: c,
level: i
onExpandableIconClicked: a,
level: l
}) {
if (!r)
if (!n)
return null;
const u = s(e);
if (u === "none" || t !== 0)
return /* @__PURE__ */ p("div", { style: { display: "inline-block", width: 19 + i * 25 } });
let n;
return u === "expand" ? n = r.expandIcon : u === "collapse" ? n = r.collapseIcon : u === "loading" && (n = r.loadingIcon), /* @__PURE__ */ p("div", { style: { display: "inline-block" }, children: /* @__PURE__ */ p(
n,
const i = s(e);
if (i === "none" || t !== 0)
return /* @__PURE__ */ p("div", { style: { display: "inline-block", width: 19 + l * 25 } });
let r;
return i === "expand" ? r = n.expandIcon : i === "collapse" ? r = n.collapseIcon : i === "loading" && (r = n.loadingIcon), /* @__PURE__ */ p("div", { style: { display: "inline-block" }, children: /* @__PURE__ */ p(
r,
{
style: { marginRight: 5, marginLeft: i * 25 },
style: { marginRight: 5, marginLeft: l * 25 },
onClick: () => {
c(e);
a(e);
}

@@ -568,3 +568,3 @@ }

}
class oe extends O.Component {
class oe extends j.Component {
constructor(t) {

@@ -576,4 +576,4 @@ super(t), this.state = { hasError: !1, error: null, errorInfo: null };

}
componentDidCatch(t, r) {
this.setState({ errorInfo: r }), console.error("Error caught by ErrorBoundary:", t, r);
componentDidCatch(t, n) {
this.setState({ errorInfo: n }), console.error("Error caught by ErrorBoundary:", t, n);
}

@@ -605,34 +605,34 @@ render() {

dataSource: t,
columns: r,
columns: n,
getColumnSorter: s,
onRowStyle: c,
onRowStatus: i,
onRowDoubleClick: u,
isRowSelected: n,
onRowStyle: a,
onRowStatus: l,
onRowDoubleClick: i,
isRowSelected: r,
toggleRowSelected: o,
expandableOpts: l,
onExpandableIconClicked: a,
getExpandableStatusForRow: f,
keyIsOpened: v,
getChildsForParent: m,
getLevelForKey: w,
onCellRender: E,
cellStyle: b,
expandableOpts: c,
onExpandableIconClicked: d,
getExpandableStatusForRow: u,
keyIsOpened: b,
getChildsForParent: g,
getLevelForKey: S,
onCellRender: w,
cellStyle: k,
readonly: h
}) => /* @__PURE__ */ p(le, { children: t.filter((R) => w(R.id) === 0).map((R) => fe({
row: R,
columns: r,
onRowStyle: c,
onRowStatus: i,
onRowDoubleClick: u,
}) => /* @__PURE__ */ p(ie, { children: t.filter((I) => S(I.id) === 0).map((I) => fe({
row: I,
columns: n,
onRowStyle: a,
onRowStatus: l,
onRowDoubleClick: i,
onRowSelectionChange: e,
isRowSelected: n,
isRowSelected: r,
toggleRowSelected: o,
expandableOpts: l,
getExpandableStatusForRow: f,
onExpandableIconClicked: a,
expandableOpts: c,
getExpandableStatusForRow: u,
onExpandableIconClicked: d,
getColumnSorter: s,
keyIsOpened: v,
getChildsForParent: m,
cellStyle: b,
keyIsOpened: b,
getChildsForParent: g,
cellStyle: k,
readonly: h

@@ -643,28 +643,28 @@ })) });

columns: t,
onRowDoubleClick: r,
onRowDoubleClick: n,
onRowSelectionChange: s,
isRowSelected: c,
toggleRowSelected: i,
expandableOpts: u,
getExpandableStatusForRow: n,
isRowSelected: a,
toggleRowSelected: l,
expandableOpts: i,
getExpandableStatusForRow: r,
onExpandableIconClicked: o,
getColumnSorter: l,
keyIsOpened: a,
getChildsForParent: f,
onRowStyle: v,
onRowStatus: m,
level: w = 0,
onCellRender: E,
cellStyle: b,
getColumnSorter: c,
keyIsOpened: d,
getChildsForParent: u,
onRowStyle: b,
onRowStatus: g,
level: S = 0,
onCellRender: w,
cellStyle: k,
readonly: h
}) {
var g;
const R = v ? v(e) : "", x = c(e);
let d = [
var y;
const I = b ? b(e) : "", x = a(e);
let f = [
/* @__PURE__ */ M(
"tr",
{
style: R,
style: I,
onDoubleClick: () => {
r == null || r(e);
n == null || n(e);
},

@@ -681,4 +681,4 @@ children: [

},
onDoubleClick: (y) => {
y.stopPropagation(), y.preventDefault();
onDoubleClick: (m) => {
m.stopPropagation(), m.preventDefault();
},

@@ -698,4 +698,4 @@ children: /* @__PURE__ */ p(

value: x,
onChange: (y) => {
i(e.id, y);
onChange: (m) => {
l(e.id, m);
}

@@ -709,3 +709,3 @@ }

),
m && /* @__PURE__ */ p(oe, { children: /* @__PURE__ */ p(
g && /* @__PURE__ */ p(oe, { children: /* @__PURE__ */ p(
se,

@@ -718,26 +718,26 @@ {

columnIdx: -1,
onCellRender: () => m(e),
expandableOpts: u,
getExpandableStatusForRow: n,
onCellRender: () => g(e),
expandableOpts: i,
getExpandableStatusForRow: r,
onExpandableIconClicked: o,
level: w,
level: S,
rowIsSelected: x,
cellStyle: b
cellStyle: k
}
) }, `status-${e.id}`),
t.map((y, S) => /* @__PURE__ */ p(oe, { children: /* @__PURE__ */ p(
t.map((m, E) => /* @__PURE__ */ p(oe, { children: /* @__PURE__ */ p(
se,
{
column: y,
columnIdx: S,
column: m,
columnIdx: E,
row: e,
getColumnSorter: l,
expandableOpts: u,
getExpandableStatusForRow: n,
getColumnSorter: c,
expandableOpts: i,
getExpandableStatusForRow: r,
onExpandableIconClicked: o,
level: w,
level: S,
rowIsSelected: x,
cellStyle: b
cellStyle: k
}
) }, `${y.key}-${e.id}`))
) }, `${m.key}-${e.id}`))
]

@@ -748,50 +748,50 @@ },

];
return u !== void 0 && a(e.id) && (d = d.concat(
(g = f(e.id)) == null ? void 0 : g.map((y) => fe({
row: y.data,
return i !== void 0 && d(e.id) && (f = f.concat(
(y = u(e.id)) == null ? void 0 : y.map((m) => fe({
row: m.data,
columns: t,
onRowStyle: v,
onRowDoubleClick: r,
onRowStyle: b,
onRowDoubleClick: n,
onRowSelectionChange: s,
isRowSelected: c,
toggleRowSelected: i,
expandableOpts: u,
getExpandableStatusForRow: n,
isRowSelected: a,
toggleRowSelected: l,
expandableOpts: i,
getExpandableStatusForRow: r,
onExpandableIconClicked: o,
getColumnSorter: l,
keyIsOpened: a,
getChildsForParent: f,
level: y.level,
onCellRender: E,
onRowStatus: m
getColumnSorter: c,
keyIsOpened: d,
getChildsForParent: u,
level: m.level,
onCellRender: w,
onRowStatus: g
}))
)), d;
)), f;
}
const Ne = ce((e, t) => {
const Re = ce((e, t) => {
const {
height: r,
height: n,
loading: s,
loadingComponent: c,
dataSource: i,
columns: u,
onRowDoubleClick: n,
loadingComponent: a,
dataSource: l,
columns: i,
onRowDoubleClick: r,
onRowStyle: o,
onRowStatus: l,
onRowSelectionChange: a,
onChangeSort: f,
sorter: v,
expandableOpts: m,
onCellRender: w,
readonly: E,
selectionRowKeys: b,
onRowStatus: c,
onRowSelectionChange: d,
onChangeSort: u,
sorter: b,
expandableOpts: g,
onCellRender: S,
readonly: w,
selectionRowKeys: k,
customStyle: h
} = e, {
selectedRowKeys: R,
selectedRowKeys: I,
toggleAllRowsSelected: x,
isRowSelected: d,
changeSelected: g
} = Ee({
selectionRowKeysProps: b
isRowSelected: f,
changeSelected: y
} = Ke({
selectionRowKeysProps: k
});
de(t, () => ({
ae(t, () => ({
unselectAll: () => {

@@ -801,31 +801,31 @@ x([]);

}));
const y = Ie(
i.map((Q) => Q.id),
g
), { localSorter: S, getColumnSorter: D, handleColumnClick: P } = Ke(v), {
keyIsOpened: A,
onExpandableIconClicked: _,
getExpandableStatusForRow: $,
getChildsForParent: B,
getAllVisibleKeys: F,
const m = Le(
l.map((H) => H.id),
y
), { localSorter: E, getColumnSorter: N, handleColumnClick: O } = Ne(b), {
keyIsOpened: _,
onExpandableIconClicked: z,
getExpandableStatusForRow: F,
getChildsForParent: P,
getAllVisibleKeys: D,
getLevelForKey: q
} = Se({
dataSource: i,
onFetchChildrenForRecord: m == null ? void 0 : m.onFetchChildrenForRecord,
childField: m == null ? void 0 : m.childField
} = Ee({
dataSource: l,
onFetchChildrenForRecord: g == null ? void 0 : g.onFetchChildrenForRecord,
childField: g == null ? void 0 : g.childField
});
L(() => {
a == null || a(R);
}, [R]), L(() => {
f == null || f(S);
}, [S]);
const H = k(() => R.length === 0 ? !1 : m ? F().length === R.length : i.length === R.length, [i.length, m, R.length]), j = k(() => {
x(F());
}, [x, F]);
return s ? c : /* @__PURE__ */ p(
Le,
A(() => {
d == null || d(I);
}, [I]), A(() => {
u == null || u(E);
}, [E]);
const W = C(() => I.length === 0 ? !1 : g ? D().length === I.length : l.length === I.length, [l.length, g, I.length]), B = C(() => {
x(D());
}, [x, D]);
return s ? a : /* @__PURE__ */ p(
Ae,
{
height: r,
canClick: n !== void 0,
readonly: E,
height: n,
canClick: r !== void 0,
readonly: w,
containerStyle: h == null ? void 0 : h.containerStyle,

@@ -836,12 +836,12 @@ children: /* @__PURE__ */ M("table", { style: h == null ? void 0 : h.tableStyle, children: [

{
allRowsAreSelected: H(),
columns: u,
onRowSelectionChange: a,
selectedRowKeys: R,
toggleAllRowsSelected: j,
handleColumnClick: P,
getColumnSorter: D,
sortEnabled: m === void 0,
readonly: E,
status: !!l,
allRowsAreSelected: W(),
columns: i,
onRowSelectionChange: d,
selectedRowKeys: I,
toggleAllRowsSelected: B,
handleColumnClick: O,
getColumnSorter: N,
sortEnabled: g === void 0,
readonly: w,
status: !!c,
headerStyle: h == null ? void 0 : h.headerStyle

@@ -853,20 +853,20 @@ }

{
dataSource: i,
columns: u,
onRowSelectionChange: a,
getColumnSorter: D,
onRowDoubleClick: n,
dataSource: l,
columns: i,
onRowSelectionChange: d,
getColumnSorter: N,
onRowDoubleClick: r,
onRowStyle: o,
onRowStatus: l,
isRowSelected: d,
toggleRowSelected: y,
expandableOpts: m,
onExpandableIconClicked: _,
getExpandableStatusForRow: $,
keyIsOpened: A,
getChildsForParent: B,
onRowStatus: c,
isRowSelected: f,
toggleRowSelected: m,
expandableOpts: g,
onExpandableIconClicked: z,
getExpandableStatusForRow: F,
keyIsOpened: _,
getChildsForParent: P,
getLevelForKey: q,
onCellRender: w,
onCellRender: S,
cellStyle: h == null ? void 0 : h.cellStyle,
readonly: E
readonly: w
}

@@ -878,11 +878,11 @@ ) })

});
Ne.displayName = "Table";
const Ae = (e, t) => we(
Re.displayName = "Table";
const ze = (e, t) => Ie(
() => e,
[e],
(r, s) => {
const c = r[0], i = s[0], u = c.map((o) => o[t]).sort((o, l) => o.localeCompare(l)).join(","), n = i.map((o) => o[t]).sort((o, l) => o.localeCompare(l)).join(",");
return u === n;
(n, s) => {
const a = n[0], l = s[0], i = a.map((o) => o[t]).sort((o, c) => o.localeCompare(c)).join(","), r = l.map((o) => o[t]).sort((o, c) => o.localeCompare(c)).join(",");
return i === r;
}
), pe = G(
), pe = V(
({

@@ -892,5 +892,5 @@ value: e,

}) => {
const r = O.useRef();
return L(() => {
const s = r.current;
const n = j.useRef();
return A(() => {
const s = n.current;
e === !0 ? (s.checked = !0, s.indeterminate = !1) : e === !1 ? (s.checked = !1, s.indeterminate = !1) : e === null && (s.checked = !1, s.indeterminate = !0);

@@ -910,3 +910,3 @@ }), /* @__PURE__ */ p(

},
ref: r,
ref: n,
type: "checkbox",

@@ -920,51 +920,51 @@ onChange: t,

pe.displayName = "HeaderCheckboxComp";
const he = G(
const he = V(
({
selectedRowKeysLength: e,
totalRows: t,
allRowSelected: r,
allRowSelected: n,
onHeaderCheckboxChange: s,
allRowSelectedMode: c
allRowSelectedMode: a
}) => {
const i = e === 0, u = e > 0 && t !== e;
let n = !1;
return c || t === e && t > 0 || r ? n = !0 : i ? n = !1 : u && (n = null), /* @__PURE__ */ p(pe, { value: n, onChange: s });
const l = e === 0, i = e > 0 && t !== e;
let r = !1;
return a || t === e && t > 0 || n ? r = !0 : l ? r = !1 : i && (r = null), /* @__PURE__ */ p(pe, { value: r, onChange: s });
}
);
he.displayName = "HeaderCheckbox";
const $e = 50, ze = ({
const Pe = 50, $e = ({
gridRef: e,
onRowSelectionChange: t,
onAllRowSelectedModeChange: r,
onAllRowSelectedModeChange: n,
totalRows: s,
allRowSelectedModeProps: c = !1
allRowSelectedModeProps: a = !1
}) => {
const [i, u] = T(
const [l, i] = T(
[]
), [n, o] = T(
c
), l = K(!1), a = K([]), f = K(!1), v = K(null);
L(() => {
l.current = n;
}, [n]), L(() => {
o(c), c && (u([]), f.current = !0);
}, [c]), L(() => {
r == null || r(n);
}, [n]);
const m = k(() => {
var R;
), [r, o] = T(
a
), c = L(!1), d = L([]), u = L(!1), b = L(null);
A(() => {
c.current = r;
}, [r]), A(() => {
o(a), a && (i([]), u.current = !0);
}, [a]), A(() => {
n == null || n(r);
}, [r]);
const g = C(() => {
var I;
let h = !1;
n ? h = !1 : !n && i.length === 0 ? h = !0 : !n && i.length === s ? h = !1 : (n || i.length > 0) && (h = !0), f.current = !0, (R = e == null ? void 0 : e.current) == null || R.api.forEachNode((x) => {
r ? h = !1 : !r && l.length === 0 ? h = !0 : !r && l.length === s ? h = !1 : (r || l.length > 0) && (h = !0), u.current = !0, (I = e == null ? void 0 : e.current) == null || I.api.forEachNode((x) => {
x.setSelected(h);
}), o(h), v.current && clearTimeout(v.current), v.current = setTimeout(() => {
f.current = !1;
}), o(h), b.current && clearTimeout(b.current), b.current = setTimeout(() => {
u.current = !1;
}, 1e3);
}, [n, i.length, s, e]);
L(() => () => {
v.current && clearTimeout(v.current);
}, [m]);
const w = k(
}, [r, l.length, s, e]);
A(() => () => {
b.current && clearTimeout(b.current);
}, [g]);
const S = C(
(h) => {
if (f.current) {
t == null || t([]), u([]);
if (u.current) {
t == null || t([]), i([]);
return;

@@ -974,84 +974,134 @@ }

let x = h.api.getSelectedNodes().map(
(d) => d.data.id
(f) => f.data.id
);
x = x.concat(
a.current
), t == null || t(x), u(x);
d.current
), t == null || t(x), i(x);
},
[t]
), E = k(
ae((h) => {
w == null || w(h);
}, $e),
[w]
), b = k((h) => {
a.current = h;
), w = C(
de((h) => {
S == null || S(h);
}, Pe),
[S]
), k = C((h) => {
d.current = h;
}, []);
return {
internalSelectedRowKeys: i,
onHeaderCheckboxChange: m,
allRowSelectedMode: n,
onSelectionChangedDebounced: E,
selectedRowKeysPendingToRender: a.current,
setSelectedRowKeysPendingToRender: b
internalSelectedRowKeys: l,
onHeaderCheckboxChange: g,
allRowSelectedMode: r,
onSelectionChangedDebounced: w,
selectedRowKeysPendingToRender: d.current,
setSelectedRowKeysPendingToRender: k
};
}, ie = 50, ye = ce(
}, Fe = ({
gridRef: e,
containerRef: t,
columnsPersistedStateRef: n
}) => {
const s = L(!1), a = C(
(i) => {
var c;
const r = i == null ? void 0 : i.reduce(
(d, u) => d + u.getActualWidth(),
0
), o = (c = t == null ? void 0 : t.current) == null ? void 0 : c.clientWidth;
return !o || !r ? 0 : o - r;
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
return {
autoSizeColumnsIfNecessary: C(() => {
!n.current && !s.current && (s.current = !0, setTimeout(() => {
var o, c, d, u;
(o = e == null ? void 0 : e.current) == null || o.api.autoSizeAllColumns();
const i = (c = e == null ? void 0 : e.current) == null ? void 0 : c.api.getAllGridColumns();
if (!i)
return;
const r = a(i);
if (r > 0) {
const b = r / (i.length - 1), S = ((d = e == null ? void 0 : e.current) == null ? void 0 : d.api.getColumnState()).map((w) => ({
...w,
// colId 0 is the checkbox column
width: w.colId !== "0" ? w.width + b : w.width
}));
(u = e == null ? void 0 : e.current) == null || u.api.applyColumnState({ state: S });
}
}, 50));
}, [a])
};
}, _e = ({
actualColumnKeys: e,
persistedColumnState: t
}) => {
if (!t)
return;
const n = t.map(
(i) => i.colId
), s = [...e].sort(), a = [...n].sort();
if (JSON.stringify(s) === JSON.stringify(a))
return t;
}, le = 50, me = ce(
(e, t) => {
const {
onRequestData: r,
onRequestData: n,
columns: s,
onRowDoubleClick: c,
onRowSelectionChange: i,
height: u,
onRowStyle: n,
onRowDoubleClick: a,
onRowSelectionChange: l,
height: i,
onRowStyle: r,
onColumnChanged: o,
onGetColumnsState: l,
onChangeFirstVisibleRowIndex: a,
onGetFirstVisibleRowIndex: f,
onGetSelectedRowKeys: v,
totalRows: m,
onAllRowSelectedModeChange: w,
allRowSelectedMode: E
} = e, b = K(null), h = K(!0), R = K(!1), x = K(), d = K(!1), g = k(
ae((C) => {
o == null || o(C);
}, ie),
onGetColumnsState: c,
onChangeFirstVisibleRowIndex: d,
onGetFirstVisibleRowIndex: u,
onGetSelectedRowKeys: b,
totalRows: g,
onAllRowSelectedModeChange: S,
allRowSelectedMode: w
} = e, k = L(null), h = L(!0), I = L(!1), x = L(), f = L(null), { autoSizeColumnsIfNecessary: y } = Fe({
gridRef: k,
containerRef: f,
columnsPersistedStateRef: x
}), m = C(
de((v) => {
o == null || o(v);
}, le),
[o]
), y = k(
(C) => {
const I = C.api.getColumnState();
g(I);
), E = C(
(v) => {
const K = v.api.getColumnState();
m(K);
},
[g]
[m]
);
de(t, () => ({
ae(t, () => ({
unselectAll: () => {
var C, I;
$([]), (I = (C = b.current) == null ? void 0 : C.api) == null || I.deselectAll();
var v, K;
P([]), (K = (v = k.current) == null ? void 0 : v.api) == null || K.deselectAll();
},
refresh: () => {
var C, I;
(I = (C = b.current) == null ? void 0 : C.api) == null || I.purgeInfiniteCache();
var v, K;
(K = (v = k.current) == null ? void 0 : v.api) == null || K.purgeInfiniteCache();
}
}));
const {
onHeaderCheckboxChange: S,
onSelectionChangedDebounced: D,
selectedRowKeysPendingToRender: P,
allRowSelectedMode: A,
internalSelectedRowKeys: _,
setSelectedRowKeysPendingToRender: $
} = ze({
gridRef: b,
onRowSelectionChange: i,
onAllRowSelectedModeChange: w,
totalRows: m,
allRowSelectedModeProps: E
onHeaderCheckboxChange: N,
onSelectionChangedDebounced: O,
selectedRowKeysPendingToRender: _,
allRowSelectedMode: z,
internalSelectedRowKeys: F,
setSelectedRowKeysPendingToRender: P
} = $e({
gridRef: k,
onRowSelectionChange: l,
onAllRowSelectedModeChange: S,
totalRows: g,
allRowSelectedModeProps: w
});
L(() => {
R.current = A;
}, [A]), L(() => {
x.current || (x.current = l == null ? void 0 : l());
}, [l]);
const B = Ae(s, "key"), F = ne(() => ({}), []), q = ne(() => [
A(() => {
I.current = z;
}, [z]);
const D = ze(s, "key"), q = J(() => ({}), []), W = J(() => [
{

@@ -1068,44 +1118,49 @@ checkboxSelection: !0,

{
totalRows: m,
selectedRowKeysLength: _.length,
allRowSelected: m === _.length,
allRowSelectedMode: A,
onHeaderCheckboxChange: S
totalRows: g,
selectedRowKeysLength: F.length,
allRowSelected: g === F.length,
allRowSelectedMode: z,
onHeaderCheckboxChange: N
}
)
},
...B.map((C) => ({
field: C.key,
...D.map((v) => ({
field: v.key,
sortable: !1,
headerName: C.title,
cellRenderer: C.render ? (I) => C.render(I.value) : void 0
headerName: v.title,
cellRenderer: v.render ? (K) => v.render(K.value) : void 0
}))
], [
A,
B,
_.length,
S,
m
]), H = k(() => {
!x.current && !d.current && (d.current = !0, setTimeout(() => {
var C;
(C = b.current) == null || C.api.autoSizeAllColumns();
}, 50));
}, []), j = k(
async (C) => {
var Y, Z, ee, te;
(Y = b.current) == null || Y.api.showLoadingOverlay();
const { startRow: I, endRow: J } = C, U = await r(I, J);
let X = -1;
if (U.length < J - I && (X = I + U.length), C.successCallback(U, X), R.current)
(Z = b == null ? void 0 : b.current) == null || Z.api.forEachNode((z) => {
z.setSelected(!0);
z,
D,
F.length,
N,
g
]), B = J(
() => D.map((v) => v.key),
[D]
);
A(() => {
x.current || (x.current = _e({
actualColumnKeys: B,
persistedColumnState: x.current
}));
}, [B, c]);
const H = C(
async (v) => {
var Z, ee, te, ne;
(Z = k.current) == null || Z.api.showLoadingOverlay();
const { startRow: K, endRow: X } = v, G = await n(K, X);
let Y = -1;
if (G.length < X - K && (Y = K + G.length), v.successCallback(G, Y), I.current)
(ee = k == null ? void 0 : k.current) == null || ee.api.forEachNode(($) => {
$.setSelected(!0);
});
else {
const z = v == null ? void 0 : v();
$(z || []), z && z.length > 0 && ((ee = b == null ? void 0 : b.current) == null || ee.api.forEachNode((N) => {
const $ = b == null ? void 0 : b();
P($ || []), $ && $.length > 0 && ((te = k == null ? void 0 : k.current) == null || te.api.forEachNode((R) => {
var re;
(re = N == null ? void 0 : N.data) != null && re.id && z.includes(N.data.id) && (N.setSelected(!0), $(
P.filter(
(ke) => N.data.id && ke !== N.data.id
(re = R == null ? void 0 : R.data) != null && re.id && $.includes(R.data.id) && (R.setSelected(!0), P(
_.filter(
(ke) => R.data.id && ke !== R.data.id
)

@@ -1115,39 +1170,39 @@ ));

}
(te = b.current) == null || te.api.hideOverlay(), H();
(ne = k.current) == null || ne.api.hideOverlay(), y();
},
[
H,
v,
r,
P,
$
y,
b,
n,
_,
P
]
), Q = k(
(C) => {
x.current && C.api.applyColumnState({
), ye = C(
(v) => {
x.current && v.api.applyColumnState({
state: x.current,
applyOrder: !0
}), C.api.setGridOption("datasource", {
getRows: j
}), v.api.setGridOption("datasource", {
getRows: H
});
},
[j]
), ge = k(
({ data: C }) => {
c == null || c(C);
[H]
), ge = C(
({ data: v }) => {
a == null || a(v);
},
[c]
), me = k(
(C) => {
const I = f == null ? void 0 : f();
I && C.api.ensureIndexVisible(I, "top");
[a]
), be = C(
(v) => {
const K = u == null ? void 0 : u();
K && v.api.ensureIndexVisible(K, "top");
},
[f]
), be = k(
(C) => {
h.current || a == null || a(
C.api.getFirstDisplayedRowIndex()
[u]
), Ce = C(
(v) => {
h.current || d == null || d(
v.api.getFirstDisplayedRowIndex()
), h.current = !1;
},
[a]
[d]
);

@@ -1157,15 +1212,16 @@ return /* @__PURE__ */ p(

{
ref: f,
className: "ag-grid-default-table ag-theme-quartz",
style: { height: u || 600 },
style: { height: i || 600, width: "100%" },
children: /* @__PURE__ */ p(
Re,
we,
{
ref: b,
columnDefs: q,
defaultColDef: F,
ref: k,
columnDefs: W,
defaultColDef: q,
onRowDoubleClicked: ge,
rowStyle: {
cursor: c ? "pointer" : "auto"
cursor: a ? "pointer" : "auto"
},
getRowStyle: n,
getRowStyle: r,
suppressCellFocus: !0,

@@ -1175,7 +1231,7 @@ suppressRowClickSelection: !0,

rowSelection: "multiple",
onColumnMoved: y,
onColumnResized: y,
onColumnMoved: E,
onColumnResized: E,
rowModelType: "infinite",
cacheBlockSize: 20,
onSelectionChanged: D,
onSelectionChanged: O,
cacheOverflowSize: 2,

@@ -1185,6 +1241,6 @@ maxConcurrentDatasourceRequests: 1,

maxBlocksInCache: 10,
onGridReady: Q,
onFirstDataRendered: me,
onBodyScroll: be,
blockLoadDebounceMillis: ie
onGridReady: ye,
onFirstDataRendered: be,
onBodyScroll: Ce,
blockLoadDebounceMillis: le
}

@@ -1196,8 +1252,8 @@ )

);
ye.displayName = "InfiniteTable";
const Ue = G(ye);
me.displayName = "InfiniteTable";
const Ue = V(me);
export {
Ue as InfiniteTable,
Ne as Table
Re as Table
};
//# sourceMappingURL=react-formiga-table.es.js.map
{
"name": "@gisce/react-formiga-table",
"version": "1.3.0-alpha.4",
"version": "1.3.0-alpha.5",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc