@mw-kit/mw-ui 1.7.94 → 1.7.95

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,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { OptionLabelComponent } from '../../../../Menu/interfaces';
3
3
  import { AppliedFilter } from '../../../interfaces';
4
- import { Common, Filter, Option } from '../../interfaces';
4
+ import { Common, Filter } from '../../interfaces';
5
5
  export interface SubmenuProps {
6
6
  item?: Filter;
7
- optionLabel?: OptionLabelComponent<Option>;
7
+ optionLabel?: OptionLabelComponent;
8
8
  close: () => void;
9
9
  closeParent: () => void;
10
10
  setAppliedFilters: React.Dispatch<React.SetStateAction<AppliedFilter[]>>;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { FiltersProps } from './interfaces';
3
- declare const Filters: ((props: FiltersProps) => JSX.Element) & {
3
+ declare const Filters: (<T extends Record<string | number | symbol, any> = Record<string | number | symbol, any>>(props: FiltersProps<T>) => JSX.Element) & {
4
4
  Menu: (props: import("./components/Menu/interfaces").FiltersMenuProps) => JSX.Element;
5
5
  };
6
6
  export default Filters;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ReactNode, SpacingOrZero } from '../../../interfaces';
2
+ import { GenericObject, ReactNode, SpacingOrZero } from '../../../interfaces';
3
3
  import { AbsoluteContainerProps } from '../../AbsoluteContainer/interfaces';
4
4
  import { OptionLabelComponent } from '../../Menu/interfaces';
5
5
  import { ButtonProps } from '../Button/interfaces';
@@ -8,28 +8,29 @@ export interface Label {
8
8
  text: string;
9
9
  element: ReactNode;
10
10
  }
11
- export interface Option {
11
+ export interface Option<T extends GenericObject = GenericObject> {
12
12
  /** label da opcao */
13
13
  label: string;
14
+ data: T;
14
15
  /** valor da opcao */
15
16
  value: string | number | boolean;
16
17
  }
17
- export interface OptionsReturn {
18
- options: Option[];
18
+ export interface OptionsReturn<T extends GenericObject = GenericObject> {
19
+ options: Option<T>[];
19
20
  lastPage: boolean;
20
21
  }
21
22
  /**
22
23
  * essa callback recebe o valor da string de busca e opcionalmente o indice da pagina, e ela deve retornar uma lista de opcoes
23
24
  * para que a paginacao seja considerada, e necessario retornar a lista de opcoes em um objeto, juntamente com o indicador de ultima pagina
24
25
  * */
25
- export declare type OptionsCallback = (value: string, page?: number) => Promise<OptionsReturn | Option[]>;
26
- export interface Filter {
26
+ export declare type OptionsCallback<T extends GenericObject = GenericObject> = (value: string, page?: number) => Promise<OptionsReturn<T> | Option<T>[]>;
27
+ export interface Filter<T extends GenericObject = GenericObject> {
27
28
  /** label do filtro */
28
29
  label: string;
29
30
  /** nome da chave do filtro */
30
31
  name: string;
31
32
  /** lista de opcoes ou funcao que retorna a lista de opcoes */
32
- options: Option[] | OptionsCallback;
33
+ options: Option<T>[] | OptionsCallback<T>;
33
34
  /** se o filtro for do tipo callback, podera ser enviado este parametro para indicar se o filtro permite busca com string vazia */
34
35
  allowEmptySearch?: boolean;
35
36
  /** indicador de filtro desabilitado */
@@ -41,14 +42,14 @@ export interface Filter {
41
42
  /** mantem o menu de filtros abertos após a selecao */
42
43
  keepOpen?: true;
43
44
  }
44
- export interface Common {
45
- items: Filter[];
45
+ export interface Common<T extends GenericObject = GenericObject> {
46
+ items: Filter<T>[];
46
47
  optionLabel?: {
47
- [key: string]: OptionLabelComponent<Option>;
48
+ [key: string]: OptionLabelComponent<T>;
48
49
  };
49
- filterLabel?: OptionLabelComponent<Filter>;
50
+ filterLabel?: OptionLabelComponent<Filter<T>>;
50
51
  setAppliedFilters: React.Dispatch<React.SetStateAction<AppliedFilter[]>>;
51
52
  containerProps?: Omit<AbsoluteContainerProps, 'open'>;
52
53
  subContainerProps?: Pick<AbsoluteContainerProps, 'center'>;
53
54
  }
54
- export declare type FiltersProps = Common & Omit<ButtonProps, 'getContent' | 'gap'>;
55
+ export declare type FiltersProps<T extends GenericObject = GenericObject> = Common<T> & Omit<ButtonProps, 'getContent' | 'gap'>;
@@ -1,4 +1,4 @@
1
- import { useSelect } from '../interfaces';
1
+ import * as Types from '../interfaces';
2
2
  import { SelectProps } from './interfaces';
3
- declare const useSelect: useSelect<SelectProps>;
3
+ declare const useSelect: Types.useSelect<SelectProps>;
4
4
  export default useSelect;
@@ -1,4 +1,4 @@
1
- import { useSelect } from '../interfaces';
1
+ import * as Types from '../interfaces';
2
2
  import { SelectProps } from './interfaces';
3
- declare const useSelectMultiple: useSelect<SelectProps>;
3
+ declare const useSelectMultiple: Types.useSelect<SelectProps>;
4
4
  export default useSelectMultiple;
package/dist/index.js CHANGED
@@ -18096,7 +18096,7 @@ var Submenu = function Submenu(props) {
18096
18096
  var optionsParser = function optionsParser(option) {
18097
18097
  return {
18098
18098
  label: option.label,
18099
- data: option
18099
+ data: option.data
18100
18100
  };
18101
18101
  };
18102
18102