@af-utils/react-mobx-table
Advanced tools
Comparing version 0.0.57 to 0.0.58
@@ -1,4 +0,4 @@ | ||
export const raw = 15820; | ||
export const min = 9283; | ||
export const minGz = 3464; | ||
export const minBrotli = 3161; | ||
export const raw = 15832; | ||
export const min = 9292; | ||
export const minGz = 3465; | ||
export const minBrotli = 3168; |
102
lib/index.js
@@ -46,5 +46,5 @@ import { Fragment as e, memo as t, useLayoutEffect as o, useMemo as r, useRef as n } from "react"; | ||
}; | ||
}, F = () => !1; | ||
}; | ||
class R extends class { | ||
class F { | ||
constructor() { | ||
@@ -80,3 +80,7 @@ this.itemCount = 0, this.getRowData = null, this.getTotalsFormattingHelper = null, | ||
} | ||
} { | ||
} | ||
const R = () => !1; | ||
class M extends F { | ||
get visibleColumns() { | ||
@@ -175,9 +179,9 @@ return this.columns.filter((e => !this.groupKeys.includes(e.key))); | ||
finalIndexes: u({ | ||
equals: F | ||
equals: R | ||
}), | ||
noGroupsSortedIndexes: u({ | ||
equals: F | ||
equals: R | ||
}), | ||
groupedSorted: u({ | ||
equals: F | ||
equals: R | ||
}), | ||
@@ -206,17 +210,17 @@ itemCount: !0, | ||
const M = new Intl.Collator(void 0, { | ||
const T = new Intl.Collator(void 0, { | ||
numeric: !0 | ||
}).compare, T = (e, t) => (e || 0) - (t || 0), z = e => e; | ||
}).compare, z = (e, t) => (e || 0) - (t || 0), A = e => e; | ||
class A extends h { | ||
class V extends h { | ||
constructor(e, t) { | ||
var o; | ||
super(e, t), this.getSortValue ||= z, this.getFilterValue ||= z, this.getGroupValue ||= z, | ||
this.t = (o = e.sort) ? "numeric" === o ? T : M : null, this.sortable = !!this.t; | ||
super(e, t), this.getSortValue ||= A, this.getFilterValue ||= A, this.getGroupValue ||= A, | ||
this.t = (o = e.sort) ? "numeric" === o ? z : T : null, this.sortable = !!this.t; | ||
} | ||
} | ||
A.KEYS = [ ...h.KEYS, "formatTotal", "totals", "priorityGroupValues", "initialGroupingIndex", "getSortValue", "getGroupValue", "getFilterValue", "getGroupLabel" ]; | ||
V.KEYS = [ ...h.KEYS, "formatTotal", "totals", "priorityGroupValues", "initialGroupingIndex", "getSortValue", "getGroupValue", "getFilterValue", "getGroupLabel" ]; | ||
const V = x("cursor: pointer", "user-select: none"), k = G(V, x("font-size: 1.2em", "font-weight: 100", "padding-right: 0.3em")), K = s((e => { | ||
const k = x("cursor: pointer", "user-select: none"), K = G(k, x("font-size: 1.2em", "font-weight: 100", "padding-right: 0.3em")), L = s((e => { | ||
let {m: t, column: o, i: r} = e; | ||
@@ -232,22 +236,22 @@ const {label: n, key: s} = o, [, i] = f((() => ({ | ||
ref: i, | ||
className: V, | ||
className: k, | ||
onClick: () => t.setSorting(s), | ||
children: [ 0 === r ? /*#__PURE__*/ C("span", { | ||
onClick: () => t.toggleCompact(), | ||
className: k, | ||
className: K, | ||
children: t.compact ? "⊕" : "⊖" | ||
}) : null, n, " ", t.sortDataKey === s ? 1 === t.sortDirection ? "↑" : "↓" : "" ] | ||
}); | ||
})), L = x("outline: none", "box-sizing: border-box", "width: 100%", "min-width: 0", "margin-top: 0.3em"), q = s((e => { | ||
})), q = x("outline: none", "box-sizing: border-box", "width: 100%", "min-width: 0", "margin-top: 0.3em"), H = s((e => { | ||
let {m: t, column: o} = e; | ||
return t.compact ? null : /*#__PURE__*/ C("input", { | ||
className: L, | ||
className: q, | ||
value: t.filtersMap.get(o.key) || "", | ||
onChange: e => t.setFiltering(o.key, e.target.value) | ||
}); | ||
})), H = e => { | ||
})), W = e => { | ||
let t = 0; | ||
if (Array.isArray(e)) t += e.length; else for (let o of e.values()) o && (t += H(o)); | ||
if (Array.isArray(e)) t += e.length; else for (let o of e.values()) o && (t += W(o)); | ||
return t; | ||
}, W = (e, t, o) => { | ||
}, j = (e, t, o) => { | ||
let r = 0; | ||
@@ -257,9 +261,9 @@ if (Array.isArray(e)) { | ||
for (const s of e) n = o(s), n && (r += n[t]); | ||
} else for (const n of e.values()) n && (r += W(n, t, o)); | ||
} else for (const n of e.values()) n && (r += j(n, t, o)); | ||
return r; | ||
}, j = s((e => { | ||
}, E = s((e => { | ||
let {m: t, column: o, rowIndexes: r} = e; | ||
if ("count" === o.totals) return H(r); | ||
if ("count" === o.totals) return W(r); | ||
if ("sum" === o.totals) { | ||
const e = W(r, o.key, t.getRowData); | ||
const e = j(r, o.key, t.getRowData); | ||
if (o.formatTotal) { | ||
@@ -272,3 +276,3 @@ const r = t.getTotalsFormattingHelper ? t.getTotalsFormattingHelper() : null; | ||
return null; | ||
})), E = x("user-select: none", "cursor: pointer", "padding-right: 0.3em"), O = x("margin-left: 1em"), P = s((t => { | ||
})), O = x("user-select: none", "cursor: pointer", "padding-right: 0.3em"), P = x("margin-left: 1em"), _ = s((t => { | ||
let {m: o, columns: r, i: n} = t; | ||
@@ -283,3 +287,3 @@ const s = o.collapsedGroups.has(n); | ||
children: [ /*#__PURE__*/ C("span", { | ||
className: E, | ||
className: O, | ||
onClick: () => o.toggleCollapsedGroup(n), | ||
@@ -294,7 +298,7 @@ "data-collapsed": s ? "" : void 0, | ||
}), d.length ? /*#__PURE__*/ C("span", { | ||
className: O, | ||
className: P, | ||
children: d.map(((r, n, s) => { | ||
/*#__PURE__*/ return y(e, { | ||
children: [ /*#__PURE__*/ y("span", { | ||
children: [ r.label, ": ", /*#__PURE__*/ C(j, { | ||
children: [ r.label, ": ", /*#__PURE__*/ C(E, { | ||
m: o, | ||
@@ -313,3 +317,3 @@ column: r, | ||
return null; | ||
})), _ = x("display: flex", "margin: 0.3em 0", "flex: 0 0 auto"), B = s((e => { | ||
})), B = x("display: flex", "margin: 0.3em 0", "flex: 0 0 auto"), J = s((e => { | ||
let {aggregatorModel: t, GroupLabel: o} = e; | ||
@@ -323,3 +327,3 @@ const [r, n] = v((() => ({ | ||
return t.compact ? null : /*#__PURE__*/ C("div", { | ||
className: _, | ||
className: B, | ||
ref: n, | ||
@@ -332,11 +336,11 @@ children: t.groupKeys.length ? t.groupKeys.map((e => /*#__PURE__*/ C(o, { | ||
}); | ||
})), J = x("user-select: none", "margin: 0 1em"), Q = e => { | ||
})), Q = x("user-select: none", "margin: 0 1em"), U = e => { | ||
let {groupKey: t, columns: o, onRemove: r} = e; | ||
/*#__PURE__*/ | ||
return C("div", { | ||
className: J, | ||
className: Q, | ||
onDoubleClick: r, | ||
children: o.find((e => e.key === t)).label | ||
}); | ||
}, U = x("flex: 1 1 auto"), X = G(x("display: flex", "flex-flow: column nowrap", U)), Y = /*#__PURE__*/ t((e => { | ||
}, X = x("flex: 1 1 auto"), Y = G(x("display: flex", "flex-flow: column nowrap", X)), Z = /*#__PURE__*/ t((e => { | ||
let {i: t, groupI: o, m: r, model: n, data: s} = e; | ||
@@ -348,3 +352,3 @@ /*#__PURE__*/ | ||
colSpan: s.columns.length, | ||
children: /*#__PURE__*/ C(P, { | ||
children: /*#__PURE__*/ C(_, { | ||
m: r, | ||
@@ -356,4 +360,4 @@ i: o, | ||
}); | ||
})), Z = /*#__PURE__*/ t((e => { | ||
let {itemCount: t, estimatedItemSize: l, overscanCount: u, estimatedWidgetSize: a, getRowData: c, getKey: h, getTotalsFormattingHelper: f, columns: v, GroupLabel: x = Q, className: I, components: b, footer: S, ...D} = e; | ||
})), $ = /*#__PURE__*/ t((e => { | ||
let {itemCount: t, estimatedItemSize: l, overscanCount: u, estimatedWidgetSize: a, getRowData: c, getKey: h, getTotalsFormattingHelper: f, columns: v, GroupLabel: x = U, className: I, components: b, footer: S, ...D} = e; | ||
const N = d({ | ||
@@ -363,4 +367,4 @@ estimatedItemSize: l, | ||
overscanCount: u | ||
}), F = (M = () => { | ||
const e = new R; | ||
}), F = (R = () => { | ||
const e = new M; | ||
e.merge({ | ||
@@ -376,4 +380,4 @@ itemCount: t, | ||
}), e; | ||
}, n().current ||= M()); | ||
var M; | ||
}, n().current ||= R()); | ||
var R; | ||
o((() => m((() => N.set({ | ||
@@ -394,3 +398,3 @@ itemCount: F.finalIndexesCount, | ||
const n = F.finalIndexes[t]; | ||
return n < 0 ? /*#__PURE__*/ C(Y, { | ||
return n < 0 ? /*#__PURE__*/ C(Z, { | ||
i: t, | ||
@@ -410,3 +414,3 @@ m: F, | ||
/*#__PURE__*/ | ||
return C(j, { | ||
return C(E, { | ||
m: F, | ||
@@ -425,7 +429,7 @@ column: t, | ||
return y(w, { | ||
children: [ /*#__PURE__*/ C(K, { | ||
children: [ /*#__PURE__*/ C(L, { | ||
m: F, | ||
column: t, | ||
i: o | ||
}), /*#__PURE__*/ C(q, { | ||
}), /*#__PURE__*/ C(H, { | ||
m: F, | ||
@@ -442,4 +446,4 @@ column: t, | ||
return y("div", { | ||
className: G(X, I), | ||
children: [ /*#__PURE__*/ C(B, { | ||
className: G(Y, I), | ||
children: [ /*#__PURE__*/ C(J, { | ||
aggregatorModel: F, | ||
@@ -449,5 +453,5 @@ GroupLabel: x | ||
children: () => /*#__PURE__*/ C(p, { | ||
className: U, | ||
className: X, | ||
model: N, | ||
ColumnModel: A, | ||
ColumnModel: V, | ||
columns: F.visibleColumns, | ||
@@ -464,3 +468,3 @@ getRowData: c, | ||
export { Z as Table }; | ||
export { $ as Table }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@af-utils/react-mobx-table", | ||
"private": false, | ||
"version": "0.0.57", | ||
"version": "0.0.58", | ||
"description": "React components for rendering tables", | ||
@@ -49,12 +49,12 @@ "repository": "https://github.com/nowaalex/af-virtual-scroll.git", | ||
"@rollup/plugin-export-bundle-size": "^0.0.1", | ||
"babel-jest": "^29.2.1", | ||
"@rollup/plugin-terser": "^0.1.0", | ||
"babel-jest": "^29.2.2", | ||
"babel-plugin-module-resolver": "^4.1.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24", | ||
"rollup": "^3.2.3", | ||
"rollup-plugin-terser": "^7.0.2" | ||
"rollup": "^3.2.5" | ||
}, | ||
"peerDependencies": { | ||
"@af-utils/react-table": "^0.0.54", | ||
"@af-utils/react-virtual-headless": "^0.0.48", | ||
"@af-utils/styled": "^0.0.19", | ||
"@af-utils/react-table": "^0.0.55", | ||
"@af-utils/react-virtual-headless": "^0.0.49", | ||
"@af-utils/styled": "^0.0.20", | ||
"mobx": "^6.3.0", | ||
@@ -61,0 +61,0 @@ "mobx-react-lite": "^3.2.0", |
Sorry, the diff of this file is not supported yet
57593
435