@vector-business-services/cristal-ds-web 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2533,6 +2533,31 @@ var Tabs = react.forwardRef(function Tabs2({ activeIndex, onTabChange, children,
|
|
|
2533
2533
|
function Column(_props) {
|
|
2534
2534
|
return null;
|
|
2535
2535
|
}
|
|
2536
|
+
function useCabecalhoNaPagina(raiz, ligado, offset) {
|
|
2537
|
+
react.useEffect(() => {
|
|
2538
|
+
const wrapper = raiz.current?.querySelector(".cr-table__wrapper");
|
|
2539
|
+
if (!ligado || !wrapper) return;
|
|
2540
|
+
const posicionar = () => {
|
|
2541
|
+
const thead = wrapper.querySelector(".cr-table__thead");
|
|
2542
|
+
if (!thead) return;
|
|
2543
|
+
const limite = Math.max(0, wrapper.clientHeight - thead.offsetHeight);
|
|
2544
|
+
const desce = Math.min(limite, Math.max(0, offset - wrapper.getBoundingClientRect().top));
|
|
2545
|
+
thead.style.transform = desce ? `translateY(${desce}px)` : "";
|
|
2546
|
+
};
|
|
2547
|
+
posicionar();
|
|
2548
|
+
const observador = new ResizeObserver(posicionar);
|
|
2549
|
+
observador.observe(wrapper);
|
|
2550
|
+
document.addEventListener("scroll", posicionar, { capture: true, passive: true });
|
|
2551
|
+
window.addEventListener("resize", posicionar, { passive: true });
|
|
2552
|
+
return () => {
|
|
2553
|
+
observador.disconnect();
|
|
2554
|
+
document.removeEventListener("scroll", posicionar, { capture: true });
|
|
2555
|
+
window.removeEventListener("resize", posicionar);
|
|
2556
|
+
const thead = wrapper.querySelector(".cr-table__thead");
|
|
2557
|
+
if (thead) thead.style.transform = "";
|
|
2558
|
+
};
|
|
2559
|
+
}, [raiz, ligado, offset]);
|
|
2560
|
+
}
|
|
2536
2561
|
var caixa = (label) => ({
|
|
2537
2562
|
root: (options) => ({
|
|
2538
2563
|
className: `cr-checkbox cr-checkbox__control${options?.props.checked ? " cr-checkbox__control--checked" : ""}`,
|
|
@@ -2629,12 +2654,16 @@ function TableBase({
|
|
|
2629
2654
|
emptyMessage = "N\xE3o h\xE1 registros para mostrar.",
|
|
2630
2655
|
loading,
|
|
2631
2656
|
columnMenu = true,
|
|
2657
|
+
stickyHeader = false,
|
|
2658
|
+
stickyHeaderOffset = 0,
|
|
2632
2659
|
...props
|
|
2633
2660
|
}, ref) {
|
|
2634
2661
|
const elementos = react.Children.toArray(children).filter(react.isValidElement);
|
|
2635
2662
|
const colunaDeSelecao = elementos.some((element) => element.props.selectionMode === "multiple");
|
|
2636
2663
|
const template = paginatorTemplate(rowsPerPageLabel);
|
|
2637
2664
|
const carregando = Boolean(loading);
|
|
2665
|
+
const raiz = react.useRef(null);
|
|
2666
|
+
useCabecalhoNaPagina(raiz, stickyHeader, stickyHeaderOffset);
|
|
2638
2667
|
const paginaPropria = !props.onPage;
|
|
2639
2668
|
const ordemPropria = !props.onSort;
|
|
2640
2669
|
const [pagina, setPagina] = react.useState({
|
|
@@ -2742,7 +2771,7 @@ function TableBase({
|
|
|
2742
2771
|
};
|
|
2743
2772
|
return (
|
|
2744
2773
|
// Contêiner da consulta de largura: a variante de 360px também muda a caixa do DataTable.
|
|
2745
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-table", children: [
|
|
2774
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: raiz, className: "cr-table", children: [
|
|
2746
2775
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2747
2776
|
datatable.DataTable,
|
|
2748
2777
|
{
|