@af-utils/react-mobx-table
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,4 +0,4 @@ | ||
export const raw = 15827; | ||
export const min = 9237; | ||
export const minGz = 3474; | ||
export const minBrotli = 3171; | ||
export const raw = 15713; | ||
export const min = 9167; | ||
export const minGz = 3450; | ||
export const minBrotli = 3148; |
130
lib/index.js
@@ -5,3 +5,3 @@ import { Fragment as e, memo as t, useLayoutEffect as o, useMemo as r, useRef as n } from "react"; | ||
import { makeObservable as l, computed as u, comparer as a, action as c, autorun as m } from "mobx"; | ||
import { makeObservable as l, computed as a, comparer as u, action as c, autorun as m } from "mobx"; | ||
@@ -12,7 +12,7 @@ import { useVirtualModel as d } from "@af-utils/react-virtual-headless"; | ||
import { useDrag as f, useDrop as v } from "react-dnd"; | ||
import { useDrag as f, useDrop as x } from "react-dnd"; | ||
import { css as x, cx as y } from "@af-utils/styled"; | ||
import { css as y, cx as G } from "@af-utils/styled"; | ||
import { jsxs as G, jsx as C, Fragment as w } from "react/jsx-runtime"; | ||
import { jsxs as C, jsx as w, Fragment as v } from "react/jsx-runtime"; | ||
@@ -35,3 +35,3 @@ const I = new Intl.Collator(void 0, { | ||
const e = S(t, o, r, i); | ||
for (const t of l) null == t || t.sort(e); | ||
for (const t of l) t?.sort(e); | ||
} | ||
@@ -111,16 +111,16 @@ }, F = function(e, t, o, r, n) { | ||
if (!e) continue; | ||
let u, a, c = i; | ||
let a, u, c = i; | ||
/* | ||
We could put everything in one loop, but last iteration is different. | ||
*/ for (let o = 0; o < n; o++) { | ||
if (a = e[t[o]], u = c.get(a), !u) { | ||
u = new Map; | ||
if (u = e[t[o]], a = c.get(u), !a) { | ||
a = new Map; | ||
for (let e of r[o]) c.has(e) || c.set(e, null); | ||
c.set(a, u); | ||
c.set(u, a); | ||
} | ||
c = u; | ||
c = a; | ||
} | ||
if (a = e[s], u = c.get(a), u) u.push(l); else { | ||
if (u = e[s], a = c.get(u), a) a.push(l); else { | ||
for (let e of r[n]) c.has(e) || c.set(e, null); | ||
c.set(a, [ l ]); | ||
c.set(u, [ l ]); | ||
} | ||
@@ -132,4 +132,3 @@ } | ||
get groupedSorted() { | ||
var e; | ||
return this.sortDataKey && D(this.grouped, this.getRowData, this.sortDataKey, this.sortDirection, this.groupKeys.length, 0, null == (e = this.columns.find((e => e.key === this.sortDataKey))) ? void 0 : e.sorter), | ||
return this.sortDataKey && D(this.grouped, this.getRowData, this.sortDataKey, this.sortDirection, this.groupKeys.length, 0, this.columns.find((e => e.key === this.sortDataKey))?.sorter), | ||
this.grouped; | ||
@@ -156,4 +155,3 @@ } | ||
get noGroupsSortedIndexes() { | ||
var e; | ||
return this.sortDataKey ? this.filteredIndexes.sort(S(this.getRowData, this.sortDataKey, this.sortDirection, null == (e = this.columns.find((e => e.key === this.sortDataKey))) ? void 0 : e.sorter)) : this.filteredIndexes; | ||
return this.sortDataKey ? this.filteredIndexes.sort(S(this.getRowData, this.sortDataKey, this.sortDirection, this.columns.find((e => e.key === this.sortDataKey))?.sorter)) : this.filteredIndexes; | ||
} | ||
@@ -183,15 +181,15 @@ get groupsSortedIndexes() { | ||
hasTotals: !0, | ||
visibleColumns: u({ | ||
equals: a.structural | ||
visibleColumns: a({ | ||
equals: u.structural | ||
}), | ||
priorityGroupValuesArray: u({ | ||
equals: a.structural | ||
priorityGroupValuesArray: a({ | ||
equals: u.structural | ||
}), | ||
finalIndexes: u({ | ||
finalIndexes: a({ | ||
equals: R | ||
}), | ||
noGroupsSortedIndexes: u({ | ||
noGroupsSortedIndexes: a({ | ||
equals: R | ||
}), | ||
groupedSorted: u({ | ||
groupedSorted: a({ | ||
equals: R | ||
@@ -234,3 +232,3 @@ }), | ||
const V = x("cursor: pointer", "user-select: none"), k = y(V, x("font-size: 1.2em", "font-weight: 100", "padding-right: 0.3em")), H = s((e => { | ||
const V = y("cursor: pointer", "user-select: none"), k = G(V, y("font-size: 1.2em", "font-weight: 100", "padding-right: 0.3em")), H = s((e => { | ||
let {m: t, column: o, i: r} = e; | ||
@@ -244,7 +242,7 @@ const {label: n, key: s} = o, [, i] = f((() => ({ | ||
/*#__PURE__*/ | ||
return G("div", { | ||
return C("div", { | ||
ref: i, | ||
className: V, | ||
onClick: () => t.setSorting(s), | ||
children: [ 0 === r ? /*#__PURE__*/ C("span", { | ||
children: [ 0 === r ? /*#__PURE__*/ w("span", { | ||
onClick: () => t.toggleCompact(), | ||
@@ -255,5 +253,5 @@ className: k, | ||
}); | ||
})), L = x("outline: none", "box-sizing: border-box", "width: 100%", "min-width: 0", "margin-top: 0.3em"), q = s((e => { | ||
})), L = y("outline: none", "box-sizing: border-box", "width: 100%", "min-width: 0", "margin-top: 0.3em"), q = s((e => { | ||
let {m: t, column: o} = e; | ||
return t.compact ? null : /*#__PURE__*/ C("input", { | ||
return t.compact ? null : /*#__PURE__*/ w("input", { | ||
className: L, | ||
@@ -286,3 +284,3 @@ value: t.filtersMap.get(o.key) || "", | ||
return null; | ||
})), O = x("user-select: none", "cursor: pointer", "padding-right: 0.3em"), P = x("margin-left: 1em"), Y = s((t => { | ||
})), O = y("user-select: none", "cursor: pointer", "padding-right: 0.3em"), P = y("margin-left: 1em"), Y = s((t => { | ||
let {m: o, columns: r, i: n} = t; | ||
@@ -293,6 +291,6 @@ const s = o.collapsedGroups.has(n); | ||
if (t) { | ||
const i = t.length - 1, l = o.groupKeys[i], {getGroupLabel: u, label: a, format: c} = o.columns.find((e => e.key === l)), m = t[i], d = r.filter((e => !!e.totals)); | ||
const i = t.length - 1, l = o.groupKeys[i], {getGroupLabel: a, label: u, format: c} = o.columns.find((e => e.key === l)), m = t[i], d = r.filter((e => !!e.totals)); | ||
/*#__PURE__*/ | ||
return G(w, { | ||
children: [ /*#__PURE__*/ C("span", { | ||
return C(v, { | ||
children: [ /*#__PURE__*/ w("span", { | ||
className: O, | ||
@@ -305,10 +303,10 @@ onClick: () => o.toggleCollapsedGroup(n), | ||
children: s ? "▸" : "▾" | ||
}), " ", u ? u(m) : /*#__PURE__*/ G(w, { | ||
children: [ a, ": ", c ? c(m) : "" + m ] | ||
}), d.length ? /*#__PURE__*/ C("span", { | ||
}), " ", a ? a(m) : /*#__PURE__*/ C(v, { | ||
children: [ u, ": ", c ? c(m) : "" + m ] | ||
}), d.length ? /*#__PURE__*/ w("span", { | ||
className: P, | ||
children: d.map(((r, n, s) => { | ||
/*#__PURE__*/ return G(e, { | ||
children: [ /*#__PURE__*/ G("span", { | ||
children: [ r.label, ": ", /*#__PURE__*/ C(j, { | ||
/*#__PURE__*/ return C(e, { | ||
children: [ /*#__PURE__*/ C("span", { | ||
children: [ r.label, ": ", /*#__PURE__*/ w(j, { | ||
m: o, | ||
@@ -327,5 +325,5 @@ column: r, | ||
return null; | ||
})), _ = x("display: flex", "margin: 0.3em 0", "flex: 0 0 auto"), B = s((e => { | ||
})), _ = y("display: flex", "margin: 0.3em 0", "flex: 0 0 auto"), B = s((e => { | ||
let {aggregatorModel: t, GroupLabel: o} = e; | ||
const [r, n] = v((() => ({ | ||
const [r, n] = x((() => ({ | ||
accept: "h", | ||
@@ -336,6 +334,6 @@ drop(e) { | ||
})), [ t ]); | ||
return t.compact ? null : /*#__PURE__*/ C("div", { | ||
return t.compact ? null : /*#__PURE__*/ w("div", { | ||
className: _, | ||
ref: n, | ||
children: t.groupKeys.length ? t.groupKeys.map((e => /*#__PURE__*/ C(o, { | ||
children: t.groupKeys.length ? t.groupKeys.map((e => /*#__PURE__*/ w(o, { | ||
groupKey: e, | ||
@@ -346,6 +344,6 @@ columns: t.columns, | ||
}); | ||
})), J = x("user-select: none", "margin: 0 1em"), Q = e => { | ||
})), J = y("user-select: none", "margin: 0 1em"), Q = e => { | ||
let {groupKey: t, columns: o, onRemove: r} = e; | ||
/*#__PURE__*/ | ||
return C("div", { | ||
return w("div", { | ||
className: J, | ||
@@ -355,10 +353,10 @@ onDoubleClick: r, | ||
}); | ||
}, U = x("flex: 1 1 auto"), X = y(x("display: flex", "flex-flow: column nowrap", U)), Z = /*#__PURE__*/ t((e => { | ||
}, U = y("flex: 1 1 auto"), X = G(y("display: flex", "flex-flow: column nowrap", U)), Z = /*#__PURE__*/ t((e => { | ||
let {i: t, groupI: o, m: r, model: n, data: s} = e; | ||
/*#__PURE__*/ | ||
return C(s.components.Tr, { | ||
return w(s.components.Tr, { | ||
ref: e => n.el(t, e), | ||
children: /*#__PURE__*/ C(s.components.Td, { | ||
children: /*#__PURE__*/ w(s.components.Td, { | ||
colSpan: s.columns.length, | ||
children: /*#__PURE__*/ C(Y, { | ||
children: /*#__PURE__*/ w(Y, { | ||
m: r, | ||
@@ -371,7 +369,7 @@ i: o, | ||
})), $ = /*#__PURE__*/ t((e => { | ||
let {itemCount: t, estimatedItemSize: l, overscanCount: u, estimatedWidgetSize: a, getRowData: c, getKey: p, getTotalsFormattingHelper: f, columns: v, GroupLabel: x = Q, className: I, components: b, footer: S, ...D} = e; | ||
let {itemCount: t, estimatedItemSize: l, overscanCount: a, estimatedWidgetSize: u, getRowData: c, getKey: p, getTotalsFormattingHelper: f, columns: x, GroupLabel: y = Q, className: I, components: b, footer: S, ...D} = e; | ||
const F = d({ | ||
estimatedItemSize: l, | ||
estimatedWidgetSize: a, | ||
overscanCount: u | ||
estimatedWidgetSize: u, | ||
overscanCount: a | ||
}), N = (R = () => { | ||
@@ -383,3 +381,3 @@ const e = new K; | ||
getTotalsFormattingHelper: f, | ||
columns: v | ||
columns: x | ||
}); | ||
@@ -400,10 +398,10 @@ const o = e.visibleColumns.filter((e => "number" == typeof e.initialGroupingIndex && e.initialGroupingIndex > 0)).sort(((e, t) => e.initialGroupingIndex - t.initialGroupingIndex)).map((e => e.key)); | ||
getTotalsFormattingHelper: f, | ||
columns: v | ||
columns: x | ||
}); | ||
})); | ||
const M = null == b ? void 0 : b.Row, T = r((() => { | ||
const M = b?.Row, T = r((() => { | ||
const e = M || g.Row, t = s((e => { | ||
let {i: t, model: o, data: r} = e; | ||
const n = N.finalIndexes[t]; | ||
return n < 0 ? /*#__PURE__*/ C(Z, { | ||
return n < 0 ? /*#__PURE__*/ w(Z, { | ||
i: t, | ||
@@ -414,3 +412,3 @@ m: N, | ||
model: o | ||
}) : /*#__PURE__*/ C(r.components.PASSED_ROW, { | ||
}) : /*#__PURE__*/ w(r.components.PASSED_ROW, { | ||
i: n, | ||
@@ -424,3 +422,3 @@ i2: t, | ||
/*#__PURE__*/ | ||
return C(j, { | ||
return w(j, { | ||
m: N, | ||
@@ -438,8 +436,8 @@ column: t, | ||
/*#__PURE__*/ | ||
return G(w, { | ||
children: [ /*#__PURE__*/ C(H, { | ||
return C(v, { | ||
children: [ /*#__PURE__*/ w(H, { | ||
m: N, | ||
column: t, | ||
i: o | ||
}), /*#__PURE__*/ C(q, { | ||
}), /*#__PURE__*/ w(q, { | ||
m: N, | ||
@@ -455,9 +453,9 @@ column: t, | ||
/*#__PURE__*/ | ||
return G("div", { | ||
className: y(X, I), | ||
children: [ /*#__PURE__*/ C(B, { | ||
return C("div", { | ||
className: G(X, I), | ||
children: [ /*#__PURE__*/ w(B, { | ||
aggregatorModel: N, | ||
GroupLabel: x | ||
}), /*#__PURE__*/ C(i, { | ||
children: () => /*#__PURE__*/ C(h, { | ||
GroupLabel: y | ||
}), /*#__PURE__*/ w(i, { | ||
children: () => /*#__PURE__*/ w(h, { | ||
className: U, | ||
@@ -464,0 +462,0 @@ model: F, |
{ | ||
"name": "@af-utils/react-mobx-table", | ||
"private": false, | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "React components for rendering tables", | ||
@@ -42,19 +42,19 @@ "repository": "https://github.com/nowaalex/af-virtual-scroll.git", | ||
"devDependencies": { | ||
"@babel/core": "^7.21.0", | ||
"@babel/plugin-transform-runtime": "^7.21.0", | ||
"@babel/preset-env": "^7.20.2", | ||
"@babel/core": "^7.21.5", | ||
"@babel/plugin-transform-runtime": "^7.21.4", | ||
"@babel/preset-env": "^7.21.5", | ||
"@babel/preset-react": "^7.18.6", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-commonjs": "^24.0.1", | ||
"@rollup/plugin-export-bundle-size": "^0.0.1", | ||
"@rollup/plugin-terser": "^0.4.0", | ||
"babel-jest": "^29.4.3", | ||
"@rollup/plugin-commonjs": "^24.1.0", | ||
"@rollup/plugin-export-bundle-size": "^0.0.2", | ||
"@rollup/plugin-terser": "^0.4.1", | ||
"babel-jest": "^29.5.0", | ||
"babel-plugin-module-resolver": "^5.0.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24", | ||
"rollup": "^3.18.0" | ||
"rollup": "^3.21.0" | ||
}, | ||
"peerDependencies": { | ||
"@af-utils/react-table": "^1.0.2", | ||
"@af-utils/react-virtual-headless": "^0.1.6", | ||
"@af-utils/styled": "^0.0.22", | ||
"@af-utils/react-table": "^1.0.3", | ||
"@af-utils/react-virtual-headless": "^0.1.11", | ||
"@af-utils/styled": "^0.0.23", | ||
"mobx": "^6.3.0", | ||
@@ -61,0 +61,0 @@ "mobx-react-lite": "^3.2.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57330
440