@charlesgomes/leafcode-shared-lib-react 1.0.76 → 1.0.78

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.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
- import react__default, { ReactNode as ReactNode$1, InputHTMLAttributes } from 'react';
3
+ import react__default, { ReactNode as ReactNode$1, InputHTMLAttributes, JSX } from 'react';
4
4
  import { FieldError } from 'react-hook-form';
5
5
  import { FilterMatchMode } from 'primereact/api';
6
6
  export { FilterMatchMode, FilterOperator } from 'primereact/api';
@@ -18,7 +18,7 @@ interface ButtonProps {
18
18
  }
19
19
  declare function Button({ disabled, loading, color, type, onClick, title, ...rest }: ButtonProps): react_jsx_runtime.JSX.Element;
20
20
 
21
- interface InputProps$1 extends React.InputHTMLAttributes<HTMLInputElement> {
21
+ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
22
22
  name: string;
23
23
  label?: string | ReactNode$1;
24
24
  error?: FieldError;
@@ -29,7 +29,7 @@ interface InputProps$1 extends React.InputHTMLAttributes<HTMLInputElement> {
29
29
  validationMode?: "default" | "restricted";
30
30
  showPasswordToggle?: boolean;
31
31
  }
32
- declare const Input: react.ForwardRefExoticComponent<InputProps$1 & react.RefAttributes<HTMLInputElement>>;
32
+ declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
33
33
 
34
34
  interface TextAreaProps {
35
35
  name: string;
@@ -94,26 +94,42 @@ interface Props {
94
94
  }
95
95
  declare function ModalBase({ show, onHide, onAction, title, children, loading, btnCancel, btnSuccess, type, disabledBtnSuccess, colors, fonts, modalMaxWidth, }: Props): react_jsx_runtime.JSX.Element;
96
96
 
97
- interface PaginatedResponse$1 {
98
- items: any[];
97
+ interface PaginatedResponse$1<T> {
98
+ items: T[];
99
99
  totalPages: number;
100
100
  totalCount: number;
101
101
  }
102
- interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
102
+ interface ServiceParams {
103
+ page: number;
104
+ size: number;
105
+ search: string;
106
+ [key: string]: any;
107
+ }
108
+ type QueryMode<T> = {
109
+ queryKey: string;
110
+ mutationFn: (page: number, size: number, search: string) => Promise<PaginatedResponse$1<T>>;
111
+ service?: never;
112
+ };
113
+ type ServiceMode<T> = {
114
+ service: (params: ServiceParams) => Promise<PaginatedResponse$1<T>>;
115
+ queryKey?: never;
116
+ mutationFn?: never;
117
+ };
118
+ type InputAutoCompleteProps<T> = (QueryMode<T> | ServiceMode<T>) & Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
103
119
  name: string;
104
120
  label?: string;
105
121
  value?: string;
106
- onChange?: (value: any) => void;
107
- onSelect: (item: any) => void;
108
122
  error?: FieldError;
109
- defaultValue?: any;
110
- inputAutocompleteActive?: string;
111
- queryKey: string;
123
+ getLabel?: (item: T) => string;
124
+ renderOption: (item: T) => ReactNode$1;
125
+ onSelect: (item: T | null) => void;
126
+ onChange?: (value: string) => void;
112
127
  isUppercaseLabel?: boolean;
113
- mutationFn: (pageNumber: number, pageSize: number, search: string) => Promise<PaginatedResponse$1>;
114
- renderOption: (item: any) => ReactNode$1;
115
- }
116
- declare const InputAutoComplete: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
128
+ [key: string]: any;
129
+ };
130
+ declare const InputAutoComplete: <T>(props: InputAutoCompleteProps<T> & {
131
+ ref?: React.Ref<HTMLInputElement>;
132
+ }) => JSX.Element;
117
133
 
118
134
  type IDataTableProps<T extends object> = {
119
135
  queryKey: string;
@@ -190,20 +206,11 @@ interface IItemProps {
190
206
  label: string;
191
207
  }
192
208
 
193
- type FilterMatchModeSelectProps = {
194
- options: any;
195
- items: {
196
- label: string;
197
- value: string;
198
- }[];
199
- placeholder?: string;
200
- };
201
- declare const FilterMatchModeSelect: ({ options, items, placeholder, }: FilterMatchModeSelectProps) => react_jsx_runtime.JSX.Element;
202
- declare const DateFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[], mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
203
- declare const DateTimeFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
209
+ declare const DateFilterTemplate: (options: any, mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
210
+ declare const DateTimeFilterTemplate: (options: any, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
204
211
  declare const ValueFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
205
- declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
206
- declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[]) => react_jsx_runtime.JSX.Element;
212
+ declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
213
+ declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean) => false | react_jsx_runtime.JSX.Element;
207
214
 
208
215
  declare const customMatchModes: {
209
216
  notStartsWith: string;
@@ -343,4 +350,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
343
350
 
344
351
  declare const defaultTheme: LeafcodeTheme;
345
352
 
346
- export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, FilterMatchModeSelect, type IDataTableProps, type IItemProps, Input, InputAutoComplete, InputSelect, LeafcodeThemeProvider, ModalBase, SelectFilterTemplate, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
353
+ export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, type IDataTableProps, type IItemProps, Input, InputAutoComplete, type InputAutoCompleteProps, InputSelect, LeafcodeThemeProvider, ModalBase, type PaginatedResponse$1 as PaginatedResponse, SelectFilterTemplate, type ServiceParams, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
- import react__default, { ReactNode as ReactNode$1, InputHTMLAttributes } from 'react';
3
+ import react__default, { ReactNode as ReactNode$1, InputHTMLAttributes, JSX } from 'react';
4
4
  import { FieldError } from 'react-hook-form';
5
5
  import { FilterMatchMode } from 'primereact/api';
6
6
  export { FilterMatchMode, FilterOperator } from 'primereact/api';
@@ -18,7 +18,7 @@ interface ButtonProps {
18
18
  }
19
19
  declare function Button({ disabled, loading, color, type, onClick, title, ...rest }: ButtonProps): react_jsx_runtime.JSX.Element;
20
20
 
21
- interface InputProps$1 extends React.InputHTMLAttributes<HTMLInputElement> {
21
+ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
22
22
  name: string;
23
23
  label?: string | ReactNode$1;
24
24
  error?: FieldError;
@@ -29,7 +29,7 @@ interface InputProps$1 extends React.InputHTMLAttributes<HTMLInputElement> {
29
29
  validationMode?: "default" | "restricted";
30
30
  showPasswordToggle?: boolean;
31
31
  }
32
- declare const Input: react.ForwardRefExoticComponent<InputProps$1 & react.RefAttributes<HTMLInputElement>>;
32
+ declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
33
33
 
34
34
  interface TextAreaProps {
35
35
  name: string;
@@ -94,26 +94,42 @@ interface Props {
94
94
  }
95
95
  declare function ModalBase({ show, onHide, onAction, title, children, loading, btnCancel, btnSuccess, type, disabledBtnSuccess, colors, fonts, modalMaxWidth, }: Props): react_jsx_runtime.JSX.Element;
96
96
 
97
- interface PaginatedResponse$1 {
98
- items: any[];
97
+ interface PaginatedResponse$1<T> {
98
+ items: T[];
99
99
  totalPages: number;
100
100
  totalCount: number;
101
101
  }
102
- interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
102
+ interface ServiceParams {
103
+ page: number;
104
+ size: number;
105
+ search: string;
106
+ [key: string]: any;
107
+ }
108
+ type QueryMode<T> = {
109
+ queryKey: string;
110
+ mutationFn: (page: number, size: number, search: string) => Promise<PaginatedResponse$1<T>>;
111
+ service?: never;
112
+ };
113
+ type ServiceMode<T> = {
114
+ service: (params: ServiceParams) => Promise<PaginatedResponse$1<T>>;
115
+ queryKey?: never;
116
+ mutationFn?: never;
117
+ };
118
+ type InputAutoCompleteProps<T> = (QueryMode<T> | ServiceMode<T>) & Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
103
119
  name: string;
104
120
  label?: string;
105
121
  value?: string;
106
- onChange?: (value: any) => void;
107
- onSelect: (item: any) => void;
108
122
  error?: FieldError;
109
- defaultValue?: any;
110
- inputAutocompleteActive?: string;
111
- queryKey: string;
123
+ getLabel?: (item: T) => string;
124
+ renderOption: (item: T) => ReactNode$1;
125
+ onSelect: (item: T | null) => void;
126
+ onChange?: (value: string) => void;
112
127
  isUppercaseLabel?: boolean;
113
- mutationFn: (pageNumber: number, pageSize: number, search: string) => Promise<PaginatedResponse$1>;
114
- renderOption: (item: any) => ReactNode$1;
115
- }
116
- declare const InputAutoComplete: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
128
+ [key: string]: any;
129
+ };
130
+ declare const InputAutoComplete: <T>(props: InputAutoCompleteProps<T> & {
131
+ ref?: React.Ref<HTMLInputElement>;
132
+ }) => JSX.Element;
117
133
 
118
134
  type IDataTableProps<T extends object> = {
119
135
  queryKey: string;
@@ -190,20 +206,11 @@ interface IItemProps {
190
206
  label: string;
191
207
  }
192
208
 
193
- type FilterMatchModeSelectProps = {
194
- options: any;
195
- items: {
196
- label: string;
197
- value: string;
198
- }[];
199
- placeholder?: string;
200
- };
201
- declare const FilterMatchModeSelect: ({ options, items, placeholder, }: FilterMatchModeSelectProps) => react_jsx_runtime.JSX.Element;
202
- declare const DateFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[], mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
203
- declare const DateTimeFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
209
+ declare const DateFilterTemplate: (options: any, mask?: (value: Date) => string) => react_jsx_runtime.JSX.Element;
210
+ declare const DateTimeFilterTemplate: (options: any, mask?: (date: Date) => string) => react_jsx_runtime.JSX.Element;
204
211
  declare const ValueFilterTemplate: (options: any, mask?: (value: any) => string | number) => react_jsx_runtime.JSX.Element;
205
- declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
206
- declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean, isNullable?: boolean, items?: any[]) => react_jsx_runtime.JSX.Element;
212
+ declare const SelectFilterTemplate: (options: any, isLanguagePtBr?: boolean, items?: IItemProps[]) => react_jsx_runtime.JSX.Element;
213
+ declare const CustomFilterElement: (options: any, isLanguagePtBr?: boolean) => false | react_jsx_runtime.JSX.Element;
207
214
 
208
215
  declare const customMatchModes: {
209
216
  notStartsWith: string;
@@ -343,4 +350,4 @@ declare const LeafcodeThemeProvider: ({ children, theme, }: LeafcodeThemeProvide
343
350
 
344
351
  declare const defaultTheme: LeafcodeTheme;
345
352
 
346
- export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, FilterMatchModeSelect, type IDataTableProps, type IItemProps, Input, InputAutoComplete, InputSelect, LeafcodeThemeProvider, ModalBase, SelectFilterTemplate, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };
353
+ export { Button, type ColumnCustom, CustomFilterElement, DataTableAdvancedFilter, DateFilterTemplate, DateTimeFilterTemplate, type IDataTableProps, type IItemProps, Input, InputAutoComplete, type InputAutoCompleteProps, InputSelect, LeafcodeThemeProvider, ModalBase, type PaginatedResponse$1 as PaginatedResponse, SelectFilterTemplate, type ServiceParams, TextArea, ValueFilterTemplate, buildDynamicCampoFilters, buildSortingWithFilters, customMatchModes, defaultTheme, getDefaultFilterMatchOptionsDate, getDefaultFilterMatchOptionsEnum, getDefaultFilterMatchOptionsString, getDefaultFilterMatchOptionsStringArray, getNullable, getUrlParams, mapPrimeToBackendFilters };