@applica-software-guru/react-admin 1.5.303 → 1.5.304
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/ra-inputs/LabeledInput.d.ts +1 -0
- package/dist/components/ra-inputs/LabeledInput.d.ts.map +1 -1
- package/dist/components/ra-lists/FilterSidebar/FilterSidebarContext.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +26 -26
- package/dist/react-admin.cjs.js.gz +0 -0
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +215 -214
- package/dist/react-admin.es.js.gz +0 -0
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +7 -7
- package/dist/react-admin.umd.js.gz +0 -0
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-inputs/LabeledInput.tsx +3 -1
- package/src/components/ra-lists/FilterSidebar/ActiveFiltersChips.tsx +1 -1
- package/src/components/ra-lists/FilterSidebar/FilterSidebar.tsx +1 -1
- package/src/components/ra-lists/FilterSidebar/FilterSidebarContext.tsx +15 -12
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ function LabeledInput({
|
|
|
16
16
|
}: LabeledInputProps): JSX.Element {
|
|
17
17
|
const theme = useTheme();
|
|
18
18
|
const { getCurrentDialog } = useAppConfig();
|
|
19
|
-
const { source, resource, isRequired } = props;
|
|
19
|
+
const { source, resource, isRequired, chip } = props;
|
|
20
20
|
const {
|
|
21
21
|
fieldState: { invalid }
|
|
22
22
|
} = useInput(props);
|
|
@@ -60,6 +60,7 @@ function LabeledInput({
|
|
|
60
60
|
// @ts-ignore
|
|
61
61
|
...children.props,
|
|
62
62
|
...props,
|
|
63
|
+
chip: chip && typeof chip === 'function' ? React.createElement(chip) : chip,
|
|
63
64
|
label: display === 'legend' ? label : false
|
|
64
65
|
})
|
|
65
66
|
: children}
|
|
@@ -90,6 +91,7 @@ type LabeledInputProps = InputProps & {
|
|
|
90
91
|
display?: 'legend' | 'label';
|
|
91
92
|
helperText?: string | boolean | React.ReactElement | null;
|
|
92
93
|
divider?: boolean;
|
|
94
|
+
chip?: any;
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
export { LabeledInput };
|
|
@@ -27,7 +27,7 @@ function FiltersInput(props: FiltersInputProps): ReactElement {
|
|
|
27
27
|
? (Array.isArray(filters) ? filters : [filters]).map((filter: ReactElement, i) => {
|
|
28
28
|
const props = { ...filter.props, display: 'label' };
|
|
29
29
|
return React.isValidElement(filter) ? (
|
|
30
|
-
<Box key={i}
|
|
30
|
+
<Box key={i} mb={1}>
|
|
31
31
|
{React.cloneElement(filter, { ...props, resource })}
|
|
32
32
|
</Box>
|
|
33
33
|
) : null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo } from 'react';
|
|
2
2
|
import { FilterContext, useResourceContext } from 'react-admin';
|
|
3
|
+
import { isFunction } from 'lodash';
|
|
3
4
|
|
|
4
5
|
interface FiltersContextType {
|
|
5
6
|
hasFilterSidebar?: boolean;
|
|
@@ -30,24 +31,26 @@ function useGetChipValue({ source, value }: ChipItemProps): JSX.Element | null {
|
|
|
30
31
|
[currentSourceFilter]
|
|
31
32
|
);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!ChipComponent) {
|
|
34
|
+
if (!currentSourceFilterProps?.chip) {
|
|
36
35
|
throw new Error(
|
|
37
36
|
`No chip component found for filter source "${source}". Ensure your filter components define a 'chip' prop.`
|
|
38
37
|
);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const chipProps = {
|
|
41
|
+
...currentSourceFilterProps,
|
|
42
|
+
record: { [source]: value },
|
|
43
|
+
value,
|
|
44
|
+
resource
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const Chip = React.isValidElement(currentSourceFilterProps.chip)
|
|
48
|
+
? React.cloneElement(currentSourceFilterProps.chip, chipProps)
|
|
49
|
+
: isFunction(currentSourceFilterProps.chip)
|
|
50
|
+
? React.createElement(currentSourceFilterProps.chip, chipProps)
|
|
51
|
+
: null;
|
|
49
52
|
|
|
50
|
-
return
|
|
53
|
+
return Chip;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export { FilterSidebarContext, useGetChipValue, useIsEnabledSidebarFilter };
|