datastake-daf 0.6.237 → 0.6.239
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/index.js
CHANGED
|
@@ -12642,6 +12642,15 @@ function Loading(_ref) {
|
|
|
12642
12642
|
const {
|
|
12643
12643
|
Paragraph: Paragraph$1
|
|
12644
12644
|
} = antd.Typography;
|
|
12645
|
+
const checkHasActiveFilterValues = filtersConfig => {
|
|
12646
|
+
if (!(filtersConfig !== null && filtersConfig !== void 0 && filtersConfig.filtersConfig) || !(filtersConfig !== null && filtersConfig !== void 0 && filtersConfig.selectedFilters)) return false;
|
|
12647
|
+
const filterConfigKeys = Object.keys(filtersConfig.filtersConfig);
|
|
12648
|
+
const selectedFilters = filtersConfig.selectedFilters;
|
|
12649
|
+
return filterConfigKeys.some(key => {
|
|
12650
|
+
const value = selectedFilters[key];
|
|
12651
|
+
return value !== undefined && value !== null && value !== '';
|
|
12652
|
+
});
|
|
12653
|
+
};
|
|
12645
12654
|
const useHeader = _ref => {
|
|
12646
12655
|
let {
|
|
12647
12656
|
title = '',
|
|
@@ -12663,7 +12672,14 @@ const useHeader = _ref => {
|
|
|
12663
12672
|
isViewMode = false,
|
|
12664
12673
|
filtersConfig = {}
|
|
12665
12674
|
} = _ref;
|
|
12675
|
+
const hasActiveFilterValues = React.useMemo(() => checkHasActiveFilterValues(filtersConfig), [filtersConfig === null || filtersConfig === void 0 ? void 0 : filtersConfig.filtersConfig, filtersConfig === null || filtersConfig === void 0 ? void 0 : filtersConfig.selectedFilters]);
|
|
12676
|
+
const [showFilters, setShowFilters] = React.useState(() => checkHasActiveFilterValues(filtersConfig));
|
|
12666
12677
|
const hasFilters = filtersConfig && Object.keys(filtersConfig).length > 0;
|
|
12678
|
+
React.useEffect(() => {
|
|
12679
|
+
if (hasActiveFilterValues) {
|
|
12680
|
+
setShowFilters(true);
|
|
12681
|
+
}
|
|
12682
|
+
}, [hasActiveFilterValues]);
|
|
12667
12683
|
const downloadButtonAction = app && app === 'sbg' && isViewMode ? null : {
|
|
12668
12684
|
onClick: onDownload,
|
|
12669
12685
|
disabled: downloadDisabled,
|
|
@@ -12689,7 +12705,7 @@ const useHeader = _ref => {
|
|
|
12689
12705
|
noMinWidth: true,
|
|
12690
12706
|
squareIconButton: true,
|
|
12691
12707
|
onClick: () => {
|
|
12692
|
-
|
|
12708
|
+
setShowFilters(p => !p);
|
|
12693
12709
|
}
|
|
12694
12710
|
}];
|
|
12695
12711
|
const actionButtons = onDownload && _actionButtons.length < 3 ? [..._actionButtons, ...(hasFilters ? filterButton : []), downloadButton] : [..._actionButtons, ...(hasFilters ? filterButton : [])];
|
|
@@ -12835,10 +12851,10 @@ const useHeader = _ref => {
|
|
|
12835
12851
|
children: hasFilters && /*#__PURE__*/jsxRuntime.jsx(SelectFilters, {
|
|
12836
12852
|
t: filtersConfig.t,
|
|
12837
12853
|
apiUrl: filtersConfig.apiUrl,
|
|
12838
|
-
showFilters:
|
|
12854
|
+
showFilters: showFilters,
|
|
12839
12855
|
onApply: filtersConfig.onApply,
|
|
12840
12856
|
options: filtersConfig.options,
|
|
12841
|
-
setShowFilters:
|
|
12857
|
+
setShowFilters: setShowFilters,
|
|
12842
12858
|
language: filtersConfig.language,
|
|
12843
12859
|
type: filtersConfig.type,
|
|
12844
12860
|
filtersConfig: filtersConfig.filtersConfig,
|
package/package.json
CHANGED
|
@@ -11,6 +11,18 @@ import SelectFilters from '../Filters/selectFilters/index.jsx'
|
|
|
11
11
|
|
|
12
12
|
const { Paragraph } = Typography
|
|
13
13
|
|
|
14
|
+
const checkHasActiveFilterValues = (filtersConfig) => {
|
|
15
|
+
if (!filtersConfig?.filtersConfig || !filtersConfig?.selectedFilters) return false;
|
|
16
|
+
|
|
17
|
+
const filterConfigKeys = Object.keys(filtersConfig.filtersConfig);
|
|
18
|
+
const selectedFilters = filtersConfig.selectedFilters;
|
|
19
|
+
|
|
20
|
+
return filterConfigKeys.some(key => {
|
|
21
|
+
const value = selectedFilters[key];
|
|
22
|
+
return value !== undefined && value !== null && value !== '';
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
14
26
|
export const useHeader = ({
|
|
15
27
|
title = '',
|
|
16
28
|
tooltip = '',
|
|
@@ -31,7 +43,16 @@ export const useHeader = ({
|
|
|
31
43
|
isViewMode = false,
|
|
32
44
|
filtersConfig = {},
|
|
33
45
|
}) => {
|
|
46
|
+
const hasActiveFilterValues = useMemo(() => checkHasActiveFilterValues(filtersConfig), [filtersConfig?.filtersConfig, filtersConfig?.selectedFilters]);
|
|
47
|
+
|
|
48
|
+
const [showFilters, setShowFilters] = useState(() => checkHasActiveFilterValues(filtersConfig))
|
|
34
49
|
const hasFilters = filtersConfig && Object.keys(filtersConfig).length > 0
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (hasActiveFilterValues) {
|
|
53
|
+
setShowFilters(true);
|
|
54
|
+
}
|
|
55
|
+
}, [hasActiveFilterValues]);
|
|
35
56
|
const downloadButtonAction = app && app === 'sbg' && isViewMode ? null : {
|
|
36
57
|
onClick: onDownload,
|
|
37
58
|
disabled: downloadDisabled,
|
|
@@ -54,7 +75,7 @@ export const useHeader = ({
|
|
|
54
75
|
noMinWidth: true,
|
|
55
76
|
squareIconButton: true,
|
|
56
77
|
onClick: () => {
|
|
57
|
-
|
|
78
|
+
setShowFilters((p) => !p)
|
|
58
79
|
}
|
|
59
80
|
}]
|
|
60
81
|
|
|
@@ -212,10 +233,10 @@ export const useHeader = ({
|
|
|
212
233
|
<SelectFilters
|
|
213
234
|
t={filtersConfig.t}
|
|
214
235
|
apiUrl={filtersConfig.apiUrl}
|
|
215
|
-
showFilters={
|
|
236
|
+
showFilters={showFilters}
|
|
216
237
|
onApply={filtersConfig.onApply}
|
|
217
238
|
options={filtersConfig.options}
|
|
218
|
-
setShowFilters={
|
|
239
|
+
setShowFilters={setShowFilters}
|
|
219
240
|
language={filtersConfig.language}
|
|
220
241
|
type={filtersConfig.type}
|
|
221
242
|
filtersConfig={filtersConfig.filtersConfig}
|