@bigbinary/neeto-filters-frontend 3.0.11 → 3.0.13
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.cjs.js +87 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +89 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import { capitalize, removeBy, findBy, isNotEmpty, humanize, hyphenate, noop as
|
|
|
5
5
|
import { useHotKeys, useMutationWithInvalidation, useQueryParams, useDebounce, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
6
6
|
import { getQueryParams, dateFormat, buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
|
|
7
7
|
import { Tooltip, Typography, Dropdown as Dropdown$2, Button, Pane as Pane$1, Alert, Select, DatePicker, TimePicker, Input as Input$1, Accordion, Spinner } from '@bigbinary/neetoui';
|
|
8
|
-
import { groupBy, anyPass, isNil, isEmpty, any, toLower, mergeLeft, identity, omit, mergeRight, toPairs, not, pluck, either, has, concat, equals, pick, modify, prop, isNotNil, append, last } from 'ramda';
|
|
8
|
+
import { groupBy, anyPass, isNil, isEmpty, any, toLower, mergeLeft, identity, omit, mergeRight, toPairs, not, pluck, either, has, concat, equals, pick, modify, prop, isNotNil, append, last, mergeDeepRight } from 'ramda';
|
|
9
9
|
import { useTranslation, Trans } from 'react-i18next';
|
|
10
10
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
11
|
-
import { Close, MenuHorizontal, Down, Settings } from '@bigbinary/neeto-icons';
|
|
11
|
+
import { Help, Close, MenuHorizontal, Down, Settings } from '@bigbinary/neeto-icons';
|
|
12
12
|
import { Form, Input, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
13
13
|
import { useQuery } from 'react-query';
|
|
14
14
|
import axios from 'axios';
|
|
@@ -249,6 +249,12 @@ var DEFAULT_BOOLEAN_OPTIONS = [{
|
|
|
249
249
|
label: t$1("neetoFilters.common.no"),
|
|
250
250
|
value: "false"
|
|
251
251
|
}];
|
|
252
|
+
var DEFAULT_HELP_ICON_PROPS = {
|
|
253
|
+
icon: Help,
|
|
254
|
+
tooltipProps: {
|
|
255
|
+
position: "right"
|
|
256
|
+
}
|
|
257
|
+
};
|
|
252
258
|
|
|
253
259
|
function _arrayWithHoles(arr) {
|
|
254
260
|
if (Array.isArray(arr)) return arr;
|
|
@@ -2564,12 +2570,11 @@ var findDateOption = function findDateOption(filter, options) {
|
|
|
2564
2570
|
var currentMoment = dayjs();
|
|
2565
2571
|
var diffWithStart = Math.abs(currentMoment.diff(dayjs(value[0]), "year"));
|
|
2566
2572
|
var diffWithEnd = Math.abs(currentMoment.diff(dayjs(value[1]), "year"));
|
|
2567
|
-
|
|
2573
|
+
return diffWithStart < diffWithEnd ? findBy({
|
|
2568
2574
|
value: "after"
|
|
2569
2575
|
}, options) : findBy({
|
|
2570
2576
|
value: "before"
|
|
2571
2577
|
}, options);
|
|
2572
|
-
return returnOption;
|
|
2573
2578
|
};
|
|
2574
2579
|
var buildDateValues = function buildDateValues(dates, selectedRule) {
|
|
2575
2580
|
if (selectedRule.value === "after") {
|
|
@@ -2579,6 +2584,9 @@ var buildDateValues = function buildDateValues(dates, selectedRule) {
|
|
|
2579
2584
|
}
|
|
2580
2585
|
return dates;
|
|
2581
2586
|
};
|
|
2587
|
+
var buildHelpIconProps = function buildHelpIconProps(helpIconProps) {
|
|
2588
|
+
return mergeDeepRight(DEFAULT_HELP_ICON_PROPS, helpIconProps);
|
|
2589
|
+
};
|
|
2582
2590
|
|
|
2583
2591
|
var Boolean = function Boolean(_ref) {
|
|
2584
2592
|
var column = _ref.column,
|
|
@@ -2589,7 +2597,9 @@ var Boolean = function Boolean(_ref) {
|
|
|
2589
2597
|
_column$defaultType = column.defaultType,
|
|
2590
2598
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
2591
2599
|
label = column.label,
|
|
2592
|
-
values = column.values
|
|
2600
|
+
values = column.values,
|
|
2601
|
+
_column$helpIconProps = column.helpIconProps,
|
|
2602
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
2593
2603
|
var options = isNil(values) || isEmpty(values) ? DEFAULT_BOOLEAN_OPTIONS : values;
|
|
2594
2604
|
var otherProps = getOtherProps(column);
|
|
2595
2605
|
var value = buildDropdownValue({
|
|
@@ -2618,7 +2628,12 @@ var Boolean = function Boolean(_ref) {
|
|
|
2618
2628
|
label: label,
|
|
2619
2629
|
options: options,
|
|
2620
2630
|
value: value,
|
|
2621
|
-
isClearable: true
|
|
2631
|
+
isClearable: true
|
|
2632
|
+
}, isNotEmpty(helpIconProps) && {
|
|
2633
|
+
labelProps: {
|
|
2634
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
2635
|
+
}
|
|
2636
|
+
}, {
|
|
2622
2637
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-filter"),
|
|
2623
2638
|
strategy: "fixed",
|
|
2624
2639
|
placeholder: t("neetoFilters.messages.selectOption", {
|
|
@@ -2643,7 +2658,9 @@ var Datetime = function Datetime(_ref) {
|
|
|
2643
2658
|
var key = column.key,
|
|
2644
2659
|
_column$defaultType = column.defaultType,
|
|
2645
2660
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
2646
|
-
label = column.label
|
|
2661
|
+
label = column.label,
|
|
2662
|
+
_column$helpIconProps = column.helpIconProps,
|
|
2663
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
2647
2664
|
var isDatePickerShown = filter && isCustomDateRange(filter.value);
|
|
2648
2665
|
var otherProps = getOtherProps(column);
|
|
2649
2666
|
var handleChange = function handleChange(option) {
|
|
@@ -2686,7 +2703,7 @@ var Datetime = function Datetime(_ref) {
|
|
|
2686
2703
|
}, [filter]);
|
|
2687
2704
|
return /*#__PURE__*/React.createElement("div", {
|
|
2688
2705
|
className: "neeto-filters-pane-filter__item-wrapper"
|
|
2689
|
-
}, /*#__PURE__*/React.createElement(Select, {
|
|
2706
|
+
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
2690
2707
|
autoFocus: autoFocus,
|
|
2691
2708
|
label: label,
|
|
2692
2709
|
isClearable: true,
|
|
@@ -2696,9 +2713,14 @@ var Datetime = function Datetime(_ref) {
|
|
|
2696
2713
|
value: selectedRule,
|
|
2697
2714
|
placeholder: t("neetoFilters.messages.selectResource", {
|
|
2698
2715
|
resource: label
|
|
2699
|
-
})
|
|
2716
|
+
})
|
|
2717
|
+
}, isNotEmpty(helpIconProps) && {
|
|
2718
|
+
labelProps: {
|
|
2719
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
2720
|
+
}
|
|
2721
|
+
}, {
|
|
2700
2722
|
onChange: handleChange
|
|
2701
|
-
}), isDatePickerShown && /*#__PURE__*/React.createElement(DatePicker, _extends({
|
|
2723
|
+
})), isDatePickerShown && /*#__PURE__*/React.createElement(DatePicker, _extends({
|
|
2702
2724
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-date-range"),
|
|
2703
2725
|
getPopupContainer: prop("parentNode"),
|
|
2704
2726
|
type: (selectedRule === null || selectedRule === void 0 ? void 0 : selectedRule.value) === "custom-date-range" ? "range" : "date",
|
|
@@ -2720,7 +2742,9 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2720
2742
|
_column$defaultType = column.defaultType,
|
|
2721
2743
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
2722
2744
|
_column$isClearable = column.isClearable,
|
|
2723
|
-
isClearable = _column$isClearable === void 0 ? true : _column$isClearable
|
|
2745
|
+
isClearable = _column$isClearable === void 0 ? true : _column$isClearable,
|
|
2746
|
+
_column$helpIconProps = column.helpIconProps,
|
|
2747
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
2724
2748
|
var otherProps = getOtherProps(column);
|
|
2725
2749
|
var options = buildDropdownOptions({
|
|
2726
2750
|
defaultType: defaultType,
|
|
@@ -2759,7 +2783,12 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
2759
2783
|
strategy: "fixed",
|
|
2760
2784
|
placeholder: t("neetoFilters.messages.selectResource", {
|
|
2761
2785
|
resource: label
|
|
2762
|
-
})
|
|
2786
|
+
})
|
|
2787
|
+
}, isNotEmpty(helpIconProps) && {
|
|
2788
|
+
labelProps: {
|
|
2789
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
2790
|
+
}
|
|
2791
|
+
}, {
|
|
2763
2792
|
onChange: handleChange
|
|
2764
2793
|
}, otherProps));
|
|
2765
2794
|
};
|
|
@@ -2782,7 +2811,9 @@ var SingleDatetime = function SingleDatetime(_ref) {
|
|
|
2782
2811
|
var key = column.key,
|
|
2783
2812
|
_column$defaultType = column.defaultType,
|
|
2784
2813
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
2785
|
-
label = column.label
|
|
2814
|
+
label = column.label,
|
|
2815
|
+
_column$helpIconProps = column.helpIconProps,
|
|
2816
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
2786
2817
|
var otherProps = getOtherProps(column);
|
|
2787
2818
|
var datePickerType = selectedRule.value === "between" ? "range" : "date";
|
|
2788
2819
|
var value = filter === null || filter === void 0 ? void 0 : filter.value;
|
|
@@ -2830,15 +2861,20 @@ var SingleDatetime = function SingleDatetime(_ref) {
|
|
|
2830
2861
|
};
|
|
2831
2862
|
return /*#__PURE__*/React.createElement("div", {
|
|
2832
2863
|
className: "neeto-filters-pane-filter__item-wrapper"
|
|
2833
|
-
}, /*#__PURE__*/React.createElement(Select, {
|
|
2864
|
+
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
2834
2865
|
label: label,
|
|
2835
2866
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-filter-rule"),
|
|
2836
2867
|
defaultValue: SINGLE_DATE_OPTIONS[0],
|
|
2837
2868
|
options: SINGLE_DATE_OPTIONS,
|
|
2838
2869
|
strategy: "fixed",
|
|
2839
|
-
value: selectedRule
|
|
2870
|
+
value: selectedRule
|
|
2871
|
+
}, isNotEmpty(helpIconProps) && {
|
|
2872
|
+
labelProps: {
|
|
2873
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
2874
|
+
}
|
|
2875
|
+
}, {
|
|
2840
2876
|
onChange: handleRuleChange
|
|
2841
|
-
}), /*#__PURE__*/React.createElement(DatePicker, _extends({
|
|
2877
|
+
})), /*#__PURE__*/React.createElement(DatePicker, _extends({
|
|
2842
2878
|
autoFocus: autoFocus,
|
|
2843
2879
|
value: value,
|
|
2844
2880
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-filter"),
|
|
@@ -2865,7 +2901,9 @@ var SingleTime = function SingleTime(_ref) {
|
|
|
2865
2901
|
var key = column.key,
|
|
2866
2902
|
_column$defaultType = column.defaultType,
|
|
2867
2903
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
2868
|
-
label = column.label
|
|
2904
|
+
label = column.label,
|
|
2905
|
+
_column$helpIconProps = column.helpIconProps,
|
|
2906
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
2869
2907
|
var otherProps = getOtherProps(column);
|
|
2870
2908
|
var timePickerType = selectedRule.value === "between" ? "range" : "time";
|
|
2871
2909
|
var value = filter === null || filter === void 0 ? void 0 : filter.value;
|
|
@@ -2905,14 +2943,19 @@ var SingleTime = function SingleTime(_ref) {
|
|
|
2905
2943
|
};
|
|
2906
2944
|
return /*#__PURE__*/React.createElement("div", {
|
|
2907
2945
|
className: "neeto-filters-pane-filter__item-wrapper"
|
|
2908
|
-
}, /*#__PURE__*/React.createElement(Select, {
|
|
2946
|
+
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
2909
2947
|
label: label,
|
|
2910
2948
|
defaultValue: SINGLE_TIME_OPTIONS[0],
|
|
2911
2949
|
options: SINGLE_TIME_OPTIONS,
|
|
2912
2950
|
strategy: "fixed",
|
|
2913
|
-
value: selectedRule
|
|
2951
|
+
value: selectedRule
|
|
2952
|
+
}, isNotEmpty(helpIconProps) && {
|
|
2953
|
+
labelProps: {
|
|
2954
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
2955
|
+
}
|
|
2956
|
+
}, {
|
|
2914
2957
|
onChange: handleRuleChange
|
|
2915
|
-
}), /*#__PURE__*/React.createElement(TimePicker, _extends({
|
|
2958
|
+
})), /*#__PURE__*/React.createElement(TimePicker, _extends({
|
|
2916
2959
|
autoFocus: autoFocus,
|
|
2917
2960
|
value: value,
|
|
2918
2961
|
use12Hours: true,
|
|
@@ -2937,7 +2980,9 @@ var Text = function Text(_ref) {
|
|
|
2937
2980
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
2938
2981
|
label = column.label,
|
|
2939
2982
|
_column$showRuleSelec = column.showRuleSelector,
|
|
2940
|
-
showRuleSelector = _column$showRuleSelec === void 0 ? false : _column$showRuleSelec
|
|
2983
|
+
showRuleSelector = _column$showRuleSelec === void 0 ? false : _column$showRuleSelec,
|
|
2984
|
+
_column$helpIconProps = column.helpIconProps,
|
|
2985
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
2941
2986
|
var otherProps = getOtherProps(column);
|
|
2942
2987
|
var ruleOptions = buildRuleOptions({
|
|
2943
2988
|
defaultType: defaultType
|
|
@@ -2997,7 +3042,7 @@ var Text = function Text(_ref) {
|
|
|
2997
3042
|
}, [debouncedInputValue]);
|
|
2998
3043
|
return /*#__PURE__*/React.createElement("div", {
|
|
2999
3044
|
className: "neeto-filters-pane-filter__item-wrapper"
|
|
3000
|
-
}, showRuleSelector && /*#__PURE__*/React.createElement(Select, {
|
|
3045
|
+
}, showRuleSelector && /*#__PURE__*/React.createElement(Select, _extends({
|
|
3001
3046
|
label: label,
|
|
3002
3047
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-filter-rule"),
|
|
3003
3048
|
defaultValue: ruleOptions[0],
|
|
@@ -3005,12 +3050,21 @@ var Text = function Text(_ref) {
|
|
|
3005
3050
|
strategy: "fixed",
|
|
3006
3051
|
value: selectedRule,
|
|
3007
3052
|
onChange: handleRuleChange
|
|
3008
|
-
}
|
|
3053
|
+
}, isNotEmpty(helpIconProps) && {
|
|
3054
|
+
labelProps: {
|
|
3055
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
3056
|
+
}
|
|
3057
|
+
})), /*#__PURE__*/React.createElement(Input$1, _extends({
|
|
3009
3058
|
autoFocus: autoFocus,
|
|
3010
3059
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-filter"),
|
|
3011
3060
|
label: !showRuleSelector && label,
|
|
3012
3061
|
type: inputType,
|
|
3013
|
-
value: inputValue
|
|
3062
|
+
value: inputValue
|
|
3063
|
+
}, isNotEmpty(helpIconProps) && {
|
|
3064
|
+
labelProps: {
|
|
3065
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
3066
|
+
}
|
|
3067
|
+
}, {
|
|
3014
3068
|
placeholder: t("neetoFilters.messages.enterResource", {
|
|
3015
3069
|
resource: label
|
|
3016
3070
|
}),
|
|
@@ -3029,7 +3083,9 @@ var Time = function Time(_ref) {
|
|
|
3029
3083
|
var key = column.key,
|
|
3030
3084
|
_column$defaultType = column.defaultType,
|
|
3031
3085
|
defaultType = _column$defaultType === void 0 ? column.type : _column$defaultType,
|
|
3032
|
-
label = column.label
|
|
3086
|
+
label = column.label,
|
|
3087
|
+
_column$helpIconProps = column.helpIconProps,
|
|
3088
|
+
helpIconProps = _column$helpIconProps === void 0 ? {} : _column$helpIconProps;
|
|
3033
3089
|
var otherProps = getOtherProps(column);
|
|
3034
3090
|
var value = buildSingleTimeValue(filter);
|
|
3035
3091
|
var isCustomTimeRangeShown = filter && isCustomTimeRange(filter.value);
|
|
@@ -3063,7 +3119,7 @@ var Time = function Time(_ref) {
|
|
|
3063
3119
|
};
|
|
3064
3120
|
return /*#__PURE__*/React.createElement("div", {
|
|
3065
3121
|
className: "neeto-filters-pane-filter__item-wrapper"
|
|
3066
|
-
}, /*#__PURE__*/React.createElement(Select, {
|
|
3122
|
+
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
3067
3123
|
autoFocus: autoFocus,
|
|
3068
3124
|
label: label,
|
|
3069
3125
|
value: value,
|
|
@@ -3073,9 +3129,14 @@ var Time = function Time(_ref) {
|
|
|
3073
3129
|
strategy: "fixed",
|
|
3074
3130
|
placeholder: t("neetoFilters.messages.selectResource", {
|
|
3075
3131
|
resource: label
|
|
3076
|
-
})
|
|
3132
|
+
})
|
|
3133
|
+
}, isNotEmpty(helpIconProps) && {
|
|
3134
|
+
labelProps: {
|
|
3135
|
+
helpIconProps: buildHelpIconProps(helpIconProps)
|
|
3136
|
+
}
|
|
3137
|
+
}, {
|
|
3077
3138
|
onChange: handleChange
|
|
3078
|
-
}), isCustomTimeRangeShown && /*#__PURE__*/React.createElement(TimePicker, _extends({
|
|
3139
|
+
})), isCustomTimeRangeShown && /*#__PURE__*/React.createElement(TimePicker, _extends({
|
|
3079
3140
|
use12Hours: true,
|
|
3080
3141
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-date-range"),
|
|
3081
3142
|
format: "h:mm A",
|