@bigbinary/neeto-filters-frontend 3.2.3 → 3.2.4
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 +55 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +56 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import i18next, { t as t$1 } from 'i18next';
|
|
|
4
4
|
import { findBy, isNotEmpty, capitalize, removeBy, humanize, hyphenate, noop, toLabelAndValue, replaceBy, isPresent, existsBy, isNotPresent, filterBy } from '@bigbinary/neeto-cist';
|
|
5
5
|
import { useMutationWithInvalidation, useQueryParams, useDebounce, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
6
6
|
import { buildUrl, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
|
|
7
|
-
import { Tooltip, Typography, Dropdown as Dropdown$2, Button, Pane as Pane$1, Alert, Select, DatePicker,
|
|
7
|
+
import { Tooltip, Typography, Dropdown as Dropdown$2, Button, Pane as Pane$1, Alert, Select, DatePicker, TimePickerInput, Input as Input$1, Accordion, Spinner } from '@bigbinary/neetoui';
|
|
8
8
|
import { groupBy, anyPass, isNil, isEmpty, any, concat, omit, mergeLeft, toLower, identity, mergeRight, toPairs, not, pluck, either, has, 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';
|
|
@@ -533,7 +533,7 @@ var buildFiltersFromSearchParams = function buildFiltersFromSearchParams(columns
|
|
|
533
533
|
}, column);
|
|
534
534
|
} else if (isTime(defaultType) && isCustomTimeRange(value)) {
|
|
535
535
|
return mergeLeft({
|
|
536
|
-
value: value
|
|
536
|
+
value: value
|
|
537
537
|
}, column);
|
|
538
538
|
} else if (isSingleDate(defaultType)) {
|
|
539
539
|
var _value$split3 = value.split("+rule-"),
|
|
@@ -939,6 +939,9 @@ var getColumnsWithStandardizedType = function getColumnsWithStandardizedType(col
|
|
|
939
939
|
});
|
|
940
940
|
});
|
|
941
941
|
};
|
|
942
|
+
var isNilOrEmpty = function isNilOrEmpty(param) {
|
|
943
|
+
return isNil(param) || isEmpty(param);
|
|
944
|
+
};
|
|
942
945
|
var isKeywordFilterPresent = function isKeywordFilterPresent(keyworFilter) {
|
|
943
946
|
return not(isEmpty(keyworFilter.node));
|
|
944
947
|
};
|
|
@@ -1290,6 +1293,7 @@ var Segment = function Segment(_ref) {
|
|
|
1290
1293
|
});
|
|
1291
1294
|
};
|
|
1292
1295
|
return /*#__PURE__*/React.createElement(React.Fragment, null, isNil(segmentId) ? /*#__PURE__*/React.createElement(Button, {
|
|
1296
|
+
"data-cy": "save-segment-button",
|
|
1293
1297
|
disabled: hasOnlyKeywordFilter(filters),
|
|
1294
1298
|
label: t("neetoFilters.segments.saveAsSegment"),
|
|
1295
1299
|
style: "secondary",
|
|
@@ -1718,6 +1722,31 @@ var buildDateValues = function buildDateValues(dates, selectedRule) {
|
|
|
1718
1722
|
var buildHelpIconProps = function buildHelpIconProps(helpIconProps) {
|
|
1719
1723
|
return mergeDeepRight(DEFAULT_HELP_ICON_PROPS, helpIconProps);
|
|
1720
1724
|
};
|
|
1725
|
+
var hasInvalidTimes = function hasInvalidTimes(times) {
|
|
1726
|
+
if (Array.isArray(times)) {
|
|
1727
|
+
return times.some(function (time) {
|
|
1728
|
+
return time.isValid();
|
|
1729
|
+
}) === false;
|
|
1730
|
+
}
|
|
1731
|
+
return !times.isValid();
|
|
1732
|
+
};
|
|
1733
|
+
var areCustomTimeRangeValuesNotValid = function areCustomTimeRangeValuesNotValid(times) {
|
|
1734
|
+
return !times.every(function (time) {
|
|
1735
|
+
return time.isValid();
|
|
1736
|
+
});
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1739
|
+
// eslint-disable-next-line @bigbinary/neeto/use-standard-date-time-formats
|
|
1740
|
+
var formatSingleTime = function formatSingleTime(time) {
|
|
1741
|
+
return dayjs(time).format("HH:mm:ss");
|
|
1742
|
+
};
|
|
1743
|
+
var formatTime = function formatTime(value, timePickerType) {
|
|
1744
|
+
if (isNilOrEmpty(value)) return null;
|
|
1745
|
+
if (timePickerType === "range") {
|
|
1746
|
+
return value.map(formatSingleTime);
|
|
1747
|
+
}
|
|
1748
|
+
return formatSingleTime(value);
|
|
1749
|
+
};
|
|
1721
1750
|
|
|
1722
1751
|
var Boolean = function Boolean(_ref) {
|
|
1723
1752
|
var column = _ref.column,
|
|
@@ -2064,6 +2093,15 @@ var SingleTime = function SingleTime(_ref) {
|
|
|
2064
2093
|
handleApplyFilter(updatedFilter);
|
|
2065
2094
|
};
|
|
2066
2095
|
var handleChange = function handleChange(times) {
|
|
2096
|
+
if (hasInvalidTimes(times)) {
|
|
2097
|
+
handleApplyFilter({
|
|
2098
|
+
_delete: true
|
|
2099
|
+
});
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
if (timePickerType === "range" && areCustomTimeRangeValuesNotValid(times)) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2067
2105
|
var value = timePickerType === "range" ? pluck("$d", times).map(function (time) {
|
|
2068
2106
|
return time.toISOString();
|
|
2069
2107
|
}) : times["$d"].toISOString();
|
|
@@ -2076,6 +2114,7 @@ var SingleTime = function SingleTime(_ref) {
|
|
|
2076
2114
|
});
|
|
2077
2115
|
handleApplyFilter(updatedFilter);
|
|
2078
2116
|
};
|
|
2117
|
+
var formattedTime = formatTime(value, timePickerType);
|
|
2079
2118
|
return /*#__PURE__*/React.createElement("div", {
|
|
2080
2119
|
className: "neeto-filters-pane-filter__item-wrapper"
|
|
2081
2120
|
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
@@ -2090,15 +2129,12 @@ var SingleTime = function SingleTime(_ref) {
|
|
|
2090
2129
|
}
|
|
2091
2130
|
}, {
|
|
2092
2131
|
onChange: handleRuleChange
|
|
2093
|
-
})), /*#__PURE__*/React.createElement(
|
|
2132
|
+
})), /*#__PURE__*/React.createElement(TimePickerInput, _extends({
|
|
2094
2133
|
autoFocus: autoFocus,
|
|
2095
|
-
value: value,
|
|
2096
|
-
use12Hours: true,
|
|
2097
2134
|
className: "w-full",
|
|
2098
2135
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-filter"),
|
|
2099
|
-
format: "h:mm A",
|
|
2100
|
-
getPopupContainer: prop("parentNode"),
|
|
2101
2136
|
type: timePickerType,
|
|
2137
|
+
value: formattedTime,
|
|
2102
2138
|
onChange: handleChange
|
|
2103
2139
|
}, otherProps)));
|
|
2104
2140
|
};
|
|
@@ -2241,6 +2277,15 @@ var Time = function Time(_ref) {
|
|
|
2241
2277
|
handleApplyFilter(updatedFilter);
|
|
2242
2278
|
};
|
|
2243
2279
|
var handleTimeRangeChange = function handleTimeRangeChange(times) {
|
|
2280
|
+
if (hasInvalidTimes(times)) {
|
|
2281
|
+
handleApplyFilter({
|
|
2282
|
+
_delete: true
|
|
2283
|
+
});
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
if (isCustomTimeRangeShown && areCustomTimeRangeValuesNotValid(times)) {
|
|
2287
|
+
return;
|
|
2288
|
+
}
|
|
2244
2289
|
var updatedFilter = buildUpdatedFilter({
|
|
2245
2290
|
column: column,
|
|
2246
2291
|
defaultType: defaultType,
|
|
@@ -2271,13 +2316,11 @@ var Time = function Time(_ref) {
|
|
|
2271
2316
|
}
|
|
2272
2317
|
}, {
|
|
2273
2318
|
onChange: handleChange
|
|
2274
|
-
})), isCustomTimeRangeShown && /*#__PURE__*/React.createElement(
|
|
2275
|
-
|
|
2319
|
+
})), isCustomTimeRangeShown && /*#__PURE__*/React.createElement(TimePickerInput, _extends({
|
|
2320
|
+
className: "w-full",
|
|
2276
2321
|
"data-cy": "neeto-filters-".concat(hyphenate(key), "-date-range"),
|
|
2277
|
-
format: "h:mm A",
|
|
2278
|
-
getPopupContainer: prop("parentNode"),
|
|
2279
2322
|
type: "range",
|
|
2280
|
-
value: filter.value,
|
|
2323
|
+
value: formatTime(filter.value, "range"),
|
|
2281
2324
|
onChange: handleTimeRangeChange
|
|
2282
2325
|
}, otherProps)));
|
|
2283
2326
|
};
|
|
@@ -2847,6 +2890,7 @@ var MenuBlocks = function MenuBlocks(_ref) {
|
|
|
2847
2890
|
return /*#__PURE__*/React.createElement(MenuBar.Block, {
|
|
2848
2891
|
active: segment.id === segmentId,
|
|
2849
2892
|
count: segment.count,
|
|
2893
|
+
"data-cy": "neeto-filters-segment-block-".concat(hyphenate(segment.name)),
|
|
2850
2894
|
key: segment.id,
|
|
2851
2895
|
label: segment.name,
|
|
2852
2896
|
onClick: function onClick() {
|