@bigbinary/neeto-filters-frontend 2.11.20 → 2.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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useContext, useState, useRef, useEffect, useCallback, useMemo } from 'react';
2
2
  import classnames from 'classnames';
3
- import { removeBy, findBy, isNotEmpty, humanize, noop as noop$2, toLabelAndValue, replaceBy, isPresent, existsBy, filterBy } from '@bigbinary/neeto-commons-frontend/pure';
3
+ import { capitalize as capitalize$1, removeBy, findBy, isNotEmpty, humanize, noop as noop$2, toLabelAndValue, replaceBy, isPresent, existsBy, filterBy } from '@bigbinary/neeto-commons-frontend/pure';
4
4
  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';
5
5
  import { groupBy, anyPass, isNil, isEmpty, any, mergeLeft, identity, omit, mergeRight, concat, pluck, either, has as has$1, toPairs, equals, pick, modify, prop, isNotNil, append, last, not } from 'ramda';
6
6
  import { useHistory, useLocation } from 'react-router-dom';
@@ -3510,28 +3510,28 @@ var groupByGroup = groupBy(function (_ref) {
3510
3510
  return group || "individual";
3511
3511
  });
3512
3512
  var isBoolean = function isBoolean(type) {
3513
- return type === "boolean";
3513
+ return type === "boolean" || type === "custom.boolean";
3514
3514
  };
3515
3515
  var isDate = function isDate(type) {
3516
- return type === "date";
3516
+ return type === "date" || type === "custom.date";
3517
3517
  };
3518
3518
  var isSingleDate = function isSingleDate(type) {
3519
- return type === "single_date";
3519
+ return type === "single_date" || type === "custom.single_date";
3520
3520
  };
3521
3521
  var isSingleTime = function isSingleTime(type) {
3522
- return type === "single_time";
3522
+ return type === "single_time" || type === "custom.single_time";
3523
3523
  };
3524
3524
  var isTime = function isTime(type) {
3525
- return type === "time";
3525
+ return type === "time" || type === "custom.time";
3526
3526
  };
3527
3527
  var isMulti = function isMulti(type) {
3528
- return type === "multi_option";
3528
+ return type === "multi_option" || type === "custom.multi_option";
3529
3529
  };
3530
3530
  var isText = function isText(type) {
3531
- return type === "text";
3531
+ return type === "text" || type === "custom.text";
3532
3532
  };
3533
3533
  var isDigit = function isDigit(type) {
3534
- return type === "number" || type === "decimal";
3534
+ return type === "number" || type === "decimal" || type === "custom.number";
3535
3535
  };
3536
3536
  var isCustomDateRange = function isCustomDateRange(value) {
3537
3537
  return !pluck("value", DATE_OPTIONS).includes(value);
@@ -4044,6 +4044,36 @@ var buildUrlFromSegment = function buildUrlFromSegment(_ref19) {
4044
4044
  var getKeywordValueFromUrl = function getKeywordValueFromUrl() {
4045
4045
  return getQueryParams()["keyword"] || "";
4046
4046
  };
4047
+ var buildFilterColumnsFromFields = function buildFilterColumnsFromFields(fields) {
4048
+ var selectedFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4049
+ if (isEmpty(selectedFields)) {
4050
+ return fields.map(function (field) {
4051
+ var id = field.id,
4052
+ name = field.name,
4053
+ kind = field.kind;
4054
+ return {
4055
+ key: name,
4056
+ node: "".concat(name, ":").concat(id),
4057
+ label: capitalize$1(name),
4058
+ type: "custom.".concat(kind)
4059
+ };
4060
+ });
4061
+ }
4062
+ return fields.reduce(function (columns, field) {
4063
+ if (selectedFields.includes(field.name)) {
4064
+ var id = field.id,
4065
+ name = field.name,
4066
+ kind = field.kind;
4067
+ columns.push({
4068
+ key: name,
4069
+ node: "".concat(name, ":").concat(id),
4070
+ label: capitalize$1(name),
4071
+ type: "custom.".concat(kind)
4072
+ });
4073
+ }
4074
+ return columns;
4075
+ }, []);
4076
+ };
4047
4077
 
4048
4078
  var buildCustomDateValue = function buildCustomDateValue(value) {
4049
4079
  var isBeforeOrAfter = Math.abs(dayjs(value[1]).diff(dayjs(value[0]), "year")) >= 90;
@@ -7559,7 +7589,7 @@ var Text = function Text(_ref) {
7559
7589
  var ruleOptions = buildRuleOptions({
7560
7590
  defaultType: defaultType
7561
7591
  });
7562
- var inputType = defaultType === "text" ? "text" : "number";
7592
+ var inputType = defaultType === "text" || defaultType === "custom.text" ? "text" : "number";
7563
7593
  var _useState = useState(filter === null || filter === void 0 ? void 0 : filter.value),
7564
7594
  _useState2 = _slicedToArray(_useState, 2),
7565
7595
  inputValue = _useState2[0],
@@ -8414,5 +8444,5 @@ instance.use(initReactI18next).init({
8414
8444
  }
8415
8445
  });
8416
8446
 
8417
- export { Bar, Filters, index as Segments, buildFiltersFromURL, buildSelectorsFromURL };
8447
+ export { Bar, Filters, index as Segments, buildFilterColumnsFromFields, buildFiltersFromURL, buildSelectorsFromURL };
8418
8448
  //# sourceMappingURL=index.js.map