@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.d.cts CHANGED
@@ -64,7 +64,7 @@ declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttri
64
64
 
65
65
  type AutoCompleteVariant = InputVariant;
66
66
  type AutoCompleteSize = InputSize;
67
- interface AutoCompleteProps extends Omit<AutoCompleteProps$1, 'size' | 'variant' | 'invalid' | 'multiple' | 'selectionLimit' | 'selectedItemTemplate' | 'removeTokenIcon' | 'dropdown' | 'dropdownAriaLabel' | 'dropdownAutoFocus' | 'dropdownIcon' | 'dropdownMode' | 'showEmptyMessage' | 'emptyMessage' | 'loadingIcon' | 'inputClassName' | 'panelClassName' | 'scrollHeight' | 'inputRef' | 'pt' | 'ptOptions' | 'unstyled' | 'children'> {
67
+ interface AutoCompleteProps extends Omit<AutoCompleteProps$1, 'size' | 'variant' | 'invalid' | 'multiple' | 'selectionLimit' | 'selectedItemTemplate' | 'removeTokenIcon' | 'dropdownIcon' | 'showEmptyMessage' | 'emptyMessage' | 'loadingIcon' | 'inputClassName' | 'panelClassName' | 'scrollHeight' | 'inputRef' | 'pt' | 'ptOptions' | 'unstyled' | 'children'> {
68
68
  /** Type no Figma: Outline (com borda) e Filled (com fundo). */
69
69
  variant?: AutoCompleteVariant;
70
70
  /** Size no Figma: 32, 36, 42 e 48px de altura do campo. */
@@ -75,6 +75,14 @@ interface AutoCompleteProps extends Omit<AutoCompleteProps$1, 'size' | 'variant'
75
75
  hint?: string;
76
76
  /** Mensagem de erro: deixa o campo no estado Error e mostra a dica de erro no lugar da dica. */
77
77
  error?: string;
78
+ /**
79
+ * Seta à direita do campo (o botão de dropdown do Prime): abre a lista sem digitar, com todas as
80
+ * sugestões (`dropdownMode="blank"`, o padrão) ou filtrando pelo texto (`"current"`).
81
+ * Padrão: false, como no Figma.
82
+ */
83
+ dropdown?: boolean;
84
+ /** Nome da seta para o leitor de tela. Padrão: "Mostrar opções". */
85
+ dropdownAriaLabel?: string;
78
86
  }
79
87
  declare const AutoComplete: react.ForwardRefExoticComponent<AutoCompleteProps & react.RefAttributes<HTMLInputElement>>;
80
88
 
@@ -900,6 +908,14 @@ interface TableProps<T extends DataTableValue> extends PrimeTableProps<T> {
900
908
  * Padrão: true.
901
909
  */
902
910
  columnMenu?: boolean;
911
+ /**
912
+ * Cabeçalho das colunas fixo na página: enquanto a página (ou o contêiner que rola em volta)
913
+ * passa pela Table, o cabeçalho fica no topo da tela, até a última linha. Soma com o
914
+ * `scrollHeight` do Prime, que fixa o cabeçalho dentro da Table. Padrão: false.
915
+ */
916
+ stickyHeader?: boolean;
917
+ /** Distância do topo da tela em que o cabeçalho para, em px (uma barra fixa da página). Padrão: 0. */
918
+ stickyHeaderOffset?: number;
903
919
  }
904
920
  /** A ref da Table é a do DataTable do Prime: `getElement()`, `exportCSV()`, `reset()`... */
905
921
  type TableHandle<T extends DataTableValue = DataTableValue> = DataTable<T[]>;
package/dist/index.d.ts CHANGED
@@ -64,7 +64,7 @@ declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttri
64
64
 
65
65
  type AutoCompleteVariant = InputVariant;
66
66
  type AutoCompleteSize = InputSize;
67
- interface AutoCompleteProps extends Omit<AutoCompleteProps$1, 'size' | 'variant' | 'invalid' | 'multiple' | 'selectionLimit' | 'selectedItemTemplate' | 'removeTokenIcon' | 'dropdown' | 'dropdownAriaLabel' | 'dropdownAutoFocus' | 'dropdownIcon' | 'dropdownMode' | 'showEmptyMessage' | 'emptyMessage' | 'loadingIcon' | 'inputClassName' | 'panelClassName' | 'scrollHeight' | 'inputRef' | 'pt' | 'ptOptions' | 'unstyled' | 'children'> {
67
+ interface AutoCompleteProps extends Omit<AutoCompleteProps$1, 'size' | 'variant' | 'invalid' | 'multiple' | 'selectionLimit' | 'selectedItemTemplate' | 'removeTokenIcon' | 'dropdownIcon' | 'showEmptyMessage' | 'emptyMessage' | 'loadingIcon' | 'inputClassName' | 'panelClassName' | 'scrollHeight' | 'inputRef' | 'pt' | 'ptOptions' | 'unstyled' | 'children'> {
68
68
  /** Type no Figma: Outline (com borda) e Filled (com fundo). */
69
69
  variant?: AutoCompleteVariant;
70
70
  /** Size no Figma: 32, 36, 42 e 48px de altura do campo. */
@@ -75,6 +75,14 @@ interface AutoCompleteProps extends Omit<AutoCompleteProps$1, 'size' | 'variant'
75
75
  hint?: string;
76
76
  /** Mensagem de erro: deixa o campo no estado Error e mostra a dica de erro no lugar da dica. */
77
77
  error?: string;
78
+ /**
79
+ * Seta à direita do campo (o botão de dropdown do Prime): abre a lista sem digitar, com todas as
80
+ * sugestões (`dropdownMode="blank"`, o padrão) ou filtrando pelo texto (`"current"`).
81
+ * Padrão: false, como no Figma.
82
+ */
83
+ dropdown?: boolean;
84
+ /** Nome da seta para o leitor de tela. Padrão: "Mostrar opções". */
85
+ dropdownAriaLabel?: string;
78
86
  }
79
87
  declare const AutoComplete: react.ForwardRefExoticComponent<AutoCompleteProps & react.RefAttributes<HTMLInputElement>>;
80
88
 
@@ -900,6 +908,14 @@ interface TableProps<T extends DataTableValue> extends PrimeTableProps<T> {
900
908
  * Padrão: true.
901
909
  */
902
910
  columnMenu?: boolean;
911
+ /**
912
+ * Cabeçalho das colunas fixo na página: enquanto a página (ou o contêiner que rola em volta)
913
+ * passa pela Table, o cabeçalho fica no topo da tela, até a última linha. Soma com o
914
+ * `scrollHeight` do Prime, que fixa o cabeçalho dentro da Table. Padrão: false.
915
+ */
916
+ stickyHeader?: boolean;
917
+ /** Distância do topo da tela em que o cabeçalho para, em px (uma barra fixa da página). Padrão: 0. */
918
+ stickyHeaderOffset?: number;
903
919
  }
904
920
  /** A ref da Table é a do DataTable do Prime: `getElement()`, `exportCSV()`, `reset()`... */
905
921
  type TableHandle<T extends DataTableValue = DataTableValue> = DataTable<T[]>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { forwardRef, useRef, useImperativeHandle, useState, Children, isValidElement, useId, useLayoutEffect, useMemo, useCallback, useEffect, useContext, cloneElement } from 'react';
2
2
  import { Accordion as Accordion$1, AccordionTab as AccordionTab$1 } from 'primereact/accordion';
3
- import { WarningCircle, Info, Question, Check, CircleNotch, ArrowLeft, X, CaretDown, MagnifyingGlass, ArrowsInSimple, ArrowsOutSimple, CaretUp, Funnel, List, DribbbleLogo, SealWarning, XCircle, CheckCircle, Warning, Note, ArrowsInLineHorizontal, SortAscending, SortDescending, DotsThreeVertical, CaretLeft, CaretRight, Trash, CaretDoubleRight, CaretDoubleLeft, GearSix } from '@phosphor-icons/react';
3
+ import { CaretDown, WarningCircle, Info, Question, Check, CircleNotch, ArrowLeft, X, MagnifyingGlass, ArrowsInSimple, ArrowsOutSimple, CaretUp, Funnel, List, DribbbleLogo, SealWarning, XCircle, CheckCircle, Warning, Note, ArrowsInLineHorizontal, SortAscending, SortDescending, DotsThreeVertical, CaretLeft, CaretRight, Trash, CaretDoubleRight, CaretDoubleLeft, GearSix } from '@phosphor-icons/react';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { AutoComplete as AutoComplete$1 } from 'primereact/autocomplete';
6
6
  import { Badge as Badge$1 } from 'primereact/badge';
@@ -134,6 +134,8 @@ var AutoComplete = forwardRef(function AutoComplete2({
134
134
  label,
135
135
  hint,
136
136
  error,
137
+ dropdown = false,
138
+ dropdownAriaLabel = "Mostrar op\xE7\xF5es",
137
139
  inputId,
138
140
  required,
139
141
  disabled,
@@ -148,6 +150,7 @@ var AutoComplete = forwardRef(function AutoComplete2({
148
150
  const classes = [
149
151
  "cr-field",
150
152
  "cr-autocomplete",
153
+ dropdown && "cr-autocomplete--dropdown",
151
154
  `cr-field--${variant}`,
152
155
  `cr-field--${size}`,
153
156
  error && "cr-field--error",
@@ -168,6 +171,9 @@ var AutoComplete = forwardRef(function AutoComplete2({
168
171
  required,
169
172
  disabled,
170
173
  scrollHeight: "185px",
174
+ dropdown,
175
+ dropdownAriaLabel,
176
+ dropdownIcon: /* @__PURE__ */ jsx(CaretDown, { className: "cr-autocomplete__dropdown-icon", "aria-hidden": "true" }),
171
177
  pt: {
172
178
  root: { className: "cr-autocomplete__root" },
173
179
  input: {
@@ -177,6 +183,9 @@ var AutoComplete = forwardRef(function AutoComplete2({
177
183
  "aria-invalid": error ? true : void 0
178
184
  }
179
185
  },
186
+ // A seta: o botão de dropdown do Prime, por cima do fim do <input> (que segue sendo a caixa,
187
+ // para a lista continuar alinhada ao campo).
188
+ dropdownButton: { root: { className: "cr-autocomplete__dropdown" } },
180
189
  // O Prime mostra um spinner próprio enquanto busca; o Figma não define esse estado.
181
190
  loadingIcon: { className: "cr-autocomplete__loader" },
182
191
  panel: { className: "cr-lista cr-autocomplete__panel" },
@@ -2522,6 +2531,31 @@ var Tabs = forwardRef(function Tabs2({ activeIndex, onTabChange, children, id, c
2522
2531
  function Column(_props) {
2523
2532
  return null;
2524
2533
  }
2534
+ function useCabecalhoNaPagina(raiz, ligado, offset) {
2535
+ useEffect(() => {
2536
+ const wrapper = raiz.current?.querySelector(".cr-table__wrapper");
2537
+ if (!ligado || !wrapper) return;
2538
+ const posicionar = () => {
2539
+ const thead = wrapper.querySelector(".cr-table__thead");
2540
+ if (!thead) return;
2541
+ const limite = Math.max(0, wrapper.clientHeight - thead.offsetHeight);
2542
+ const desce = Math.min(limite, Math.max(0, offset - wrapper.getBoundingClientRect().top));
2543
+ thead.style.transform = desce ? `translateY(${desce}px)` : "";
2544
+ };
2545
+ posicionar();
2546
+ const observador = new ResizeObserver(posicionar);
2547
+ observador.observe(wrapper);
2548
+ document.addEventListener("scroll", posicionar, { capture: true, passive: true });
2549
+ window.addEventListener("resize", posicionar, { passive: true });
2550
+ return () => {
2551
+ observador.disconnect();
2552
+ document.removeEventListener("scroll", posicionar, { capture: true });
2553
+ window.removeEventListener("resize", posicionar);
2554
+ const thead = wrapper.querySelector(".cr-table__thead");
2555
+ if (thead) thead.style.transform = "";
2556
+ };
2557
+ }, [raiz, ligado, offset]);
2558
+ }
2525
2559
  var caixa = (label) => ({
2526
2560
  root: (options) => ({
2527
2561
  className: `cr-checkbox cr-checkbox__control${options?.props.checked ? " cr-checkbox__control--checked" : ""}`,
@@ -2618,12 +2652,16 @@ function TableBase({
2618
2652
  emptyMessage = "N\xE3o h\xE1 registros para mostrar.",
2619
2653
  loading,
2620
2654
  columnMenu = true,
2655
+ stickyHeader = false,
2656
+ stickyHeaderOffset = 0,
2621
2657
  ...props
2622
2658
  }, ref) {
2623
2659
  const elementos = Children.toArray(children).filter(isValidElement);
2624
2660
  const colunaDeSelecao = elementos.some((element) => element.props.selectionMode === "multiple");
2625
2661
  const template = paginatorTemplate(rowsPerPageLabel);
2626
2662
  const carregando = Boolean(loading);
2663
+ const raiz = useRef(null);
2664
+ useCabecalhoNaPagina(raiz, stickyHeader, stickyHeaderOffset);
2627
2665
  const paginaPropria = !props.onPage;
2628
2666
  const ordemPropria = !props.onSort;
2629
2667
  const [pagina, setPagina] = useState({
@@ -2731,7 +2769,7 @@ function TableBase({
2731
2769
  };
2732
2770
  return (
2733
2771
  // Contêiner da consulta de largura: a variante de 360px também muda a caixa do DataTable.
2734
- /* @__PURE__ */ jsxs("div", { className: "cr-table", children: [
2772
+ /* @__PURE__ */ jsxs("div", { ref: raiz, className: "cr-table", children: [
2735
2773
  /* @__PURE__ */ jsx(
2736
2774
  DataTable,
2737
2775
  {