@deix/rossini-core 6.2.1 → 6.3.1
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/lib/components/display/PaginatedList/PaginatedList.d.ts +1 -1
- package/lib/components/display/PaginatedList/PaginatedList.d.ts.map +1 -1
- package/lib/components/display/PaginatedList/PaginatedList.js +9 -13
- package/lib/components/filters/DateFilter.d.ts +11 -0
- package/lib/components/filters/DateFilter.d.ts.map +1 -0
- package/lib/components/filters/DateFilter.js +29 -0
- package/lib/components/filters/FilterForm.d.ts +10 -0
- package/lib/components/filters/FilterForm.d.ts.map +1 -0
- package/lib/components/filters/FilterForm.js +15 -0
- package/lib/components/filters/NumberFilter.d.ts +12 -0
- package/lib/components/filters/NumberFilter.d.ts.map +1 -0
- package/lib/components/filters/NumberFilter.js +26 -0
- package/lib/components/filters/SelectFilter.d.ts +20 -0
- package/lib/components/filters/SelectFilter.d.ts.map +1 -0
- package/lib/components/filters/SelectFilter.js +40 -0
- package/lib/components/filters/TextFilter.d.ts +12 -0
- package/lib/components/filters/TextFilter.d.ts.map +1 -0
- package/lib/components/filters/TextFilter.js +25 -0
- package/lib/components/filters/index.d.ts +11 -0
- package/lib/components/filters/index.d.ts.map +1 -0
- package/lib/components/filters/index.js +5 -0
- package/lib/components/i18n/Link.d.ts.map +1 -1
- package/lib/components/index.d.ts +14 -12
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +7 -6
- package/lib/components/provider/UserInfoProvider.d.ts.map +1 -1
- package/lib/components/provider/UserInfoProvider.js +5 -4
- package/lib/index.d.ts +5 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/helpers/index.d.ts +3 -3
- package/lib/utils/helpers/index.d.ts.map +1 -1
- package/lib/utils/helpers/index.js +3 -3
- package/lib/utils/helpers/stringHelpers.d.ts +2 -0
- package/lib/utils/helpers/stringHelpers.d.ts.map +1 -1
- package/lib/utils/helpers/stringHelpers.js +14 -0
- package/lib/utils/hooks/useFormattedQueryState.d.ts +8 -0
- package/lib/utils/hooks/useFormattedQueryState.d.ts.map +1 -0
- package/lib/utils/hooks/useFormattedQueryState.js +18 -0
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +3 -3
- package/lib/utils/middleware/index.d.ts +1 -1
- package/lib/utils/middleware/index.d.ts.map +1 -1
- package/lib/utils/middleware/index.js +1 -1
- package/package.json +16 -16
|
@@ -18,6 +18,6 @@ export interface PaginatedListProps {
|
|
|
18
18
|
emptyDataLabel?: string;
|
|
19
19
|
disablePaginationLabels?: boolean;
|
|
20
20
|
}
|
|
21
|
-
declare const PaginatedList: ({ urlPrefix, title, subtitle, items, totalItems, onPageChange, rowsPerPageOptions, onPageSizeChange, menu, densityMenuEnabled, maxHeight, emptyDataLabel, disablePaginationLabels, }: PaginatedListProps) => React.JSX.Element;
|
|
21
|
+
declare const PaginatedList: ({ urlPrefix, title, subtitle, items, totalItems, page, onPageChange, pageSize, rowsPerPageOptions, onPageSizeChange, menu, densityMenuEnabled, maxHeight, emptyDataLabel, disablePaginationLabels, }: PaginatedListProps) => React.JSX.Element;
|
|
22
22
|
export default PaginatedList;
|
|
23
23
|
//# sourceMappingURL=PaginatedList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedList.d.ts","sourceRoot":"","sources":["../../../../src/components/display/PaginatedList/PaginatedList.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAqB5C,OAAiB,EAAW,aAAa,EAAE,MAAM,YAAY,CAAC;AAI9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AA2BD,QAAA,MAAM,aAAa,GAAI,
|
|
1
|
+
{"version":3,"file":"PaginatedList.d.ts","sourceRoot":"","sources":["../../../../src/components/display/PaginatedList/PaginatedList.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAqB5C,OAAiB,EAAW,aAAa,EAAE,MAAM,YAAY,CAAC;AAI9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AA2BD,QAAA,MAAM,aAAa,GAAI,sMAgBpB,kBAAkB,sBAyLpB,CAAC;AACF,eAAe,aAAa,CAAC"}
|
|
@@ -32,14 +32,10 @@ const paginatedListTranslations = {
|
|
|
32
32
|
en: 'No data available',
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
|
-
const PaginatedList = ({ urlPrefix = 'pl', title, subtitle, items, totalItems,
|
|
36
|
-
//page = 0,
|
|
37
|
-
onPageChange,
|
|
38
|
-
//pageSize = 10,
|
|
39
|
-
rowsPerPageOptions = [10, 25, 50], onPageSizeChange, menu = [], densityMenuEnabled = false, maxHeight = '90vh', emptyDataLabel, disablePaginationLabels = false, }) => {
|
|
35
|
+
const PaginatedList = ({ urlPrefix = 'pl', title, subtitle, items, totalItems, page = 0, onPageChange, pageSize = 10, rowsPerPageOptions = [10, 25, 50], onPageSizeChange, menu = [], densityMenuEnabled = false, maxHeight = '90vh', emptyDataLabel, disablePaginationLabels = false, }) => {
|
|
40
36
|
const locale = useLocale();
|
|
41
|
-
const [
|
|
42
|
-
const [
|
|
37
|
+
const [currentPage, setCurrentPage] = useQueryState(`${urlPrefix}_page`, parseAsInteger.withDefault(page));
|
|
38
|
+
const [currentPageSize, setCurrentPageSize] = useQueryState(`${urlPrefix}_page_size`, parseAsInteger.withDefault(pageSize));
|
|
43
39
|
// Appearance
|
|
44
40
|
const [listDensity, setListDensity] = usePersistedState(`listDensity`, 'standard');
|
|
45
41
|
const [densityMenuAnchorEl, setDensityMenuAnchorEl] = useState(null);
|
|
@@ -72,24 +68,24 @@ rowsPerPageOptions = [10, 25, 50], onPageSizeChange, menu = [], densityMenuEnabl
|
|
|
72
68
|
paginatedListTranslations.rowsPerPage[locale] ||
|
|
73
69
|
'Rows per page',
|
|
74
70
|
":")),
|
|
75
|
-
React.createElement(Select, { labelId: 'page-size-select-label', id: 'page-size-select', value: Number(
|
|
76
|
-
|
|
71
|
+
React.createElement(Select, { labelId: 'page-size-select-label', id: 'page-size-select', value: Number(currentPageSize), label: 'Rows per Page', onChange: (event) => {
|
|
72
|
+
setCurrentPageSize(Number(event.target.value));
|
|
77
73
|
onPageSizeChange(Number(event.target.value));
|
|
78
74
|
}, variant: 'standard' }, rowsPerPageOptions.map((opt) => (React.createElement(MenuItem, { key: opt, value: Number(opt) },
|
|
79
75
|
React.createElement(Typography, { variant: 'caption', sx: { mr: 2 } }, opt)))))),
|
|
80
76
|
React.createElement(Grid, { size: { xs: 12, md: 6 } },
|
|
81
77
|
React.createElement(Box, { sx: { display: 'flex', justifyContent: 'center' } },
|
|
82
|
-
React.createElement(Pagination, { count: Math.ceil(totalItems /
|
|
78
|
+
React.createElement(Pagination, { count: Math.ceil(totalItems / currentPageSize), size: 'small', showFirstButton: true, showLastButton: true, page: currentPage + 1, onChange: onPageChange
|
|
83
79
|
? (_evt, page) => {
|
|
84
|
-
|
|
80
|
+
setCurrentPage(page - 1);
|
|
85
81
|
onPageChange(page - 1);
|
|
86
82
|
}
|
|
87
83
|
: undefined, sx: { mr: 4 } }))),
|
|
88
84
|
React.createElement(Grid, { size: { xs: 12, md: 3 }, sx: { textAlign: 'end' } },
|
|
89
85
|
React.createElement(Typography, { variant: 'caption' },
|
|
90
|
-
|
|
86
|
+
currentPage * currentPageSize + 1,
|
|
91
87
|
"-",
|
|
92
|
-
Math.min((
|
|
88
|
+
Math.min((currentPage + 1) * currentPageSize, totalItems),
|
|
93
89
|
' ',
|
|
94
90
|
paginatedListTranslations.of[locale],
|
|
95
91
|
" ",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
3
|
+
export interface DateFilterProps extends DatePickerProps {
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
parseUrlParam?: (param: string) => string;
|
|
7
|
+
formatUrlParam?: (param: string) => string;
|
|
8
|
+
}
|
|
9
|
+
declare const DateFilter: ({ name, label, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }: DateFilterProps) => React.JSX.Element;
|
|
10
|
+
export default DateFilter;
|
|
11
|
+
//# sourceMappingURL=DateFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateFilter.d.ts","sourceRoot":"","sources":["../../../src/components/filters/DateFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,OAAO,EAAc,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAI7E,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AAED,QAAA,MAAM,UAAU,GAAI,6EAOjB,eAAe,sBAyCjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Controller, useFormContext } from 'react-hook-form';
|
|
3
|
+
import { it } from 'date-fns/locale/it';
|
|
4
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
5
|
+
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
6
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
7
|
+
import { useFormattedQueryState } from '../../utils/hooks/useFormattedQueryState';
|
|
8
|
+
const DateFilter = ({ name, label, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }) => {
|
|
9
|
+
const { control, watch, setValue } = useFormContext();
|
|
10
|
+
const [urlValue, setUrlValue] = useFormattedQueryState(name, {
|
|
11
|
+
defaultValue: defaultValue?.toISOString() || '',
|
|
12
|
+
parseUrlParam,
|
|
13
|
+
formatUrlParam,
|
|
14
|
+
});
|
|
15
|
+
const formValue = watch(name);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (formValue !== undefined) {
|
|
18
|
+
setUrlValue(formValue?.toISOString());
|
|
19
|
+
}
|
|
20
|
+
}, [JSON.stringify(formValue)]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (urlValue) {
|
|
23
|
+
setValue(name, new Date(urlValue));
|
|
24
|
+
}
|
|
25
|
+
}, [urlValue]);
|
|
26
|
+
return (React.createElement(Controller, { name: name, control: control, defaultValue: urlValue ? new Date(urlValue) : null, render: ({ field }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterDateFns, adapterLocale: it },
|
|
27
|
+
React.createElement(DatePicker, { ...field, label: label || name, slotProps: { field: { clearable: true } }, sx: { width: '100%' }, ...otherProps }))) }));
|
|
28
|
+
};
|
|
29
|
+
export default DateFilter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FilterFormProps {
|
|
3
|
+
onChange?: (filters: {
|
|
4
|
+
[name: string]: string | string[];
|
|
5
|
+
}) => void;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare const FilterForm: ({ onChange, children }: FilterFormProps) => React.JSX.Element;
|
|
9
|
+
export default FilterForm;
|
|
10
|
+
//# sourceMappingURL=FilterForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterForm.d.ts","sourceRoot":"","sources":["../../../src/components/filters/FilterForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAGzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IACpE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,QAAA,MAAM,UAAU,GAAI,wBAAwB,eAAe,sBAe1D,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { FormProvider, useForm } from 'react-hook-form';
|
|
3
|
+
const FilterForm = ({ onChange, children }) => {
|
|
4
|
+
const methods = useForm();
|
|
5
|
+
const values = methods.watch();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (onChange) {
|
|
8
|
+
// Remove empty strings from values
|
|
9
|
+
const filteredValues = Object.fromEntries(Object.entries(values).filter(([_, v]) => v != null && v != ''));
|
|
10
|
+
onChange(filteredValues);
|
|
11
|
+
}
|
|
12
|
+
}, [JSON.stringify(values)]);
|
|
13
|
+
return React.createElement(FormProvider, { ...methods }, children);
|
|
14
|
+
};
|
|
15
|
+
export default FilterForm;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface NumberFilterProps extends TextFieldProps<'outlined'> {
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
defaultValue?: number;
|
|
7
|
+
parseUrlParam: (param: string) => string;
|
|
8
|
+
formatUrlParam: (param: string) => string;
|
|
9
|
+
}
|
|
10
|
+
declare const NumberFilter: ({ name, label, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }: NumberFilterProps) => React.JSX.Element;
|
|
11
|
+
export default NumberFilter;
|
|
12
|
+
//# sourceMappingURL=NumberFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberFilter.d.ts","sourceRoot":"","sources":["../../../src/components/filters/NumberFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,MAAM,WAAW,iBAAkB,SAAQ,cAAc,CAAC,UAAU,CAAC;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C;AAED,QAAA,MAAM,YAAY,GAAI,6EAOnB,iBAAiB,sBAyCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TextField } from '@mui/material';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { Controller, useFormContext } from 'react-hook-form';
|
|
4
|
+
import { useFormattedQueryState } from '../../utils/hooks/useFormattedQueryState';
|
|
5
|
+
const NumberFilter = ({ name, label, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }) => {
|
|
6
|
+
const { control, watch, setValue } = useFormContext();
|
|
7
|
+
const [urlValue, setUrlValue] = useFormattedQueryState(name, {
|
|
8
|
+
defaultValue: defaultValue?.toString() || '',
|
|
9
|
+
parseUrlParam,
|
|
10
|
+
formatUrlParam,
|
|
11
|
+
});
|
|
12
|
+
const formValue = watch(name);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (formValue !== undefined) {
|
|
15
|
+
console.log(typeof formValue);
|
|
16
|
+
setUrlValue(formValue);
|
|
17
|
+
}
|
|
18
|
+
}, [JSON.stringify(formValue)]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (urlValue) {
|
|
21
|
+
setValue(name, urlValue);
|
|
22
|
+
}
|
|
23
|
+
}, [urlValue]);
|
|
24
|
+
return (React.createElement(Controller, { name: name, control: control, defaultValue: urlValue, render: ({ field }) => (React.createElement(TextField, { type: 'number', onWheel: (e) => e.preventDefault(), ...field, label: label || name, sx: { width: '100%' }, ...otherProps })) }));
|
|
25
|
+
};
|
|
26
|
+
export default NumberFilter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SelectProps, FormControlProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface SelectOption {
|
|
4
|
+
value: string | number;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export type SelectFilterProps = FormControlProps & {
|
|
8
|
+
name: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
/** Allow multiple values to be selected; in the URL values will be concatenated separated by commas */
|
|
12
|
+
options?: SelectOption[];
|
|
13
|
+
multiple?: boolean;
|
|
14
|
+
selectProps?: SelectProps<string>;
|
|
15
|
+
parseUrlParam: (param: string) => string;
|
|
16
|
+
formatUrlParam: (param: string) => string;
|
|
17
|
+
};
|
|
18
|
+
declare const SelectFilter: ({ name, label, options, multiple, selectProps, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }: SelectFilterProps) => React.JSX.Element;
|
|
19
|
+
export default SelectFilter;
|
|
20
|
+
//# sourceMappingURL=SelectFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectFilter.d.ts","sourceRoot":"","sources":["../../../src/components/filters/SelectFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uGAAuG;IACvG,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,6GAUnB,iBAAiB,sBA0DnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FormControl, InputLabel, MenuItem, Select, } from '@mui/material';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { Controller, useFormContext } from 'react-hook-form';
|
|
4
|
+
import { useFormattedQueryState } from '../../utils/hooks/useFormattedQueryState';
|
|
5
|
+
const SelectFilter = ({ name, label, options, multiple, selectProps, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }) => {
|
|
6
|
+
const { control, watch, setValue } = useFormContext();
|
|
7
|
+
const [urlValue, setUrlValue] = useFormattedQueryState(name, {
|
|
8
|
+
defaultValue: defaultValue?.toString() || '',
|
|
9
|
+
parseUrlParam,
|
|
10
|
+
formatUrlParam,
|
|
11
|
+
});
|
|
12
|
+
const formValue = watch(name);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (formValue !== undefined) {
|
|
15
|
+
if (multiple) {
|
|
16
|
+
setUrlValue(formValue.join(','));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
setUrlValue(formValue);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}, [JSON.stringify(formValue)]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (urlValue) {
|
|
25
|
+
if (multiple) {
|
|
26
|
+
setValue(name, urlValue.split(','));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
setValue(name, urlValue);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, [urlValue]);
|
|
33
|
+
return (React.createElement(Controller, { name: name, control: control, defaultValue: multiple ? urlValue.split(',') : urlValue, render: ({ field }) => (React.createElement(FormControl, { sx: { width: '100%' }, ...otherProps },
|
|
34
|
+
React.createElement(InputLabel, null, label || name),
|
|
35
|
+
React.createElement(Select, { label: label || name, multiple: multiple, ...selectProps, ...field },
|
|
36
|
+
!multiple && (React.createElement(MenuItem, { value: '' },
|
|
37
|
+
React.createElement("em", null, "-"))),
|
|
38
|
+
options?.map((option) => (React.createElement(MenuItem, { value: option.value }, label)))))) }));
|
|
39
|
+
};
|
|
40
|
+
export default SelectFilter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface TextFilterProps extends TextFieldProps<'outlined'> {
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
parseUrlParam: (param: string) => string;
|
|
8
|
+
formatUrlParam: (param: string) => string;
|
|
9
|
+
}
|
|
10
|
+
declare const TextFilter: ({ name, label, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }: TextFilterProps) => React.JSX.Element;
|
|
11
|
+
export default TextFilter;
|
|
12
|
+
//# sourceMappingURL=TextFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextFilter.d.ts","sourceRoot":"","sources":["../../../src/components/filters/TextFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,UAAU,CAAC;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C;AAED,QAAA,MAAM,UAAU,GAAI,6EAOjB,eAAe,sBAsCjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TextField } from '@mui/material';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { Controller, useFormContext } from 'react-hook-form';
|
|
4
|
+
import { useFormattedQueryState } from '../../utils/hooks/useFormattedQueryState';
|
|
5
|
+
const TextFilter = ({ name, label, parseUrlParam, formatUrlParam, defaultValue, ...otherProps }) => {
|
|
6
|
+
const { control, watch, setValue } = useFormContext();
|
|
7
|
+
const [urlValue, setUrlValue] = useFormattedQueryState(name, {
|
|
8
|
+
defaultValue: defaultValue?.toString() || '',
|
|
9
|
+
parseUrlParam,
|
|
10
|
+
formatUrlParam,
|
|
11
|
+
});
|
|
12
|
+
const formValue = watch(name);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (formValue !== undefined) {
|
|
15
|
+
setUrlValue(formValue);
|
|
16
|
+
}
|
|
17
|
+
}, [JSON.stringify(formValue)]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (urlValue) {
|
|
20
|
+
setValue(name, urlValue);
|
|
21
|
+
}
|
|
22
|
+
}, [urlValue]);
|
|
23
|
+
return (React.createElement(Controller, { name: name, control: control, defaultValue: urlValue, render: ({ field }) => (React.createElement(TextField, { ...field, label: label || name, sx: { width: '100%' }, ...otherProps })) }));
|
|
24
|
+
};
|
|
25
|
+
export default TextFilter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as DateFilter } from './DateFilter';
|
|
2
|
+
export type { DateFilterProps } from './DateFilter';
|
|
3
|
+
export { default as NumberFilter } from './NumberFilter';
|
|
4
|
+
export type { NumberFilterProps } from './NumberFilter';
|
|
5
|
+
export { default as SelectFilter } from './SelectFilter';
|
|
6
|
+
export type { SelectOption, SelectFilterProps } from './SelectFilter';
|
|
7
|
+
export { default as TextFilter } from './TextFilter';
|
|
8
|
+
export type { TextFilterProps } from './TextFilter';
|
|
9
|
+
export { default as FilterForm } from './FilterForm';
|
|
10
|
+
export type { FilterFormProps } from './FilterForm';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/filters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as DateFilter } from './DateFilter';
|
|
2
|
+
export { default as NumberFilter } from './NumberFilter';
|
|
3
|
+
export { default as SelectFilter } from './SelectFilter';
|
|
4
|
+
export { default as TextFilter } from './TextFilter';
|
|
5
|
+
export { default as FilterForm } from './FilterForm';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../src/components/i18n/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../src/components/i18n/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,cAAc,CAAC,OAAO,QAAQ,CAAC,EAC/B,QAAQ,CACT;IACC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,IAAI,GAAI,iCAAiC,SAAS,sBAiBvD,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type
|
|
3
|
-
export
|
|
4
|
-
export type
|
|
5
|
-
export
|
|
6
|
-
export type
|
|
7
|
-
export
|
|
8
|
-
export type
|
|
9
|
-
export
|
|
10
|
-
export type
|
|
11
|
-
export
|
|
12
|
-
export type
|
|
1
|
+
export * from './buttons';
|
|
2
|
+
export type * from './buttons';
|
|
3
|
+
export * from './display';
|
|
4
|
+
export type * from './display';
|
|
5
|
+
export * from './filters';
|
|
6
|
+
export type * from './filters';
|
|
7
|
+
export * from './i18n';
|
|
8
|
+
export type * from './i18n';
|
|
9
|
+
export * from './layout';
|
|
10
|
+
export type * from './layout';
|
|
11
|
+
export * from './progress';
|
|
12
|
+
export type * from './progress';
|
|
13
|
+
export * from './provider';
|
|
14
|
+
export type * from './provider';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,mBAAmB,WAAW,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,mBAAmB,WAAW,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,mBAAmB,WAAW,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,mBAAmB,QAAQ,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,mBAAmB,UAAU,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,mBAAmB,YAAY,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,mBAAmB,YAAY,CAAC"}
|
package/lib/components/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export * from './buttons';
|
|
2
|
+
export * from './display';
|
|
3
|
+
export * from './filters';
|
|
4
|
+
export * from './i18n';
|
|
5
|
+
export * from './layout';
|
|
6
|
+
export * from './progress';
|
|
7
|
+
export * from './provider';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserInfoProvider.d.ts","sourceRoot":"","sources":["../../../src/components/provider/UserInfoProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"UserInfoProvider.d.ts","sourceRoot":"","sources":["../../../src/components/provider/UserInfoProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AASD,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,QAAA,MAAM,gBAAgB,GAAI,qCAIvB,qBAAqB,sBAcvB,CAAC;AAEF,eAAO,MAAM,WAAW,4BAAoC,CAAC;AAE7D,eAAe,gBAAgB,CAAC"}
|
|
@@ -3,10 +3,8 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
3
3
|
import { createContext, useContext } from 'react';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
const getUserInfo = async (url = '/oauth2/userinfo') => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
return await fetch;
|
|
6
|
+
const response = await axios.get(url);
|
|
7
|
+
return response.data;
|
|
10
8
|
};
|
|
11
9
|
const UserInfoContext = createContext(undefined);
|
|
12
10
|
const UserInfoProvider = ({ url, defaultUserInfo, children, }) => {
|
|
@@ -14,6 +12,9 @@ const UserInfoProvider = ({ url, defaultUserInfo, children, }) => {
|
|
|
14
12
|
queryKey: ['user-info'],
|
|
15
13
|
queryFn: () => getUserInfo(url),
|
|
16
14
|
staleTime: Infinity,
|
|
15
|
+
retry: (failureCount, error) => {
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
17
18
|
});
|
|
18
19
|
return (React.createElement(UserInfoContext.Provider, { value: userInfo || defaultUserInfo }, children));
|
|
19
20
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type
|
|
3
|
-
export
|
|
4
|
-
export type
|
|
5
|
-
export
|
|
1
|
+
export * from './components';
|
|
2
|
+
export type * from './components';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export type * from './types';
|
|
5
|
+
export * from './utils';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,mBAAmB,cAAc,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,mBAAmB,SAAS,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './utils';
|