@true-engineering/true-react-common-ui-kit 4.0.0-alpha26 → 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;
@@ -1,6 +1,7 @@
1
1
  import { type ChangeEvent, type FC, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';
2
2
  import { type Classes } from 'jss';
3
- export interface ISelectListItemProps {
3
+ import { IDataAttributesProps } from '../../../../types';
4
+ export interface ISelectListItemProps extends IDataAttributesProps {
4
5
  index: number;
5
6
  isSemiChecked?: boolean;
6
7
  isDisabled?: boolean;
@@ -11474,7 +11474,7 @@ function _object_spread_props$F(target, source) {
11474
11474
  return target;
11475
11475
  }
11476
11476
  var SelectListItem = function(param) {
11477
- var classes = param.classes, index = param.index, isSemiChecked = param.isSemiChecked, isDisabled = param.isDisabled, isActive = param.isActive, children = param.children, isFocused = param.isFocused, isMultiSelect = param.isMultiSelect, onOptionSelect = param.onOptionSelect, onToggleCheckbox = param.onToggleCheckbox;
11477
+ var classes = param.classes, index = param.index, isSemiChecked = param.isSemiChecked, isDisabled = param.isDisabled, isActive = param.isActive, children = param.children, isFocused = param.isFocused, isMultiSelect = param.isMultiSelect, data = param.data, onOptionSelect = param.onOptionSelect, onToggleCheckbox = param.onToggleCheckbox;
11478
11478
  var multiSelectContent = isMultiSelect && /* @__PURE__ */ jsx(Checkbox, {
11479
11479
  isChecked: isActive || isSemiChecked,
11480
11480
  isSemiChecked,
@@ -11493,11 +11493,11 @@ var SelectListItem = function(param) {
11493
11493
  block: "nearest"
11494
11494
  },
11495
11495
  className: clsx(classes.cell, (_obj2 = {}, _define_property$N(_obj2, classes.cellWithCheckbox, isMultiSelect), _define_property$N(_obj2, classes.focused, isFocused), _define_property$N(_obj2, classes.active, isActive && !isMultiSelect), _define_property$N(_obj2, classes.disabled, isDisabled), _obj2))
11496
- }, addDataAttributes({
11496
+ }, addDataAttributes$1(_object_spread$L({
11497
11497
  disabled: isDisabled,
11498
11498
  active: isActive,
11499
11499
  focused: isFocused
11500
- })), {
11500
+ }, data))), {
11501
11501
  onClick: !isDisabled && !isMultiSelect ? function(event) {
11502
11502
  return onOptionSelect(index, event);
11503
11503
  } : void 0,
@@ -11626,8 +11626,9 @@ function SelectList(param) {
11626
11626
  }),
11627
11627
  listOptions.map(function(opt, i) {
11628
11628
  var optionValue = options[i];
11629
+ var id = convertValueToId(optionValue);
11629
11630
  var isFocused = focusedIndex === i;
11630
- var isActive = activeOptionsIds.has(convertValueToId(optionValue));
11631
+ var isActive = activeOptionsIds.has(id);
11631
11632
  var isDisabled = optionsDisableMap[i];
11632
11633
  return /* @__PURE__ */ jsx(SelectListItem, {
11633
11634
  classes,
@@ -11638,6 +11639,9 @@ function SelectList(param) {
11638
11639
  isMultiSelect,
11639
11640
  onOptionSelect,
11640
11641
  onToggleCheckbox,
11642
+ data: {
11643
+ id
11644
+ },
11641
11645
  children: opt
11642
11646
  }, i);
11643
11647
  }),
@@ -19077,7 +19081,7 @@ function FilterSelect(param) {
19077
19081
  }, []);
19078
19082
  return /* @__PURE__ */ jsxs("div", _object_spread_props$t(_object_spread$u({
19079
19083
  className: classes.root
19080
- }, addDataAttributes(data)), {
19084
+ }, addDataAttributes$1(data, testId)), {
19081
19085
  children: [
19082
19086
  isSearchEnabled && /* @__PURE__ */ jsx("div", {
19083
19087
  className: classes.dropdownInput,
@@ -19086,20 +19090,20 @@ function FilterSelect(param) {
19086
19090
  placeholder: translates.searchPlaceholder,
19087
19091
  onChange: handleOnChange,
19088
19092
  tweakStyles: tweakSearchInputStyles,
19089
- testId: testId !== void 0 ? "".concat(testId, "-search") : void 0,
19093
+ testId: getTestId(testId, "search"),
19090
19094
  shouldFocusOnMount: true
19091
19095
  })
19092
19096
  }),
19093
19097
  !isLoading && /* @__PURE__ */ jsxs(Fragment, {
19094
19098
  children: [
19095
- allOptions.length !== 0 && /* @__PURE__ */ jsxs("div", {
19096
- className: clsx(classes.list, hasClearButton && classes.withClearButton),
19097
- "data-testid": testId !== void 0 ? "".concat(testId, "-list") : void 0,
19099
+ isArrayNotEmpty(allOptions) && /* @__PURE__ */ jsxs("div", _object_spread_props$t(_object_spread$u({
19100
+ className: clsx(classes.list, _define_property$v({}, classes.withClearButton, hasClearButton))
19101
+ }, addDataTestId(testId, "list")), {
19098
19102
  children: [
19099
- isGroupingEnabled && value !== void 0 && /* @__PURE__ */ jsxs(Fragment, {
19103
+ isGroupingEnabled && isNotEmpty(value) && /* @__PURE__ */ jsxs(Fragment, {
19100
19104
  children: [
19101
19105
  /* @__PURE__ */ jsx("div", {
19102
- className: clsx(classes.label, classes.labelChosen, !isSearchEnabled && classes.withoutTopGap),
19106
+ className: clsx(classes.label, classes.labelChosen, _define_property$v({}, classes.withoutTopGap, !isSearchEnabled)),
19103
19107
  children: translates.chosen
19104
19108
  }),
19105
19109
  /* @__PURE__ */ jsxs("div", {
@@ -19127,7 +19131,7 @@ function FilterSelect(param) {
19127
19131
  ]
19128
19132
  }),
19129
19133
  allOptions.map(function(item, index) {
19130
- var isActive = value !== void 0 && getValueId(value) === getValueId(item);
19134
+ var isActive = isNotEmpty(value) && getValueId(value) === getValueId(item);
19131
19135
  if (isGroupingEnabled && isActive) {
19132
19136
  return null;
19133
19137
  }
@@ -19140,11 +19144,14 @@ function FilterSelect(param) {
19140
19144
  return handleChange(item);
19141
19145
  },
19142
19146
  children: [
19143
- /* @__PURE__ */ jsx("div", {
19144
- className: classes.option,
19145
- "data-option": id,
19147
+ /* @__PURE__ */ jsx("div", _object_spread_props$t(_object_spread$u({
19148
+ className: classes.option
19149
+ }, addDataAttributes$1({
19150
+ id,
19151
+ option: id
19152
+ })), {
19146
19153
  children: view
19147
- }),
19154
+ })),
19148
19155
  isActive && /* @__PURE__ */ jsx("div", {
19149
19156
  className: classes.icon,
19150
19157
  children: /* @__PURE__ */ jsx(Icon, {
@@ -19163,14 +19170,14 @@ function FilterSelect(param) {
19163
19170
  }
19164
19171
  })
19165
19172
  ]
19166
- }),
19173
+ })),
19167
19174
  shouldShowPreloader && /* @__PURE__ */ jsx("div", {
19168
19175
  className: classes.preloader,
19169
19176
  children: /* @__PURE__ */ jsx(ThemedPreloader, {
19170
19177
  type: "dots"
19171
19178
  })
19172
19179
  }),
19173
- allOptions.length === 0 && /* @__PURE__ */ jsx("div", {
19180
+ !isArrayNotEmpty(allOptions) && /* @__PURE__ */ jsx("div", {
19174
19181
  className: classes.nothingFound,
19175
19182
  children: translates.nothingFound
19176
19183
  }),
@@ -19187,7 +19194,7 @@ function FilterSelect(param) {
19187
19194
  onClick: handleClear,
19188
19195
  size: "s",
19189
19196
  view: "text",
19190
- testId: testId !== void 0 ? "".concat(testId, "-clear-button") : void 0,
19197
+ testId: getTestId(testId, "clear-button"),
19191
19198
  tweakStyles: tweakClearButtonStyles,
19192
19199
  children: translates.clear
19193
19200
  })
@@ -19795,7 +19802,7 @@ var FilterWithPeriod = function(param) {
19795
19802
  locale: translates,
19796
19803
  tweakStyles: tweakSelectStyles,
19797
19804
  getValueView: getPeriodTranslate,
19798
- testId: testId !== void 0 ? "".concat(testId, "-select") : void 0
19805
+ testId: getTestId(testId, "select")
19799
19806
  })
19800
19807
  }),
19801
19808
  isDatePickerShown && /* @__PURE__ */ jsx("div", {
@@ -19817,7 +19824,7 @@ var FilterWithPeriod = function(param) {
19817
19824
  onChange: handleCustomDateChange,
19818
19825
  localeKey,
19819
19826
  locale: translates,
19820
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
19827
+ testId: getTestId(testId, "dates")
19821
19828
  })
19822
19829
  })
19823
19830
  ]
@@ -19912,7 +19919,7 @@ function Filter(props) {
19912
19919
  onClose,
19913
19920
  localeKey: translatesLocaleKey,
19914
19921
  locale: translates,
19915
- testId: testId !== void 0 ? "".concat(testId, "-select") : void 0
19922
+ testId: getTestId(testId, "select")
19916
19923
  }, filter));
19917
19924
  }
19918
19925
  if (filter.type === "dateRange") {
@@ -19923,7 +19930,7 @@ function Filter(props) {
19923
19930
  onClose,
19924
19931
  localeKey: translatesLocaleKey,
19925
19932
  locale: translates,
19926
- testId: testId !== void 0 ? "".concat(testId, "-period") : void 0
19933
+ testId: getTestId(testId, "period")
19927
19934
  }, filter));
19928
19935
  }
19929
19936
  if (filter.type === "dateRangeWithoutPeriod") {
@@ -19940,7 +19947,7 @@ function Filter(props) {
19940
19947
  },
19941
19948
  localeKey: translatesLocaleKey,
19942
19949
  locale: translates,
19943
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
19950
+ testId: getTestId(testId, "dates")
19944
19951
  }, filter));
19945
19952
  }
19946
19953
  if (filter.type === "multiSelect") {
@@ -19951,7 +19958,7 @@ function Filter(props) {
19951
19958
  onClose,
19952
19959
  localeKey: translatesLocaleKey,
19953
19960
  locale: translates,
19954
- testId: testId !== void 0 ? "".concat(testId, "-multiSelect") : void 0
19961
+ testId: getTestId(testId, "multiSelect")
19955
19962
  }, filter));
19956
19963
  }
19957
19964
  if (filter.type === "interval") {
@@ -19962,19 +19969,19 @@ function Filter(props) {
19962
19969
  localeKey: translatesLocaleKey,
19963
19970
  locale: translates,
19964
19971
  labelName: filter.name,
19965
- testId: testId !== void 0 ? "".concat(testId, "-interval") : void 0
19972
+ testId: getTestId(testId, "interval")
19966
19973
  }, filter));
19967
19974
  }
19968
- if (filter.type === "boolean") {
19969
- return null;
19970
- }
19971
19975
  if (filter.type === "custom" && filter.component) {
19972
19976
  var Component = filter.component;
19973
19977
  return /* @__PURE__ */ jsx(Component, _object_spread_props$q(_object_spread$r({}, props), {
19974
- filter
19978
+ filter,
19979
+ testId: getTestId(testId, "dropdown")
19975
19980
  }));
19976
19981
  }
19977
- 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
+ }
19978
19985
  return null;
19979
19986
  }
19980
19987
  var useStyles$o = createThemedStyles("FiltersPaneSearch", {
@@ -20228,17 +20235,11 @@ function FiltersPaneSearch(param) {
20228
20235
  });
20229
20236
  setIsOpen(false);
20230
20237
  };
20231
- var selectedFieldLabel = useMemo(function() {
20232
- return field !== void 0 && getValueView !== void 0 ? getValueView(field) : void 0;
20233
- }, [
20234
- field
20235
- ]);
20236
20238
  var _obj2;
20237
20239
  return /* @__PURE__ */ jsxs("div", _object_spread_props$p(_object_spread$q({
20238
20240
  className: clsx(classes.root, (_obj2 = {}, _define_property$r(_obj2, classes.focused, isInputFocused), _define_property$r(_obj2, classes.disabled, isDisabled), _obj2)),
20239
- ref: refRoot,
20240
- "data-testid": testId
20241
- }, addDataAttributes(data)), {
20241
+ ref: refRoot
20242
+ }, addDataAttributes$1(data, testId)), {
20242
20243
  children: [
20243
20244
  /* @__PURE__ */ jsx(SearchInput, {
20244
20245
  value,
@@ -20251,23 +20252,23 @@ function FiltersPaneSearch(param) {
20251
20252
  onBlur: function() {
20252
20253
  return setIsInputFocused(false);
20253
20254
  },
20254
- testId: testId !== void 0 ? "".concat(testId, "-input") : void 0,
20255
+ testId: getTestId(testId, "input"),
20255
20256
  maxLength,
20256
20257
  isDisabled
20257
20258
  }),
20258
20259
  /* @__PURE__ */ jsxs("div", {
20259
20260
  className: classes.selectWrapper,
20260
20261
  children: [
20261
- fields.length > 0 && /* @__PURE__ */ jsxs("div", {
20262
+ fields.length > 0 && /* @__PURE__ */ jsxs("div", _object_spread_props$p(_object_spread$q({
20262
20263
  className: classes.selectBlock,
20263
20264
  onClick: !isDisabled ? function() {
20264
20265
  return setIsOpen(!isOpen);
20265
- } : void 0,
20266
- "data-testid": testId !== void 0 ? "".concat(testId, "-select") : void 0,
20266
+ } : void 0
20267
+ }, addDataTestId(testId, "select")), {
20267
20268
  children: [
20268
20269
  /* @__PURE__ */ jsx("div", {
20269
- className: clsx(classes.selectLabel, selectedFieldLabel !== void 0 && classes.active),
20270
- 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
20271
20272
  }),
20272
20273
  /* @__PURE__ */ jsx("div", {
20273
20274
  className: clsx(classes.chevronIcon, isOpen && classes.open),
@@ -20276,7 +20277,7 @@ function FiltersPaneSearch(param) {
20276
20277
  })
20277
20278
  })
20278
20279
  ]
20279
- }),
20280
+ })),
20280
20281
  isOpen && /* @__PURE__ */ jsx("div", {
20281
20282
  className: classes.dropdown,
20282
20283
  children: /* @__PURE__ */ jsx(FilterSelect, {
@@ -20291,7 +20292,7 @@ function FiltersPaneSearch(param) {
20291
20292
  onChange: handleFieldsChange,
20292
20293
  isSearchEnabled: isSelectSearchEnabled,
20293
20294
  hasClearButton: hasClearSelectButton,
20294
- testId: testId !== void 0 ? "".concat(testId, "-dropdown") : void 0
20295
+ testId: getTestId(testId, "dropdown")
20295
20296
  })
20296
20297
  })
20297
20298
  ]
@@ -20676,7 +20677,7 @@ function FilterWrapper(param) {
20676
20677
  var _obj2;
20677
20678
  return /* @__PURE__ */ jsx("div", _object_spread_props$o(_object_spread$p({
20678
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))
20679
- }, addDataTestId(testId), addDataAttributes(data), referenceProps), {
20680
+ }, addDataAttributes$1(data, testId), referenceProps), {
20680
20681
  children: /* @__PURE__ */ jsxs("div", {
20681
20682
  onClick: handleLabelClick,
20682
20683
  className: clsx(classes.item, _define_property$q({}, classes.booleanItem, isBoolean)),
@@ -20685,7 +20686,7 @@ function FilterWrapper(param) {
20685
20686
  className: classes.name,
20686
20687
  children: filter.name
20687
20688
  }),
20688
- !isBoolean && value !== void 0 && value !== null && /* @__PURE__ */ jsx("div", {
20689
+ !isBoolean && isNotEmpty(value) && /* @__PURE__ */ jsx("div", {
20689
20690
  className: classes.value,
20690
20691
  children: /* @__PURE__ */ jsx(FilterValueView, {
20691
20692
  value,
@@ -20803,7 +20804,7 @@ function FiltersPane(param) {
20803
20804
  ]);
20804
20805
  var filtersKeys = enabledFilters !== null && enabledFilters !== void 0 ? enabledFilters : Object.keys(filtersConfig);
20805
20806
  var handleClear = function() {
20806
- if (onClear !== void 0) {
20807
+ if (isNotEmpty(onClear)) {
20807
20808
  onClear();
20808
20809
  return;
20809
20810
  }
@@ -20812,9 +20813,9 @@ function FiltersPane(param) {
20812
20813
  search.onChange({});
20813
20814
  }
20814
20815
  };
20815
- var shouldShowClearButton = hasClearButton && (search !== void 0 || filtersKeys.filter(function(key) {
20816
- return filtersConfig[key] !== void 0;
20817
- }).length > 0);
20816
+ var shouldShowClearButton = hasClearButton && (isNotEmpty(search) || filtersKeys.some(function(key) {
20817
+ return isNotEmpty(filtersConfig[key]);
20818
+ }));
20818
20819
  var clearButton = /* @__PURE__ */ jsx("div", {
20819
20820
  className: classes.clear,
20820
20821
  children: /* @__PURE__ */ jsx(Button, {
@@ -20830,7 +20831,7 @@ function FiltersPane(param) {
20830
20831
  var _search_localeKey, _search_localeKey1, _search_isDisabled;
20831
20832
  return /* @__PURE__ */ jsxs("div", _object_spread_props$n(_object_spread$o({
20832
20833
  className: classes.root
20833
- }, addDataTestId(testId), addDataAttributes(data)), {
20834
+ }, addDataAttributes$1(data, testId)), {
20834
20835
  children: [
20835
20836
  onSettingsButtonClick !== void 0 && /* @__PURE__ */ jsx("div", _object_spread_props$n(_object_spread$o({
20836
20837
  className: classes.settings,