@grazziotin/react-components-next 1.0.1 → 2.1.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.
@@ -1,7 +1,7 @@
1
1
  import * as _mui_material from '@mui/material';
2
- import { CSSProperties, Breakpoint, TabProps as TabProps$1, TabsProps as TabsProps$1 } from '@mui/material';
2
+ import { CSSProperties, Breakpoint, TabProps as TabProps$1, TabsProps as TabsProps$1, TextFieldProps, AutocompleteProps, AutocompleteChangeReason, AutocompleteChangeDetails } from '@mui/material';
3
3
  import * as react from 'react';
4
- import react__default, { ComponentPropsWithoutRef } from 'react';
4
+ import react__default, { ComponentPropsWithoutRef, Dispatch, SetStateAction, SubmitEventHandler, ReactElement } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { DataGridProps } from '@mui/x-data-grid';
7
7
  import * as _emotion_styled from '@emotion/styled';
@@ -311,6 +311,212 @@ declare const Tabs: _emotion_styled.StyledComponent<_mui_material.TabsOwnProps &
311
311
  * <Tab label="Configurações" color="#00B2A6" />
312
312
  * ```
313
313
  */
314
- declare const Tab: _emotion_styled.StyledComponent<_mui_material.TabOwnProps & Omit<_mui_material.ButtonBaseOwnProps, keyof _mui_material.TabOwnProps> & Omit<_mui_material.ButtonBaseOwnProps, "tabIndex" | "type" | "touchRippleRef" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | keyof _mui_material.TabOwnProps> & _mui_material_OverridableComponent.CommonProps & Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "label" | "style" | "className" | "tabIndex" | "children" | "icon" | "sx" | "type" | "classes" | "disabled" | "touchRippleRef" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "disableFocusRipple" | "iconPosition" | "wrapped"> & _mui_system.MUIStyledCommonProps<_mui_material.Theme> & TabColorProps, {}, {}>;
314
+ declare const Tab: _emotion_styled.StyledComponent<_mui_material.TabOwnProps & Omit<_mui_material.ButtonBaseOwnProps, keyof _mui_material.TabOwnProps> & Omit<_mui_material.ButtonBaseOwnProps, "tabIndex" | "type" | "touchRippleRef" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | keyof _mui_material.TabOwnProps> & _mui_material_OverridableComponent.CommonProps & Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style" | "label" | "className" | "tabIndex" | "children" | "icon" | "sx" | "type" | "classes" | "disabled" | "touchRippleRef" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "disableFocusRipple" | "iconPosition" | "wrapped"> & _mui_system.MUIStyledCommonProps<_mui_material.Theme> & TabColorProps, {}, {}>;
315
315
 
316
- export { Card, type CardClassName, type CardProps, DataTable, type DataTableProps, Dialog, type DialogProps, Tab, type TabColorProps, type TabProps, Tabs, type TabsProps };
316
+ type InputType = TextFieldProps["type"] | "cpf-cnpj" | "numeric" | "price" | "text-only" | "text-no-number" | "item-170" | "item-150";
317
+ type InputProps = Omit<TextFieldProps, "color" | "type" | "size"> & {
318
+ /**
319
+ * Cor do input.
320
+ */
321
+ color?: string;
322
+ /**
323
+ * Se true, exibe um botão de toggle para mostrar/ocultar a senha.
324
+ */
325
+ isPassword?: boolean;
326
+ /**
327
+ * Aceita os tipos padrão do TextField e tipos customizados do projeto.
328
+ * Padrão: `"text"`.
329
+ */
330
+ type?: InputType;
331
+ /**
332
+ * Tamanho do campo conforme o MUI TextField.
333
+ * Padrão: `"small"`.
334
+ */
335
+ size?: TextFieldProps["size"];
336
+ };
337
+
338
+ /**
339
+ * Campo de texto baseado no MUI TextField, com máscaras e tipos customizados do projeto.
340
+ */
341
+ declare const Input: ({ color, onChange, isPassword, type, size, ...rest }: Readonly<InputProps>) => react_jsx_runtime.JSX.Element;
342
+
343
+ /**
344
+ * Propriedades de layout em grid para o campo do {@link InputSelect}.
345
+ */
346
+ interface InputSelectGridProps {
347
+ /**
348
+ * Ordem de exibição do input.
349
+ */
350
+ order?: number;
351
+ /**
352
+ * Tamanho do grid para o input.
353
+ */
354
+ xs?: number;
355
+ }
356
+ /**
357
+ * Propriedades do componente {@link InputSelect}.
358
+ *
359
+ * Estende o Autocomplete do MUI, substituindo `renderInput` pelo {@link Input} do projeto
360
+ * e tipando `onChange` conforme seleção única ou múltipla.
361
+ *
362
+ * @template T - Tipo dos itens de opções no seletor.
363
+ * @template M - Valor booleano que define se a seleção pode ser múltipla.
364
+ */
365
+ interface InputSelectProps<T, M extends boolean = false> extends Omit<AutocompleteProps<T, M, boolean | undefined, boolean | undefined>, "renderInput" | "onChange"> {
366
+ /**
367
+ * Propriedades repassadas ao {@link Input} interno.
368
+ * Aceita label, color, type, máscaras e demais props do TextField do projeto.
369
+ */
370
+ input?: InputProps & InputSelectGridProps;
371
+ /**
372
+ * Opções exibidas no seletor.
373
+ */
374
+ options: T[];
375
+ /**
376
+ * Retorna a string exibida como rótulo de uma opção.
377
+ * @param data - Item da lista `options`.
378
+ */
379
+ optionLabel: (data: T) => string;
380
+ /**
381
+ * Define se o seletor permite múltiplas seleções.
382
+ * Padrão: `false`.
383
+ */
384
+ multiple?: M;
385
+ /**
386
+ * Callback disparado quando o valor do seletor é alterado.
387
+ * @param event - Evento que disparou a alteração.
388
+ * @param value - Novo valor (`T | null` ou `T[]` quando `multiple`).
389
+ * @param reason - Motivo da alteração (MUI `AutocompleteChangeReason`).
390
+ * @param details - Detalhes adicionais da alteração (opcional).
391
+ */
392
+ onChange?: (event: React.SyntheticEvent, value: M extends true ? T[] : T | null, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<T>) => void;
393
+ }
394
+
395
+ /**
396
+ * Componente InputSelect que encapsula o Autocomplete do Material-UI com o {@link Input} do projeto.
397
+ *
398
+ * Permite a seleção de uma ou mais opções com base nos parâmetros fornecidos.
399
+ * É configurável via props do Autocomplete do MUI, com campo de entrada customizável
400
+ * através de `input` (mesmas props do {@link Input}: cor, label, máscaras, etc.).
401
+ *
402
+ * @template T - Tipo dos itens de opções exibidos no seletor.
403
+ * @template M - Define se o seletor permite múltiplas seleções. Padrão: `false` (seletor único).
404
+ *
405
+ * @param props - Propriedades do componente. Detalhes em {@link InputSelectProps}.
406
+ * @param props.multiple - Se `true`, permite selecionar várias opções. Padrão: `false`.
407
+ * @param props.optionLabel - Função que recebe uma opção e retorna o rótulo exibido.
408
+ * @param props.onChange - Callback ao alterar o valor (evento, valor, motivo e detalhes).
409
+ * @param props.input - Props repassadas ao {@link Input} interno (label, color, type, etc.).
410
+ * @param props.options - Lista de opções disponíveis no seletor.
411
+ * @param props.rest - Demais props do Autocomplete do MUI (exceto `renderInput` e `onChange`).
412
+ *
413
+ * @returns Autocomplete com campo de entrada personalizado.
414
+ *
415
+ * @example
416
+ * ```tsx
417
+ * const options = [
418
+ * { id: 1, label: "Opção 1" },
419
+ * { id: 2, label: "Opção 2" },
420
+ * ];
421
+ *
422
+ * <InputSelect
423
+ * options={options}
424
+ * optionLabel={(option) => option.label}
425
+ * input={{ label: "Selecione", color: "#00b2a6" }}
426
+ * onChange={(_event, value) => console.log("Valor selecionado:", value)}
427
+ * multiple
428
+ * />
429
+ * ```
430
+ */
431
+ declare function InputSelect<T, M extends boolean = false>({ multiple, optionLabel, onChange, input, ...rest }: Readonly<InputSelectProps<T, M>>): react_jsx_runtime.JSX.Element;
432
+
433
+ /**
434
+ * Propriedades do componente {@link FilterCard}.
435
+ */
436
+ interface FilterCardProps {
437
+ /** Título do cartão de filtros. */
438
+ title?: string;
439
+ /** Indica se o botão de filtros deve ser exibido. */
440
+ renderFilter: boolean;
441
+ /** Controla a abertura do drawer de filtros. */
442
+ setOpen: Dispatch<SetStateAction<boolean>>;
443
+ }
444
+ /**
445
+ * {@link Input} no grid do drawer de filtros.
446
+ * Inclui `order` e `xs` para posicionamento no grid responsivo.
447
+ */
448
+ type FilterInputProps = InputProps & InputSelectGridProps;
449
+ /**
450
+ * {@link InputSelect} tipado no grid do drawer.
451
+ * Use {@link filterInputSelect} para inferir `T` por campo sem casts.
452
+ */
453
+ type FilterInputSelectItem<T, M extends boolean = false> = InputSelectProps<T, M> & InputSelectGridProps;
454
+ /**
455
+ * Campo {@link InputSelect} no drawer com tipos heterogêneos.
456
+ * Cada item pode ter `options` de um tipo diferente na mesma lista.
457
+ */
458
+ type FilterInputSelectField<M extends boolean = false> = InputSelectProps<unknown, M> & InputSelectGridProps;
459
+ /**
460
+ * Lista de campos {@link InputSelect} no drawer.
461
+ * Cada item pode ter tipo de opção e seleção única/múltipla diferentes.
462
+ */
463
+ type FilterInputSelectProps = (FilterInputSelectField<false> | FilterInputSelectField<true>)[];
464
+ /** Campo do drawer: {@link Input} ou {@link InputSelect}. */
465
+ type FilterDrawerField = FilterInputProps | FilterInputSelectField<false> | FilterInputSelectField<true>;
466
+ /**
467
+ * Propriedades do componente {@link FilterDrawer}.
468
+ */
469
+ interface FilterDrawerProps {
470
+ /** Drawer aberto. */
471
+ open?: boolean;
472
+ /** Controla a abertura do drawer. */
473
+ setOpen: Dispatch<SetStateAction<boolean>>;
474
+ /** Campos {@link Input}. */
475
+ inputs?: FilterInputProps[];
476
+ /** Campos {@link InputSelect}. */
477
+ inputSelect?: FilterInputSelectProps;
478
+ /** Callback ao limpar filtros. */
479
+ onClear?: () => void;
480
+ /** Callback ao submeter o formulário de filtros. */
481
+ onSubmit?: SubmitEventHandler<HTMLFormElement>;
482
+ }
483
+ /**
484
+ * Propriedades do componente {@link Filter}.
485
+ *
486
+ * Combina título do card com campos e callbacks do drawer.
487
+ */
488
+ interface FilterProps extends Omit<FilterCardProps, "renderFilter" | "setOpen">, Omit<FilterDrawerProps, "open" | "setOpen"> {
489
+ }
490
+
491
+ /**
492
+ * Filtro com card de título e drawer contendo {@link Input} e {@link InputSelect}.
493
+ *
494
+ * O card exibe o título da página/relatório e um botão para abrir o drawer quando
495
+ * há campos em `inputs` ou `inputSelect`. O drawer renderiza os campos em grid
496
+ * responsivo, com ações de limpar e pesquisar.
497
+ *
498
+ * @param props - Propriedades do componente. Detalhes em {@link FilterProps}.
499
+ * @param props.title - Título exibido no card.
500
+ * @param props.inputs - Campos de texto/máscara ({@link Input}).
501
+ * @param props.inputSelect - Campos de seleção ({@link InputSelect}).
502
+ * @param props.onClear - Callback ao limpar filtros.
503
+ * @param props.onSubmit - Callback ao pesquisar.
504
+ * @returns Elemento React com card e drawer de filtros.
505
+ */
506
+ declare const Filter: ({ title, inputs, onClear, onSubmit, inputSelect, }: FilterProps) => ReactElement;
507
+
508
+ /**
509
+ * Define um campo {@link InputSelect} no filter preservando a inferência de `T`.
510
+ * Permite montar listas com tipos de opção diferentes sem union nem `as`.
511
+ *
512
+ * @example
513
+ * filterInputSelect({
514
+ * options: networks,
515
+ * optionLabel: (v) => v.desRede,
516
+ * input: { label: "Rede" },
517
+ * order: 1,
518
+ * })
519
+ */
520
+ declare function filterInputSelect<T extends object, M extends boolean = false>(props: InputSelectProps<T, M> & InputSelectGridProps): M extends true ? FilterInputSelectField<true> : FilterInputSelectField<false>;
521
+
522
+ export { Card, type CardClassName, type CardProps, DataTable, type DataTableProps, Dialog, type DialogProps, Filter, type FilterCardProps, type FilterDrawerField, type FilterDrawerProps, type FilterInputProps, type FilterInputSelectField, type FilterInputSelectItem, type FilterInputSelectProps, type FilterProps, Input, type InputProps, InputSelect, type InputSelectGridProps, type InputSelectProps, type InputType, Tab, type TabColorProps, type TabProps, Tabs, type TabsProps, filterInputSelect };