@af-utils/react-table
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -1,4 +0,4 @@ | ||
export const raw = 6760; | ||
export const min = 3431; | ||
export const minGz = 1490; | ||
export const minBrotli = 1340; | ||
export const raw = 6994; | ||
export const min = 3450; | ||
export const minGz = 1504; | ||
export const minBrotli = 1349; |
130
lib/index.js
@@ -5,14 +5,14 @@ import { memo as t, useMemo as e } from "react"; | ||
import { areItemPropsEqual as o, mapVisibleRange as s, Subscription as n, EVT_SCROLL_SIZE as r, EVT_FROM as i, EVT_TO as a } from "@af-utils/react-virtual-headless"; | ||
import { areItemPropsEqual as o, mapVisibleRange as r, Subscription as s, EVT_SCROLL_SIZE as n, EVT_FROM as i, EVT_TO as c } from "@af-utils/react-virtual-headless"; | ||
export * from "@af-utils/react-virtual-headless"; | ||
import { css as c, cx as h } from "@af-utils/styled"; | ||
import { css as a, cx as h } from "@af-utils/styled"; | ||
import { jsx as d, jsxs as m, Fragment as u } from "react/jsx-runtime"; | ||
import { jsx as d, jsxs as u, Fragment as m } from "react/jsx-runtime"; | ||
const p = { | ||
right: c("text-align: right !important;"), | ||
left: c("text-align: left !important;"), | ||
center: c("text-align: center !important;") | ||
right: a("text-align: right !important;"), | ||
left: a("text-align: left !important;"), | ||
center: a("text-align: center !important;") | ||
}; | ||
@@ -33,3 +33,3 @@ | ||
const b = /*#__PURE__*/ t((t => { | ||
const w = /*#__PURE__*/ t((t => { | ||
let {columns: e} = t; | ||
@@ -39,7 +39,7 @@ /*#__PURE__*/ | ||
children: e.map((t => { | ||
let {key: e, background: l, border: o, width: s} = t; | ||
let {key: e, background: l, border: o, width: r} = t; | ||
/*#__PURE__*/ | ||
return d("col", { | ||
style: { | ||
width: s, | ||
width: r, | ||
background: l, | ||
@@ -51,9 +51,14 @@ border: o | ||
}); | ||
})), g = t => { | ||
let {i: e, data: l} = t; | ||
const o = l.getRowData(e), s = l.components; | ||
})); | ||
if ("production" !== process.env.NODE_ENV) var b = !1; | ||
const g = t => { | ||
let {i: e, model: l, data: o} = t; | ||
const r = o.getRowData(e), s = o.components, n = o.getRowProps(l, e, r); | ||
if ("production" !== process.env.NODE_ENV && !1 === b && !n.ref) throw b = !0, new Error("ref should be present in getRowProps return value"); | ||
/*#__PURE__*/ | ||
return d(s.Tr, { | ||
...l.getRowProps && l.getRowProps(o, e), | ||
children: o ? l.columns.map((t => { | ||
...n, | ||
children: r ? o.columns.map((t => { | ||
const e = t.Cell || s.Cell; | ||
@@ -64,3 +69,3 @@ /*#__PURE__*/ | ||
children: /*#__PURE__*/ d(e, { | ||
row: o, | ||
row: r, | ||
column: t | ||
@@ -70,6 +75,6 @@ }) | ||
})) : /*#__PURE__*/ d(s.CellForEmptyRow, { | ||
data: l | ||
data: o | ||
}) | ||
}); | ||
}, w = { | ||
}, y = { | ||
/* Basic Elements */ | ||
@@ -87,4 +92,4 @@ Table: "table", | ||
let {row: e, column: l} = t; | ||
const {render: o, key: s, format: n} = l, r = e[s]; | ||
return void 0 === r ? " " : o ? o(r, e) : n ? n(r) : r; | ||
const {render: o, key: r, format: s} = l, n = e[r]; | ||
return void 0 === n ? " " : o ? o(n, e) : s ? s(n) : n; | ||
}, | ||
@@ -128,9 +133,11 @@ CellForEmptyRow: t => { | ||
OriginalRow: g | ||
}, y = [ r ], v = [ i, a ], x = c("overflow: auto", "position: relative", // https://github.com/nowaalex/af-virtual-scroll/issues/26 | ||
"will-change: scroll-position"), N = c("top: 0"), T = c("visibility: hidden"), C = c("position: sticky"), R = h(T, N, c("position: absolute", "left: 0", "width: 1px")), k = c("table-layout: fixed", "min-width: 100%"), D = h(C, N), F = h(C, c("bottom: 0")); | ||
}, v = [ n ], x = [ i, c ], N = a("overflow: auto", "position: relative", // https://github.com/nowaalex/af-virtual-scroll/issues/26 | ||
"will-change: scroll-position"), T = a("top: 0"), R = a("visibility: hidden"), C = a("position: sticky"), k = h(R, T, a("position: absolute", "left: 0", "width: 1px")), D = a("table-layout: fixed", "min-width: 100%"), F = h(C, T), I = h(C, a("bottom: 0")); | ||
/* Creating classes for hidden classes optimization */ | ||
class I { | ||
class P { | ||
constructor(t, e, l, o) { | ||
this.columns = t, this.components = e, this.getRowData = l, this.getRowProps = o; | ||
this.columns = t, this.components = e, this.getRowData = l, this.getRowProps = o || ((t, e) => ({ | ||
ref: l => t.el(e, l) | ||
})); | ||
} | ||
@@ -143,3 +150,3 @@ } | ||
return d("div", { | ||
className: R, | ||
className: k, | ||
style: { | ||
@@ -149,50 +156,49 @@ height: e | ||
}); | ||
}, H = t => { | ||
let {model: l, columns: o, getKey: r, getRowData: i, getRowProps: a, components: c, headless: p, footer: g, className: N, tabIndex: C = -1, ...R} = t; | ||
const H = e((() => Object.assign({}, w, c)), [ c ]), K = e((() => o.map((t => new f(t)))), [ o ]), O = e((() => { | ||
const t = new I(K, H, i, a); | ||
return e => /*#__PURE__*/ m(u, { | ||
}, E = t => { | ||
let {model: l, columns: o, getKey: n, getRowData: i, getRowProps: c, components: a, headless: p, footer: b, className: g, tabIndex: T = -1, ...C} = t; | ||
const k = e((() => Object.assign({}, y, a)), [ a ]), E = e((() => o.map((t => new f(t)))), [ o ]), H = e((() => { | ||
const t = new P(E, k, i, c); | ||
return e => /*#__PURE__*/ u(m, { | ||
children: [ /*#__PURE__*/ d("tr", { | ||
className: T, | ||
ref: e.setZeroChildNode, | ||
className: R, | ||
style: { | ||
height: e.getOffset(e.from) | ||
} | ||
}), s(e, H.Row, t, r) ] | ||
}), r(e, k.Row, t, n) ] | ||
}); | ||
}), [ H, K, i, a, r ]); | ||
}), [ k, E, i, c, n ]); | ||
/*#__PURE__*/ | ||
return m("div", { | ||
className: h(x, N), | ||
return u("div", { | ||
className: h(N, g), | ||
ref: l.setOuterNode, | ||
tabIndex: C, | ||
...R, | ||
children: [ /*#__PURE__*/ d(n, { | ||
tabIndex: T, | ||
...C, | ||
children: [ /*#__PURE__*/ d(s, { | ||
model: l, | ||
events: y, | ||
events: v, | ||
children: j | ||
}), /*#__PURE__*/ m(H.Table, { | ||
className: k, | ||
children: [ /*#__PURE__*/ d(b, { | ||
columns: K | ||
}), p ? null : /*#__PURE__*/ d(H.Thead, { | ||
className: D, | ||
children: /*#__PURE__*/ d(H.Tr, { | ||
children: /*#__PURE__*/ d(H.HeaderCells, { | ||
columns: K, | ||
components: H | ||
}), /*#__PURE__*/ u(k.Table, { | ||
className: D, | ||
children: [ /*#__PURE__*/ d(w, { | ||
columns: E | ||
}), p ? null : /*#__PURE__*/ d(k.Thead, { | ||
className: F, | ||
children: /*#__PURE__*/ d(k.Tr, { | ||
children: /*#__PURE__*/ d(k.HeaderCells, { | ||
columns: E, | ||
components: k | ||
}) | ||
}) | ||
}), /*#__PURE__*/ d(H.Tbody, { | ||
children: /*#__PURE__*/ d(n, { | ||
}), /*#__PURE__*/ d(k.Tbody, { | ||
children: /*#__PURE__*/ d(s, { | ||
model: l, | ||
events: v, | ||
children: O | ||
events: x, | ||
children: H | ||
}) | ||
}), g ? /*#__PURE__*/ d(H.Tfoot, { | ||
className: F, | ||
children: /*#__PURE__*/ d(H.Tr, { | ||
children: /*#__PURE__*/ d(H.FooterCells, { | ||
columns: K, | ||
components: H | ||
}), b ? /*#__PURE__*/ d(k.Tfoot, { | ||
className: I, | ||
children: /*#__PURE__*/ d(k.Tr, { | ||
children: /*#__PURE__*/ d(k.FooterCells, { | ||
columns: E, | ||
components: k | ||
}) | ||
@@ -205,3 +211,3 @@ }) | ||
"production" !== process.env.NODE_ENV && (H.propTypes = { | ||
"production" !== process.env.NODE_ENV && (E.propTypes = { | ||
model: l.object.isRequired, | ||
@@ -219,5 +225,5 @@ components: l.object, | ||
const K = /*#__PURE__*/ t(H); | ||
const H = /*#__PURE__*/ t(E); | ||
export { w as DefaultTableComponents, K as Table }; | ||
export { y as DefaultTableComponents, H as Table }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@af-utils/react-table", | ||
"private": false, | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "React components for rendering large scrollable data", | ||
@@ -60,3 +60,3 @@ "repository": "https://github.com/nowaalex/af-virtual-scroll.git", | ||
"lodash": "^4.17.21", | ||
"rollup": "^2.75.6", | ||
"rollup": "^2.75.7", | ||
"rollup-plugin-filesize": "^9.1.2", | ||
@@ -66,4 +66,4 @@ "rollup-plugin-terser": "^7.0.2" | ||
"peerDependencies": { | ||
"@af-utils/react-virtual-headless": "^0.0.9", | ||
"@af-utils/styled": "^0.0.5", | ||
"@af-utils/react-virtual-headless": "^0.0.10", | ||
"@af-utils/styled": "^0.0.6", | ||
"prop-types": "^15.8.0", | ||
@@ -70,0 +70,0 @@ "react": "^17.0.0 || ^18.1.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
24861
205
4