@true-engineering/true-react-common-ui-kit 4.0.0-alpha27 → 4.0.0-alpha28

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.
@@ -1,4 +1,5 @@
1
1
  import { FC, ReactNode } from 'react';
2
+ import { ITestIdProps } from '../../types';
2
3
  import { IDatePickerProps } from '../DatePicker';
3
4
  import { IMultiSelectListValues } from '../MultiSelectList';
4
5
  import type { IFilterIntervalProps, IFilterMultiSelectProps, IFilterSelectProps, IFilterWithDatesProps, IFilterWithPeriodProps } from './components';
@@ -54,7 +55,7 @@ export type IDateRangeConfigItem<Value> = IConfigItemBasicBase<Value> & {
54
55
  type: 'dateRange';
55
56
  dateFormat?: string;
56
57
  } & Omit<IFilterWithPeriodProps, 'value' | 'onChange' | 'setIsOpen'>;
57
- export interface ICustomComponentProps<Value> {
58
+ export interface ICustomComponentProps<Value> extends ITestIdProps {
58
59
  value?: Value;
59
60
  onChange: (v?: Value) => void;
60
61
  onClose?: () => void;
@@ -19802,7 +19802,7 @@ var FilterWithPeriod = function(param) {
19802
19802
  locale: translates,
19803
19803
  tweakStyles: tweakSelectStyles,
19804
19804
  getValueView: getPeriodTranslate,
19805
- testId: testId !== void 0 ? "".concat(testId, "-select") : void 0
19805
+ testId: getTestId(testId, "select")
19806
19806
  })
19807
19807
  }),
19808
19808
  isDatePickerShown && /* @__PURE__ */ jsx("div", {
@@ -19824,7 +19824,7 @@ var FilterWithPeriod = function(param) {
19824
19824
  onChange: handleCustomDateChange,
19825
19825
  localeKey,
19826
19826
  locale: translates,
19827
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
19827
+ testId: getTestId(testId, "dates")
19828
19828
  })
19829
19829
  })
19830
19830
  ]
@@ -19919,7 +19919,7 @@ function Filter(props) {
19919
19919
  onClose,
19920
19920
  localeKey: translatesLocaleKey,
19921
19921
  locale: translates,
19922
- testId: testId !== void 0 ? "".concat(testId, "-select") : void 0
19922
+ testId: getTestId(testId, "select")
19923
19923
  }, filter));
19924
19924
  }
19925
19925
  if (filter.type === "dateRange") {
@@ -19930,7 +19930,7 @@ function Filter(props) {
19930
19930
  onClose,
19931
19931
  localeKey: translatesLocaleKey,
19932
19932
  locale: translates,
19933
- testId: testId !== void 0 ? "".concat(testId, "-period") : void 0
19933
+ testId: getTestId(testId, "period")
19934
19934
  }, filter));
19935
19935
  }
19936
19936
  if (filter.type === "dateRangeWithoutPeriod") {
@@ -19947,7 +19947,7 @@ function Filter(props) {
19947
19947
  },
19948
19948
  localeKey: translatesLocaleKey,
19949
19949
  locale: translates,
19950
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
19950
+ testId: getTestId(testId, "dates")
19951
19951
  }, filter));
19952
19952
  }
19953
19953
  if (filter.type === "multiSelect") {
@@ -19958,7 +19958,7 @@ function Filter(props) {
19958
19958
  onClose,
19959
19959
  localeKey: translatesLocaleKey,
19960
19960
  locale: translates,
19961
- testId: testId !== void 0 ? "".concat(testId, "-multiSelect") : void 0
19961
+ testId: getTestId(testId, "multiSelect")
19962
19962
  }, filter));
19963
19963
  }
19964
19964
  if (filter.type === "interval") {
@@ -19969,19 +19969,19 @@ function Filter(props) {
19969
19969
  localeKey: translatesLocaleKey,
19970
19970
  locale: translates,
19971
19971
  labelName: filter.name,
19972
- testId: testId !== void 0 ? "".concat(testId, "-interval") : void 0
19972
+ testId: getTestId(testId, "interval")
19973
19973
  }, filter));
19974
19974
  }
19975
- if (filter.type === "boolean") {
19976
- return null;
19977
- }
19978
19975
  if (filter.type === "custom" && filter.component) {
19979
19976
  var Component = filter.component;
19980
19977
  return /* @__PURE__ */ jsx(Component, _object_spread_props$q(_object_spread$r({}, props), {
19981
- filter
19978
+ filter,
19979
+ testId: getTestId(testId, "dropdown")
19982
19980
  }));
19983
19981
  }
19984
- console.warn("%cДля фильтра ".concat(filter.name, " не задан тип или component"), "background: red; color: black");
19982
+ if (filter.type !== "boolean") {
19983
+ console.warn("%cДля фильтра ".concat(filter.name, " не задан тип или component"), "background: red; color: black");
19984
+ }
19985
19985
  return null;
19986
19986
  }
19987
19987
  var useStyles$o = createThemedStyles("FiltersPaneSearch", {
@@ -20235,17 +20235,11 @@ function FiltersPaneSearch(param) {
20235
20235
  });
20236
20236
  setIsOpen(false);
20237
20237
  };
20238
- var selectedFieldLabel = useMemo(function() {
20239
- return field !== void 0 && getValueView !== void 0 ? getValueView(field) : void 0;
20240
- }, [
20241
- field
20242
- ]);
20243
20238
  var _obj2;
20244
20239
  return /* @__PURE__ */ jsxs("div", _object_spread_props$p(_object_spread$q({
20245
20240
  className: clsx(classes.root, (_obj2 = {}, _define_property$r(_obj2, classes.focused, isInputFocused), _define_property$r(_obj2, classes.disabled, isDisabled), _obj2)),
20246
- ref: refRoot,
20247
- "data-testid": testId
20248
- }, addDataAttributes(data)), {
20241
+ ref: refRoot
20242
+ }, addDataAttributes$1(data, testId)), {
20249
20243
  children: [
20250
20244
  /* @__PURE__ */ jsx(SearchInput, {
20251
20245
  value,
@@ -20258,23 +20252,23 @@ function FiltersPaneSearch(param) {
20258
20252
  onBlur: function() {
20259
20253
  return setIsInputFocused(false);
20260
20254
  },
20261
- testId: testId !== void 0 ? "".concat(testId, "-input") : void 0,
20255
+ testId: getTestId(testId, "input"),
20262
20256
  maxLength,
20263
20257
  isDisabled
20264
20258
  }),
20265
20259
  /* @__PURE__ */ jsxs("div", {
20266
20260
  className: classes.selectWrapper,
20267
20261
  children: [
20268
- fields.length > 0 && /* @__PURE__ */ jsxs("div", {
20262
+ fields.length > 0 && /* @__PURE__ */ jsxs("div", _object_spread_props$p(_object_spread$q({
20269
20263
  className: classes.selectBlock,
20270
20264
  onClick: !isDisabled ? function() {
20271
20265
  return setIsOpen(!isOpen);
20272
- } : void 0,
20273
- "data-testid": testId !== void 0 ? "".concat(testId, "-select") : void 0,
20266
+ } : void 0
20267
+ }, addDataTestId(testId, "select")), {
20274
20268
  children: [
20275
20269
  /* @__PURE__ */ jsx("div", {
20276
- className: clsx(classes.selectLabel, selectedFieldLabel !== void 0 && classes.active),
20277
- children: selectedFieldLabel !== null && selectedFieldLabel !== void 0 ? selectedFieldLabel : translates.displayedFields
20270
+ className: clsx(classes.selectLabel, _define_property$r({}, classes.active, isNotEmpty(field))),
20271
+ children: isNotEmpty(field) ? getValueView === null || getValueView === void 0 ? void 0 : getValueView(field) : translates.displayedFields
20278
20272
  }),
20279
20273
  /* @__PURE__ */ jsx("div", {
20280
20274
  className: clsx(classes.chevronIcon, isOpen && classes.open),
@@ -20283,7 +20277,7 @@ function FiltersPaneSearch(param) {
20283
20277
  })
20284
20278
  })
20285
20279
  ]
20286
- }),
20280
+ })),
20287
20281
  isOpen && /* @__PURE__ */ jsx("div", {
20288
20282
  className: classes.dropdown,
20289
20283
  children: /* @__PURE__ */ jsx(FilterSelect, {
@@ -20298,7 +20292,7 @@ function FiltersPaneSearch(param) {
20298
20292
  onChange: handleFieldsChange,
20299
20293
  isSearchEnabled: isSelectSearchEnabled,
20300
20294
  hasClearButton: hasClearSelectButton,
20301
- testId: testId !== void 0 ? "".concat(testId, "-dropdown") : void 0
20295
+ testId: getTestId(testId, "dropdown")
20302
20296
  })
20303
20297
  })
20304
20298
  ]
@@ -20683,7 +20677,7 @@ function FilterWrapper(param) {
20683
20677
  var _obj2;
20684
20678
  return /* @__PURE__ */ jsx("div", _object_spread_props$o(_object_spread$p({
20685
20679
  className: clsx(classes.root, (_obj2 = {}, _define_property$q(_obj2, classes.noValue, !hasValue), _define_property$q(_obj2, classes.openNoValue, isActive && !hasValue), _define_property$q(_obj2, classes.withValue, !isActive && hasValue), _define_property$q(_obj2, classes.openWithValue, isActive && hasValue), _define_property$q(_obj2, classes.boolean, isBoolean), _define_property$q(_obj2, classes.disabled, isDisabled), _obj2))
20686
- }, addDataTestId(testId), addDataAttributes(data), referenceProps), {
20680
+ }, addDataAttributes$1(data, testId), referenceProps), {
20687
20681
  children: /* @__PURE__ */ jsxs("div", {
20688
20682
  onClick: handleLabelClick,
20689
20683
  className: clsx(classes.item, _define_property$q({}, classes.booleanItem, isBoolean)),
@@ -20692,7 +20686,7 @@ function FilterWrapper(param) {
20692
20686
  className: classes.name,
20693
20687
  children: filter.name
20694
20688
  }),
20695
- !isBoolean && value !== void 0 && value !== null && /* @__PURE__ */ jsx("div", {
20689
+ !isBoolean && isNotEmpty(value) && /* @__PURE__ */ jsx("div", {
20696
20690
  className: classes.value,
20697
20691
  children: /* @__PURE__ */ jsx(FilterValueView, {
20698
20692
  value,
@@ -20810,7 +20804,7 @@ function FiltersPane(param) {
20810
20804
  ]);
20811
20805
  var filtersKeys = enabledFilters !== null && enabledFilters !== void 0 ? enabledFilters : Object.keys(filtersConfig);
20812
20806
  var handleClear = function() {
20813
- if (onClear !== void 0) {
20807
+ if (isNotEmpty(onClear)) {
20814
20808
  onClear();
20815
20809
  return;
20816
20810
  }
@@ -20819,9 +20813,9 @@ function FiltersPane(param) {
20819
20813
  search.onChange({});
20820
20814
  }
20821
20815
  };
20822
- var shouldShowClearButton = hasClearButton && (search !== void 0 || filtersKeys.filter(function(key) {
20823
- return filtersConfig[key] !== void 0;
20824
- }).length > 0);
20816
+ var shouldShowClearButton = hasClearButton && (isNotEmpty(search) || filtersKeys.some(function(key) {
20817
+ return isNotEmpty(filtersConfig[key]);
20818
+ }));
20825
20819
  var clearButton = /* @__PURE__ */ jsx("div", {
20826
20820
  className: classes.clear,
20827
20821
  children: /* @__PURE__ */ jsx(Button, {
@@ -20837,7 +20831,7 @@ function FiltersPane(param) {
20837
20831
  var _search_localeKey, _search_localeKey1, _search_isDisabled;
20838
20832
  return /* @__PURE__ */ jsxs("div", _object_spread_props$n(_object_spread$o({
20839
20833
  className: classes.root
20840
- }, addDataTestId(testId), addDataAttributes(data)), {
20834
+ }, addDataAttributes$1(data, testId)), {
20841
20835
  children: [
20842
20836
  onSettingsButtonClick !== void 0 && /* @__PURE__ */ jsx("div", _object_spread_props$n(_object_spread$o({
20843
20837
  className: classes.settings,