@mw-kit/mw-ui 1.7.93 → 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.
- package/dist/components/Filters/Filters/components/Submenu/interfaces.d.ts +2 -2
- package/dist/components/Filters/Filters/index.d.ts +1 -1
- package/dist/components/Filters/Filters/interfaces.d.ts +13 -12
- package/dist/components/Input/components/Select/hooks/Select/index.d.ts +3 -4
- package/dist/components/Input/components/Select/hooks/SelectMultiple/index.d.ts +3 -4
- package/dist/components/Input/components/Select/hooks/interfaces.d.ts +1 -0
- package/dist/components/Menu/interfaces.d.ts +5 -1
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +7 -8
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
4
|
+
import { Common, Filter } from '../../interfaces';
|
|
5
5
|
export interface SubmenuProps {
|
|
6
6
|
item?: Filter;
|
|
7
|
-
optionLabel?: OptionLabelComponent
|
|
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<
|
|
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,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const useSelect: (props: SelectProps, [highlight, setHighlight]: [number, React.Dispatch<React.SetStateAction<number>>], [options, setOptions]: [Option[], React.Dispatch<React.SetStateAction<Option[]>>], setOpen: React.Dispatch<React.SetStateAction<boolean>>) => useSelectReturn;
|
|
1
|
+
import * as Types from '../interfaces';
|
|
2
|
+
import { SelectProps } from './interfaces';
|
|
3
|
+
declare const useSelect: Types.useSelect<SelectProps>;
|
|
5
4
|
export default useSelect;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const useSelectMultiple: (props: SelectProps, [highlight, setHighlight]: [number, React.Dispatch<React.SetStateAction<number>>], [options, setOptions]: [Option[], React.Dispatch<React.SetStateAction<Option[]>>], _setOpen: React.Dispatch<React.SetStateAction<boolean>>) => useSelectReturn;
|
|
1
|
+
import * as Types from '../interfaces';
|
|
2
|
+
import { SelectProps } from './interfaces';
|
|
3
|
+
declare const useSelectMultiple: Types.useSelect<SelectProps>;
|
|
5
4
|
export default useSelectMultiple;
|
|
@@ -48,4 +48,5 @@ export interface useSelectReturn {
|
|
|
48
48
|
onClear?: () => void;
|
|
49
49
|
dirty?: InputProps['dirty'];
|
|
50
50
|
}
|
|
51
|
+
export declare type useSelect<Props extends CommonProps> = (props: Props, highlight: [number, React.Dispatch<React.SetStateAction<number>>], options: [Option[], React.Dispatch<React.SetStateAction<Option[]>>], setOpen: React.Dispatch<React.SetStateAction<boolean>>) => useSelectReturn;
|
|
51
52
|
export {};
|
|
@@ -24,7 +24,11 @@ export interface CommonProps extends Omit<AbsoluteContainerProps, 'children' | '
|
|
|
24
24
|
export interface MenuProps<T extends GenericObject = GenericObject> extends CommonProps, Pick<ScrollContainerProps, 'onScrollEnd' | 'loading' | 'before' | 'after'> {
|
|
25
25
|
open: boolean;
|
|
26
26
|
close: () => void;
|
|
27
|
-
options: Option<T>
|
|
27
|
+
options: (Option<T> & {
|
|
28
|
+
labelComponent?: OptionLabelComponent<T>;
|
|
29
|
+
onClick?: (index: number, option: T, event: React.MouseEvent) => void;
|
|
30
|
+
rules?: Rule<T>[];
|
|
31
|
+
})[];
|
|
28
32
|
scrollSpacing?: ScrollContainerProps['spacing'];
|
|
29
33
|
scrollTabIndex?: number;
|
|
30
34
|
emptyContent?: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -13041,8 +13041,6 @@ var MenuComponent = function MenuComponent(props, ref) {
|
|
|
13041
13041
|
var absoluteContainerProps = filterObject(props, ['scrollSpacing', 'scrollTabIndex', 'label', 'rules', 'onClickOption', 'onScrollEnd', 'before', 'after', 'close', 'options', 'loading', 'children', 'emptyContent', 'highlight'], {
|
|
13042
13042
|
itemSpacing: 's1'
|
|
13043
13043
|
});
|
|
13044
|
-
var rules = props.rules || [];
|
|
13045
|
-
var LabelComponent = props.label || EmptyLabel;
|
|
13046
13044
|
return React__default.createElement(Container$2, Object.assign({}, absoluteContainerProps, {
|
|
13047
13045
|
ref: ref
|
|
13048
13046
|
}), React__default.createElement(React__default.Fragment, null, React__default.createElement(ScrollContainer, {
|
|
@@ -13074,14 +13072,14 @@ var MenuComponent = function MenuComponent(props, ref) {
|
|
|
13074
13072
|
};
|
|
13075
13073
|
|
|
13076
13074
|
if (!disabled) {
|
|
13077
|
-
var rule = rules.map(function (rule) {
|
|
13075
|
+
var rule = (option.rules || props.rules || []).map(function (rule) {
|
|
13078
13076
|
return rule(index, data);
|
|
13079
13077
|
}).find(function (result) {
|
|
13080
13078
|
return result !== true;
|
|
13081
13079
|
});
|
|
13082
13080
|
|
|
13083
13081
|
if (rule === true || rule === undefined) {
|
|
13084
|
-
var _onClick = props.onClickOption || function () {};
|
|
13082
|
+
var _onClick = option.onClick || props.onClickOption || function () {};
|
|
13085
13083
|
|
|
13086
13084
|
onClick = function onClick(e) {
|
|
13087
13085
|
_onClick(index, option.data, e);
|
|
@@ -13114,6 +13112,7 @@ var MenuComponent = function MenuComponent(props, ref) {
|
|
|
13114
13112
|
}
|
|
13115
13113
|
|
|
13116
13114
|
OptionContent.displayName = 'OptionContent';
|
|
13115
|
+
var LabelComponent = option.labelComponent || props.label || EmptyLabel;
|
|
13117
13116
|
return React__default.createElement(React__default.Fragment, {
|
|
13118
13117
|
key: index
|
|
13119
13118
|
}, React__default.createElement(OptionContent, null, React__default.createElement(Option, {
|
|
@@ -14705,11 +14704,11 @@ var useNavigation = function useNavigation(props) {
|
|
|
14705
14704
|
}
|
|
14706
14705
|
}, [highlight, options, rules]);
|
|
14707
14706
|
|
|
14708
|
-
var onFocus = function onFocus(
|
|
14707
|
+
var onFocus = function onFocus() {
|
|
14709
14708
|
setHighlight(0);
|
|
14710
14709
|
};
|
|
14711
14710
|
|
|
14712
|
-
var onBlur = function onBlur(
|
|
14711
|
+
var onBlur = function onBlur() {
|
|
14713
14712
|
setHighlight(-1);
|
|
14714
14713
|
};
|
|
14715
14714
|
|
|
@@ -15059,7 +15058,7 @@ var parseValue = function parseValue(value) {
|
|
|
15059
15058
|
return parsed;
|
|
15060
15059
|
};
|
|
15061
15060
|
|
|
15062
|
-
var useSelectMultiple = function useSelectMultiple(props, _ref, _ref2
|
|
15061
|
+
var useSelectMultiple = function useSelectMultiple(props, _ref, _ref2) {
|
|
15063
15062
|
var highlight = _ref[0],
|
|
15064
15063
|
setHighlight = _ref[1];
|
|
15065
15064
|
var options = _ref2[0],
|
|
@@ -18097,7 +18096,7 @@ var Submenu = function Submenu(props) {
|
|
|
18097
18096
|
var optionsParser = function optionsParser(option) {
|
|
18098
18097
|
return {
|
|
18099
18098
|
label: option.label,
|
|
18100
|
-
data: option
|
|
18099
|
+
data: option.data
|
|
18101
18100
|
};
|
|
18102
18101
|
};
|
|
18103
18102
|
|