@bitrise/bitkit 13.10.1-alpha.1 → 13.12.0
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/package.json
CHANGED
|
@@ -24,6 +24,7 @@ import FilterSwitchAdapter from './FilterSwitchAdapter/FilterSwitchAdapter';
|
|
|
24
24
|
|
|
25
25
|
export interface FilterProps extends Omit<BoxProps, 'onChange'> {
|
|
26
26
|
data: FilterData;
|
|
27
|
+
defaultState?: FilterState;
|
|
27
28
|
filtersDependOn?: string[];
|
|
28
29
|
isLoading?: boolean;
|
|
29
30
|
onChange: (state: FilterState) => void;
|
|
@@ -36,6 +37,7 @@ export interface FilterProps extends Omit<BoxProps, 'onChange'> {
|
|
|
36
37
|
const Filter = (props: FilterProps) => {
|
|
37
38
|
const {
|
|
38
39
|
data,
|
|
40
|
+
defaultState,
|
|
39
41
|
filtersDependOn,
|
|
40
42
|
isLoading,
|
|
41
43
|
onChange,
|
|
@@ -59,7 +61,7 @@ const Filter = (props: FilterProps) => {
|
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
|
|
62
|
-
const
|
|
64
|
+
const stateToRestore = useRef<FilterState>(defaultState || cleanState);
|
|
63
65
|
|
|
64
66
|
const [isPopoverOpen, setPopoverOpen] = useState<boolean>(false);
|
|
65
67
|
|
|
@@ -97,7 +99,7 @@ const Filter = (props: FilterProps) => {
|
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
const onClearFilters = () => {
|
|
100
|
-
onChange(
|
|
102
|
+
onChange(stateToRestore.current || {});
|
|
101
103
|
};
|
|
102
104
|
|
|
103
105
|
const filters = {
|
|
@@ -112,7 +114,7 @@ const Filter = (props: FilterProps) => {
|
|
|
112
114
|
filters[value.type || 'tag'][category] = value;
|
|
113
115
|
});
|
|
114
116
|
|
|
115
|
-
const showClearFilters = !isEqual(
|
|
117
|
+
const showClearFilters = !isEqual(stateToRestore.current, state);
|
|
116
118
|
|
|
117
119
|
const contextValue: FilterContextType = useMemo(
|
|
118
120
|
() => ({
|