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

@af-utils/react-mobx-table

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@af-utils/react-mobx-table - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

8

lib/bundlesize.index.js

@@ -1,4 +0,4 @@

export const raw = 14702;
export const min = 8536;
export const minGz = 3240;
export const minBrotli = 2950;
export const raw = 15509;
export const min = 9181;
export const minGz = 3420;
export const minBrotli = 3118;

@@ -1,2 +0,2 @@

import { Fragment as e, memo as t, useEffect as r, useMemo as o } from "react";
import { Fragment as t, memo as e, useLayoutEffect as r, useMemo as o } from "react";

@@ -7,34 +7,36 @@ import { observer as n, Observer as s } from "mobx-react-lite";

import { useVirtualModel as m, useOnce as d, areItemPropsEqual as h } from "@af-utils/react-virtual-headless";
import { useVirtualModel as m, useOnce as h } from "@af-utils/react-virtual-headless";
import { DefaultTableComponents as g, Table as p } from "@af-utils/react-table";
import { ColumnModel as d, DefaultTableComponents as g, Table as p } from "@af-utils/react-table";
import { useDrag as f, useDrop as x } from "react-dnd";
import { css as w, cx as y } from "@af-utils/styled";
import { css as v, cx as G } from "@af-utils/styled";
import { jsxs as v, jsx as G, Fragment as C } from "react/jsx-runtime";
import { jsxs as y, jsx as w, Fragment as C } from "react/jsx-runtime";
const b = new Intl.Collator(void 0, {
const I = new Intl.Collator(void 0, {
numeric: !0
}), I = (e, t, r) => (o, n) => {
const s = e(o), i = e(n);
if (s && i) {
const e = s[t], o = i[t];
return b.compare(e, o) * r;
}).compare, b = (t, e) => (t || 0) - (e || 0), S = (t, e, r, o) => {
const n = (t => "numeric" === t ? b : "function" == typeof t ? t : I)(o);
return (o, s) => {
const i = t(o), l = t(s);
if (i && l) {
const t = i[e], o = l[e];
return n(t, o) * r;
}
return i ? r : l ? -r : 0;
};
}, D = (t, e, r, o, n, s, i) => {
const l = t.values();
if (s < n - 1) for (const t of l) t && D(t, e, r, o, n, s + 1, i); else {
const t = S(e, r, o, i);
for (const e of l) null == e || e.sort(t);
}
return s ? r : i ? -r : 0;
}, S = function(e, t, r, o, n, s) {
void 0 === s && (s = 0);
const i = e.values();
if (s < n - 1) for (let e of i) e && S(e, t, r, o, n, s + 1); else {
const e = I(t, r, o);
for (let t of i) t && t.sort(e);
}
}, D = function(e, t, r, o, n) {
}, F = function(t, e, r, o, n) {
let s;
void 0 === r && (r = []), void 0 === o && (o = []), void 0 === n && (n = []);
for (let [i, l] of e) if (l) {
const e = r.concat(i);
s = -o.push(e), n.push(s), t.has(s) || (Array.isArray(l) ? n.push.apply(n, l) : D(l, t, e, o, n));
for (let [i, l] of t) if (l) {
const t = r.concat(i);
s = -o.push(t), n.push(s), e.has(s) || (Array.isArray(l) ? n.push.apply(n, l) : F(l, e, t, o, n));
}

@@ -45,5 +47,5 @@ return {

};
}, N = () => !1;
};
class R extends class {
class N extends class {
constructor() {

@@ -54,4 +56,4 @@ this.itemCount = 0, this.getRowData = null, this.getTotalsFormattingHelper = null,

}
setFiltering(e, t) {
t ? this.filtersMap.set(e, t.toLowerCase()) : this.filtersMap.delete(e);
setFiltering(t, e) {
e ? this.filtersMap.set(t, e.toLowerCase()) : this.filtersMap.delete(t);
}

@@ -61,39 +63,39 @@ toggleCompact() {

}
setSorting(e) {
this.sortDataKey === e && (this.sortDirection *= -1), this.sortDataKey = e;
setSorting(t) {
this.sortDataKey === t && (this.sortDirection *= -1), this.sortDataKey = t;
}
setGrouping(e) {
this.groupKeys = e;
setGrouping(t) {
this.groupKeys = t;
}
addGrouping(e) {
this.groupKeys.includes(e) || (this.groupKeys.push(e), this.collapsedGroups.clear());
addGrouping(t) {
this.groupKeys.includes(t) || (this.groupKeys.push(t), this.collapsedGroups.clear());
}
toggleCollapsedGroup(e) {
this.collapsedGroups.has(e) ? this.collapsedGroups.delete(e) : this.collapsedGroups.add(e);
toggleCollapsedGroup(t) {
this.collapsedGroups.has(t) ? this.collapsedGroups.delete(t) : this.collapsedGroups.add(t);
}
removeGrouping(e) {
const t = this.groupKeys.indexOf(e);
-1 !== t && (this.groupKeys.splice(t, 1), this.collapsedGroups.clear());
removeGrouping(t) {
const e = this.groupKeys.indexOf(t);
-1 !== e && (this.groupKeys.splice(e, 1), this.collapsedGroups.clear());
}
merge(e) {
Object.assign(this, e);
merge(t) {
Object.assign(this, t);
}
} {
get visibleColumns() {
return this.columns.filter((e => !this.groupKeys.includes(e.key)));
return this.columns.filter((t => !this.groupKeys.includes(t.key)));
}
get priorityGroupValuesArray() {
return this.groupKeys.map((e => this.columns.find((t => t.key === e)).priorityGroupValues || []));
return this.groupKeys.map((t => this.columns.find((e => e.key === t)).priorityGroupValues || []));
}
get grouped() {
return ((e, t, r, o) => {
const n = t.length - 1;
return ((t, e, r, o) => {
const n = e.length - 1;
if ("production" !== process.env.NODE_ENV && n < 0) throw new Error("lastGroupIndex < 0");
const s = t[n], i = new Map;
for (let l of e) {
const s = e[n], i = new Map;
for (const l of t) {
/*
It is better to start from indexes iteration, not from groups, to minimize getRowData calls
*/
const e = r(l);
if (!e) continue;
const t = r(l);
if (!t) continue;
let u, a, c = i;

@@ -103,5 +105,5 @@ /*

*/ for (let r = 0; r < n; r++) {
if (a = e[t[r]], u = c.get(a), !u) {
if (a = t[e[r]], u = c.get(a), !u) {
u = new Map;
for (let e of o[r]) c.has(e) || c.set(e, null);
for (let t of o[r]) c.has(t) || c.set(t, null);
c.set(a, u);

@@ -111,4 +113,4 @@ }

}
if (a = e[s], u = c.get(a), u) u.push(l); else {
for (let e of o[n]) c.has(e) || c.set(e, null);
if (a = t[s], u = c.get(a), u) u.push(l); else {
for (let t of o[n]) c.has(t) || c.set(t, null);
c.set(a, [ l ]);

@@ -121,14 +123,15 @@ }

get groupedSorted() {
return this.sortDataKey && S(this.grouped, this.getRowData, this.sortDataKey, this.sortDirection, this.groupKeys.length),
var t;
return this.sortDataKey && D(this.grouped, this.getRowData, this.sortDataKey, this.sortDirection, this.groupKeys.length, 0, null == (t = this.columns.find((t => t.key === this.sortDataKey))) ? void 0 : t.sorter),
this.grouped;
}
get flattenedGroups() {
return D(this.groupedSorted, this.collapsedGroups);
return F(this.groupedSorted, this.collapsedGroups);
}
get filteredIndexes() {
return ((e, t, r) => {
return ((t, e, r) => {
if (r.size) {
const o = [];
e: for (let n, s = 0; s < e; s++) if (n = t(s), n) {
for (const [e, t] of r) if (!("" + n[e]).toLowerCase().includes(t)) continue e;
t: for (let n, s = 0; s < t; s++) if (n = e(s), n) {
for (const [t, e] of r) if (!("" + n[t]).toLowerCase().includes(e)) continue t;
o.push(s);

@@ -139,8 +142,9 @@ }

return Array.from({
length: e
}, ((e, t) => t));
length: t
}, ((t, e) => e));
})(this.itemCount, this.getRowData, this.filtersMap);
}
get noGroupsSortedIndexes() {
return this.sortDataKey ? this.filteredIndexes.sort(I(this.getRowData, this.sortDataKey, this.sortDirection)) : this.filteredIndexes;
var t;
return this.sortDataKey ? this.filteredIndexes.sort(S(this.getRowData, this.sortDataKey, this.sortDirection, null == (t = this.columns.find((t => t.key === this.sortDataKey))) ? void 0 : t.sorter)) : this.filteredIndexes;
}

@@ -160,3 +164,3 @@ get groupsSortedIndexes() {

get hasTotals() {
return this.visibleColumns.some((e => !!e.totals));
return this.visibleColumns.some((t => !!t.totals));
}

@@ -177,11 +181,5 @@ constructor() {

}),
finalIndexes: l({
equals: N
}),
noGroupsSortedIndexes: l({
equals: N
}),
groupedSorted: l({
equals: N
}),
finalIndexes: !0,
noGroupsSortedIndexes: !0,
groupedSorted: !0,
itemCount: !0,

@@ -209,4 +207,18 @@ getRowData: !1,

const F = w("cursor: pointer", "user-select: none"), A = y(F, w("font-size: 1.2em", "font-weight: 100", "padding-right: 0.3em")), T = n((e => {
let {m: t, column: r, i: o} = e;
const R = new Intl.Collator(void 0, {
numeric: !0
}).compare, M = (t, e) => (t || 0) - (e || 0), T = t => t;
class A extends d {
constructor(t, e) {
var r;
super(t, e), this.getSortValue ||= T, this.getFilterValue ||= T, this.getGroupValue ||= T,
this.t = (r = t.sort) ? "numeric" === r ? M : R : null, this.sortable = !!this.t;
}
}
A.KEYS = [ ...d.KEYS, "formatTotal", "totals", "priorityGroupValues", "initialGroupingIndex", "getSortValue", "getGroupValue", "getFilterValue", "getGroupLabel" ];
const V = v("cursor: pointer", "user-select: none"), k = G(V, v("font-size: 1.2em", "font-weight: 100", "padding-right: 0.3em")), z = n((t => {
let {m: e, column: r, i: o} = t;
const {label: n, key: s} = r, [, i] = f((() => ({

@@ -219,53 +231,53 @@ type: "h",

/*#__PURE__*/
return v("div", {
return y("div", {
ref: i,
className: F,
onClick: () => t.setSorting(s),
children: [ 0 === o ? /*#__PURE__*/ G("span", {
onClick: () => t.toggleCompact(),
className: A,
children: t.compact ? "⊕" : "⊖"
}) : null, n, " ", t.sortDataKey === s ? 1 === t.sortDirection ? "↑" : "↓" : "" ]
className: V,
onClick: () => e.setSorting(s),
children: [ 0 === o ? /*#__PURE__*/ w("span", {
onClick: () => e.toggleCompact(),
className: k,
children: e.compact ? "⊕" : "⊖"
}) : null, n, " ", e.sortDataKey === s ? 1 === e.sortDirection ? "↑" : "↓" : "" ]
});
})), k = w("outline: none", "box-sizing: border-box", "width: 100%", "min-width: 0", "margin-top: 0.3em"), z = n((e => {
let {m: t, column: r} = e;
return t.compact ? null : /*#__PURE__*/ G("input", {
className: k,
value: t.filtersMap.get(r.key) || "",
onChange: e => t.setFiltering(r.key, e.target.value)
})), K = v("outline: none", "box-sizing: border-box", "width: 100%", "min-width: 0", "margin-top: 0.3em"), L = n((t => {
let {m: e, column: r} = t;
return e.compact ? null : /*#__PURE__*/ w("input", {
className: K,
value: e.filtersMap.get(r.key) || "",
onChange: t => e.setFiltering(r.key, t.target.value)
});
})), K = e => {
let t = 0;
if (Array.isArray(e)) t += e.length; else for (let r of e.values()) r && (t += K(r));
return t;
}, M = (e, t, r) => {
})), H = t => {
let e = 0;
if (Array.isArray(t)) e += t.length; else for (let r of t.values()) r && (e += H(r));
return e;
}, E = (t, e, r) => {
let o = 0;
if (Array.isArray(e)) {
if (Array.isArray(t)) {
let n;
for (const s of e) n = r(s), n && (o += n[t]);
} else for (const n of e.values()) n && (o += M(n, t, r));
for (const s of t) n = r(s), n && (o += n[e]);
} else for (const n of t.values()) n && (o += E(n, e, r));
return o;
}, q = n((e => {
let {m: t, column: r, rowIndexes: o} = e;
if ("count" === r.totals) return K(o);
}, W = n((t => {
let {m: e, column: r, rowIndexes: o} = t;
if ("count" === r.totals) return H(o);
if ("sum" === r.totals) {
const e = M(o, r.key, t.getRowData);
const t = E(o, r.key, e.getRowData);
if (r.formatTotal) {
const o = t.getTotalsFormattingHelper ? t.getTotalsFormattingHelper() : null;
return r.formatTotal(e, o);
const o = e.getTotalsFormattingHelper ? e.getTotalsFormattingHelper() : null;
return r.formatTotal(t, o);
}
return r.format ? r.format(e) : e;
return r.format ? r.format(t) : t;
}
return null;
})), H = w("user-select: none", "cursor: pointer", "padding-right: 0.3em"), L = w("margin-left: 1em"), E = n((t => {
let {m: r, columns: o, i: n} = t;
})), j = v("user-select: none", "cursor: pointer", "padding-right: 0.3em"), q = v("margin-left: 1em"), O = n((e => {
let {m: r, columns: o, i: n} = e;
const s = r.collapsedGroups.has(n);
if (r.hasGrouping) {
const t = r.flattenedGroups.groupValues[~n];
if (t) {
const i = t.length - 1, l = r.groupKeys[i], {getGroupLabel: u, label: a, format: c} = r.columns.find((e => e.key === l)), m = t[i], d = o.filter((e => !!e.totals));
const e = r.flattenedGroups.groupValues[~n];
if (e) {
const i = e.length - 1, l = r.groupKeys[i], {getGroupLabel: u, label: a, format: c} = r.columns.find((t => t.key === l)), m = e[i], h = o.filter((t => !!t.totals));
/*#__PURE__*/
return v(C, {
children: [ /*#__PURE__*/ G("span", {
className: H,
return y(C, {
children: [ /*#__PURE__*/ w("span", {
className: j,
onClick: () => r.toggleCollapsedGroup(n),

@@ -277,13 +289,13 @@ "data-collapsed": s ? "" : void 0,

children: s ? "▸" : "▾"
}), " ", u ? u(m) : /*#__PURE__*/ v(C, {
}), " ", u ? u(m) : /*#__PURE__*/ y(C, {
children: [ a, ": ", c ? c(m) : "" + m ]
}), d.length ? /*#__PURE__*/ G("span", {
className: L,
children: d.map(((o, n, s) => {
/*#__PURE__*/ return v(e, {
children: [ /*#__PURE__*/ v("span", {
children: [ o.label, ":  ", /*#__PURE__*/ G(q, {
}), h.length ? /*#__PURE__*/ w("span", {
className: q,
children: h.map(((o, n, s) => {
/*#__PURE__*/ return y(t, {
children: [ /*#__PURE__*/ y("span", {
children: [ o.label, ":  ", /*#__PURE__*/ w(W, {
m: r,
column: o,
rowIndexes: (i = r.grouped, l = t, l.reduce(((e, t) => e.get(t)), i))
rowIndexes: (i = r.grouped, l = e, l.reduce(((t, e) => t.get(e)), i))
}) ]

@@ -299,35 +311,35 @@ }), n !== s.length - 1 ? ", " : "" ]

return null;
})), V = w("display: flex", "margin: 0.3em 0", "flex: 0 0 auto"), W = n((e => {
let {aggregatorModel: t, GroupLabel: r} = e;
})), P = v("display: flex", "margin: 0.3em 0", "flex: 0 0 auto"), _ = n((t => {
let {aggregatorModel: e, GroupLabel: r} = t;
const [o, n] = x((() => ({
accept: "h",
drop(e) {
t.addGrouping(e.key);
drop(t) {
e.addGrouping(t.key);
}
})), [ t ]);
return t.compact ? null : /*#__PURE__*/ G("div", {
className: V,
})), [ e ]);
return e.compact ? null : /*#__PURE__*/ w("div", {
className: P,
ref: n,
children: t.groupKeys.length ? t.groupKeys.map((e => /*#__PURE__*/ G(r, {
groupKey: e,
columns: t.columns,
onRemove: () => t.removeGrouping(e)
}, e))) : "Drag column headers here to group by column"
children: e.groupKeys.length ? e.groupKeys.map((t => /*#__PURE__*/ w(r, {
groupKey: t,
columns: e.columns,
onRemove: () => e.removeGrouping(t)
}, t))) : "Drag column headers here to group by column"
});
})), j = w("user-select: none", "margin: 0 1em"), O = e => {
let {groupKey: t, columns: r, onRemove: o} = e;
})), B = v("user-select: none", "margin: 0 1em"), J = t => {
let {groupKey: e, columns: r, onRemove: o} = t;
/*#__PURE__*/
return G("div", {
className: j,
return w("div", {
className: B,
onDoubleClick: o,
children: r.find((e => e.key === t)).label
children: r.find((t => t.key === e)).label
});
}, P = w("display: flex", "flex-flow: column nowrap", "flex: 1 1 auto"), _ = /*#__PURE__*/ t((e => {
let {i: t, groupI: r, m: o, model: n, data: s} = e;
}, Q = v("display: flex", "flex-flow: column nowrap", "flex: 1 1 auto"), U = /*#__PURE__*/ e((t => {
let {i: e, groupI: r, m: o, model: n, data: s} = t;
/*#__PURE__*/
return G(s.components.Tr, {
ref: e => n.el(t, e),
children: /*#__PURE__*/ G(s.components.Td, {
return w(s.components.Tr, {
ref: t => n.el(e, t),
children: /*#__PURE__*/ w(s.components.Td, {
colSpan: s.columns.length,
children: /*#__PURE__*/ G(E, {
children: /*#__PURE__*/ w(O, {
m: o,

@@ -339,12 +351,12 @@ i: r,

});
}), h), B = /*#__PURE__*/ t((e => {
let {itemCount: t, getEstimatedItemSize: i, overscanCount: l, estimatedWidgetSize: u, getRowData: a, getKey: h, getTotalsFormattingHelper: f, columns: x, GroupLabel: w = O, className: b, components: I, footer: S, ...D} = e;
const N = m({
})), X = /*#__PURE__*/ e((t => {
let {itemCount: e, getEstimatedItemSize: i, overscanCount: l, estimatedWidgetSize: u, getRowData: a, getKey: d, getTotalsFormattingHelper: f, columns: x, GroupLabel: v = J, className: I, components: b, footer: S, ...D} = t;
const F = m({
getEstimatedItemSize: i,
estimatedWidgetSize: u,
overscanCount: l
}), F = d((() => {
const e = new R;
e.merge({
itemCount: t,
}), R = h((() => {
const t = new N;
t.merge({
itemCount: e,
getRowData: a,

@@ -354,8 +366,8 @@ getTotalsFormattingHelper: f,

});
const r = e.visibleColumns.filter((e => "number" == typeof e.initialGroupingIndex && e.initialGroupingIndex > 0)).sort(((e, t) => e.initialGroupingIndex - t.initialGroupingIndex)).map((e => e.key));
return e.setGrouping(r), N.setItemCount(e.finalIndexesCount, i), e;
const r = t.visibleColumns.filter((t => "number" == typeof t.initialGroupingIndex && t.initialGroupingIndex > 0)).sort(((t, e) => t.initialGroupingIndex - e.initialGroupingIndex)).map((t => t.key));
return t.setGrouping(r), F.setItemCount(t.finalIndexesCount, i), t;
}));
r((() => c((() => N.setItemCount(F.finalIndexesCount, i)))), [ i ]), r((() => {
F.merge({
itemCount: t,
r((() => c((() => F.setItemCount(R.finalIndexesCount, i)))), [ i ]), r((() => {
R.merge({
itemCount: e,
getRowData: a,

@@ -366,41 +378,42 @@ getTotalsFormattingHelper: f,

}));
const A = null == I ? void 0 : I.Row, k = o((() => {
const e = A || g.Row, t = n((e => {
let {i: t, model: r, data: o} = e;
const n = F.finalIndexes[t];
return n < 0 ? /*#__PURE__*/ G(_, {
i: t,
m: F,
const M = null == b ? void 0 : b.Row, T = o((() => {
const t = M || g.Row, e = n((t => {
let {i: e, model: r, data: o} = t;
const n = R.finalIndexes[e];
return n < 0 ? /*#__PURE__*/ w(U, {
i: e,
m: R,
groupI: n,
data: o,
model: r
}) : /*#__PURE__*/ G(o.components.PASSED_ROW, {
}) : /*#__PURE__*/ w(o.components.PASSED_ROW, {
i: n,
i2: e,
data: o,
model: r
});
})), r = n((e => {
let {column: t} = e;
})), r = n((t => {
let {column: e} = t;
/*#__PURE__*/
return G(q, {
m: F,
column: t,
rowIndexes: F.filteredIndexes
return w(W, {
m: R,
column: e,
rowIndexes: R.filteredIndexes
});
}));
return {
...I,
PASSED_ROW: e,
Row: t,
HeaderCell: e => {
let {column: t, i: r} = e;
...b,
PASSED_ROW: t,
Row: e,
HeaderCell: t => {
let {column: e, i: r} = t;
/*#__PURE__*/
return v(C, {
children: [ /*#__PURE__*/ G(T, {
m: F,
column: t,
return y(C, {
children: [ /*#__PURE__*/ w(z, {
m: R,
column: e,
i: r
}), /*#__PURE__*/ G(z, {
m: F,
column: t,
}), /*#__PURE__*/ w(L, {
m: R,
column: e,
i: r

@@ -412,17 +425,18 @@ }) ]

};
}), [ A ]);
}), [ M ]);
/*#__PURE__*/
return v("div", {
className: y(P, b),
children: [ /*#__PURE__*/ G(W, {
aggregatorModel: F,
GroupLabel: w
}), /*#__PURE__*/ G(s, {
children: () => /*#__PURE__*/ G(p, {
model: N,
columns: F.visibleColumns,
return y("div", {
className: G(Q, I),
children: [ /*#__PURE__*/ w(_, {
aggregatorModel: R,
GroupLabel: v
}), /*#__PURE__*/ w(s, {
children: () => /*#__PURE__*/ w(p, {
model: F,
ColumnModel: A,
columns: R.visibleColumns,
getRowData: a,
getKey: h,
components: k,
footer: F.hasTotals,
getKey: d,
components: T,
footer: R.hasTotals,
...D

@@ -434,3 +448,3 @@ })

export { B as Table };
export { X as Table };
//# sourceMappingURL=index.js.map
{
"name": "@af-utils/react-mobx-table",
"private": false,
"version": "0.0.19",
"version": "0.0.20",
"description": "React components for rendering tables",

@@ -55,4 +55,4 @@ "repository": "https://github.com/nowaalex/af-virtual-scroll.git",

"peerDependencies": {
"@af-utils/react-table": "^0.0.18",
"@af-utils/react-virtual-headless": "^0.0.14",
"@af-utils/react-table": "^0.0.19",
"@af-utils/react-virtual-headless": "^0.0.15",
"@af-utils/styled": "^0.0.9",

@@ -59,0 +59,0 @@ "mobx": "^6.3.0",

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