@vector-business-services/cristal-ds-web 0.17.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 CHANGED
@@ -136,6 +136,8 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
136
136
  label,
137
137
  hint,
138
138
  error,
139
+ dropdown = false,
140
+ dropdownAriaLabel = "Mostrar op\xE7\xF5es",
139
141
  inputId,
140
142
  required,
141
143
  disabled,
@@ -150,6 +152,7 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
150
152
  const classes = [
151
153
  "cr-field",
152
154
  "cr-autocomplete",
155
+ dropdown && "cr-autocomplete--dropdown",
153
156
  `cr-field--${variant}`,
154
157
  `cr-field--${size}`,
155
158
  error && "cr-field--error",
@@ -170,6 +173,9 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
170
173
  required,
171
174
  disabled,
172
175
  scrollHeight: "185px",
176
+ dropdown,
177
+ dropdownAriaLabel,
178
+ dropdownIcon: /* @__PURE__ */ jsxRuntime.jsx(react$1.CaretDown, { className: "cr-autocomplete__dropdown-icon", "aria-hidden": "true" }),
173
179
  pt: {
174
180
  root: { className: "cr-autocomplete__root" },
175
181
  input: {
@@ -179,6 +185,9 @@ var AutoComplete = react.forwardRef(function AutoComplete2({
179
185
  "aria-invalid": error ? true : void 0
180
186
  }
181
187
  },
188
+ // A seta: o botão de dropdown do Prime, por cima do fim do <input> (que segue sendo a caixa,
189
+ // para a lista continuar alinhada ao campo).
190
+ dropdownButton: { root: { className: "cr-autocomplete__dropdown" } },
182
191
  // O Prime mostra um spinner próprio enquanto busca; o Figma não define esse estado.
183
192
  loadingIcon: { className: "cr-autocomplete__loader" },
184
193
  panel: { className: "cr-lista cr-autocomplete__panel" },
@@ -2524,6 +2533,31 @@ var Tabs = react.forwardRef(function Tabs2({ activeIndex, onTabChange, children,
2524
2533
  function Column(_props) {
2525
2534
  return null;
2526
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
+ }
2527
2561
  var caixa = (label) => ({
2528
2562
  root: (options) => ({
2529
2563
  className: `cr-checkbox cr-checkbox__control${options?.props.checked ? " cr-checkbox__control--checked" : ""}`,
@@ -2620,12 +2654,16 @@ function TableBase({
2620
2654
  emptyMessage = "N\xE3o h\xE1 registros para mostrar.",
2621
2655
  loading,
2622
2656
  columnMenu = true,
2657
+ stickyHeader = false,
2658
+ stickyHeaderOffset = 0,
2623
2659
  ...props
2624
2660
  }, ref) {
2625
2661
  const elementos = react.Children.toArray(children).filter(react.isValidElement);
2626
2662
  const colunaDeSelecao = elementos.some((element) => element.props.selectionMode === "multiple");
2627
2663
  const template = paginatorTemplate(rowsPerPageLabel);
2628
2664
  const carregando = Boolean(loading);
2665
+ const raiz = react.useRef(null);
2666
+ useCabecalhoNaPagina(raiz, stickyHeader, stickyHeaderOffset);
2629
2667
  const paginaPropria = !props.onPage;
2630
2668
  const ordemPropria = !props.onSort;
2631
2669
  const [pagina, setPagina] = react.useState({
@@ -2733,7 +2771,7 @@ function TableBase({
2733
2771
  };
2734
2772
  return (
2735
2773
  // Contêiner da consulta de largura: a variante de 360px também muda a caixa do DataTable.
2736
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-table", children: [
2774
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: raiz, className: "cr-table", children: [
2737
2775
  /* @__PURE__ */ jsxRuntime.jsx(
2738
2776
  datatable.DataTable,
2739
2777
  {