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

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,7 +1,7 @@
1
1
  import { ITweakStyles } from '../../../../theme';
2
2
  import { ISearchInputStyles } from '../../../SearchInput';
3
3
  import { ISelectStyles } from '../../../Select';
4
- export declare const useStyles: import("../../../../theme").IUseStyles<"root" | "open" | "active" | "disabled" | "dropdownInput" | "chevronIcon" | "dropdown" | "focused" | "selectWrapper" | "selectBlock" | "selectLabel", unknown>;
4
+ export declare const useStyles: import("../../../../theme").IUseStyles<"root" | "open" | "active" | "disabled" | "dropdownInput" | "chevronIcon" | "dropdown" | "focused" | "hasValue" | "selectWrapper" | "selectBlock" | "selectLabel", unknown>;
5
5
  export declare const searchInputStyles: ISearchInputStyles;
6
6
  export declare const selectStyles: ISelectStyles;
7
7
  export type IFiltersPaneSearchStyles = ITweakStyles<typeof useStyles, {
@@ -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;
@@ -8192,17 +8192,18 @@ var WithPopup = function(param) {
8192
8192
  theme: tweakStyles
8193
8193
  });
8194
8194
  var _useState = _sliced_to_array$m(useState(false), 2), isOpen = _useState[0], setIsOpen = _useState[1];
8195
+ var isActive = isOpen && !isDisabled;
8195
8196
  var arrowRef = useRef(null);
8196
- var handleToggle = function(isActive, event) {
8197
+ var handleToggle = function(next, event) {
8197
8198
  event === null || event === void 0 ? void 0 : event.stopPropagation();
8198
- onToggle === null || onToggle === void 0 ? void 0 : onToggle(isActive, event);
8199
- setIsOpen(isActive);
8199
+ onToggle === null || onToggle === void 0 ? void 0 : onToggle(next, event);
8200
+ setIsOpen(next);
8200
8201
  };
8201
8202
  var handleClose = function(event) {
8202
8203
  handleToggle(false, event);
8203
8204
  };
8204
8205
  var _useFloating = useFloating({
8205
- open: isOpen && !isDisabled,
8206
+ open: isActive,
8206
8207
  middleware: [
8207
8208
  offset$2(popupOffset),
8208
8209
  canBeFlipped && flip$2({
@@ -8255,7 +8256,7 @@ var WithPopup = function(param) {
8255
8256
  var triggerElement = applyAction(trigger, {
8256
8257
  referenceProps: !isTriggerWrapped ? referenceProps : void 0,
8257
8258
  triggerProps: _object_spread$12({
8258
- isActive: isOpen,
8259
+ isActive,
8259
8260
  isDisabled
8260
8261
  }, !isTriggerWrapped && _object_spread$12({
8261
8262
  data,
@@ -8266,7 +8267,7 @@ var WithPopup = function(param) {
8266
8267
  return /* @__PURE__ */ jsxs(Fragment, {
8267
8268
  children: [
8268
8269
  isTriggerWrapped ? /* @__PURE__ */ jsx("div", _object_spread_props$S(_object_spread$12({
8269
- className: clsx(classes.trigger, (_obj2 = {}, _define_property$14(_obj2, classes.clickable, eventType === "click"), _define_property$14(_obj2, classes.disabled, isDisabled), _define_property$14(_obj2, classes.active, isOpen), _obj2))
8270
+ className: clsx(classes.trigger, (_obj2 = {}, _define_property$14(_obj2, classes.clickable, eventType === "click"), _define_property$14(_obj2, classes.disabled, isDisabled), _define_property$14(_obj2, classes.active, isActive), _obj2))
8270
8271
  }, referenceProps, addDataAttributes$1(data, testId)), {
8271
8272
  children: triggerElement
8272
8273
  })) : triggerElement,
@@ -19802,7 +19803,7 @@ var FilterWithPeriod = function(param) {
19802
19803
  locale: translates,
19803
19804
  tweakStyles: tweakSelectStyles,
19804
19805
  getValueView: getPeriodTranslate,
19805
- testId: testId !== void 0 ? "".concat(testId, "-select") : void 0
19806
+ testId: getTestId(testId, "select")
19806
19807
  })
19807
19808
  }),
19808
19809
  isDatePickerShown && /* @__PURE__ */ jsx("div", {
@@ -19824,7 +19825,7 @@ var FilterWithPeriod = function(param) {
19824
19825
  onChange: handleCustomDateChange,
19825
19826
  localeKey,
19826
19827
  locale: translates,
19827
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
19828
+ testId: getTestId(testId, "dates")
19828
19829
  })
19829
19830
  })
19830
19831
  ]
@@ -19919,7 +19920,7 @@ function Filter(props) {
19919
19920
  onClose,
19920
19921
  localeKey: translatesLocaleKey,
19921
19922
  locale: translates,
19922
- testId: testId !== void 0 ? "".concat(testId, "-select") : void 0
19923
+ testId: getTestId(testId, "select")
19923
19924
  }, filter));
19924
19925
  }
19925
19926
  if (filter.type === "dateRange") {
@@ -19930,7 +19931,7 @@ function Filter(props) {
19930
19931
  onClose,
19931
19932
  localeKey: translatesLocaleKey,
19932
19933
  locale: translates,
19933
- testId: testId !== void 0 ? "".concat(testId, "-period") : void 0
19934
+ testId: getTestId(testId, "period")
19934
19935
  }, filter));
19935
19936
  }
19936
19937
  if (filter.type === "dateRangeWithoutPeriod") {
@@ -19947,7 +19948,7 @@ function Filter(props) {
19947
19948
  },
19948
19949
  localeKey: translatesLocaleKey,
19949
19950
  locale: translates,
19950
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
19951
+ testId: getTestId(testId, "dates")
19951
19952
  }, filter));
19952
19953
  }
19953
19954
  if (filter.type === "multiSelect") {
@@ -19958,7 +19959,7 @@ function Filter(props) {
19958
19959
  onClose,
19959
19960
  localeKey: translatesLocaleKey,
19960
19961
  locale: translates,
19961
- testId: testId !== void 0 ? "".concat(testId, "-multiSelect") : void 0
19962
+ testId: getTestId(testId, "multiSelect")
19962
19963
  }, filter));
19963
19964
  }
19964
19965
  if (filter.type === "interval") {
@@ -19969,19 +19970,19 @@ function Filter(props) {
19969
19970
  localeKey: translatesLocaleKey,
19970
19971
  locale: translates,
19971
19972
  labelName: filter.name,
19972
- testId: testId !== void 0 ? "".concat(testId, "-interval") : void 0
19973
+ testId: getTestId(testId, "interval")
19973
19974
  }, filter));
19974
19975
  }
19975
- if (filter.type === "boolean") {
19976
- return null;
19977
- }
19978
19976
  if (filter.type === "custom" && filter.component) {
19979
19977
  var Component = filter.component;
19980
19978
  return /* @__PURE__ */ jsx(Component, _object_spread_props$q(_object_spread$r({}, props), {
19981
- filter
19979
+ filter,
19980
+ testId: getTestId(testId, "dropdown")
19982
19981
  }));
19983
19982
  }
19984
- console.warn("%cДля фильтра ".concat(filter.name, " не задан тип или component"), "background: red; color: black");
19983
+ if (filter.type !== "boolean") {
19984
+ console.warn("%cДля фильтра ".concat(filter.name, " не задан тип или component"), "background: red; color: black");
19985
+ }
19985
19986
  return null;
19986
19987
  }
19987
19988
  var useStyles$o = createThemedStyles("FiltersPaneSearch", {
@@ -20008,6 +20009,10 @@ var useStyles$o = createThemedStyles("FiltersPaneSearch", {
20008
20009
  cursor: "default"
20009
20010
  }
20010
20011
  },
20012
+ hasValue: {
20013
+ backgroundColor: colors.CLASSIC_WHITE,
20014
+ borderColor: colors.BORDER_MAIN
20015
+ },
20011
20016
  selectWrapper: {
20012
20017
  position: "relative",
20013
20018
  display: "flex",
@@ -20235,17 +20240,11 @@ function FiltersPaneSearch(param) {
20235
20240
  });
20236
20241
  setIsOpen(false);
20237
20242
  };
20238
- var selectedFieldLabel = useMemo(function() {
20239
- return field !== void 0 && getValueView !== void 0 ? getValueView(field) : void 0;
20240
- }, [
20241
- field
20242
- ]);
20243
20243
  var _obj2;
20244
20244
  return /* @__PURE__ */ jsxs("div", _object_spread_props$p(_object_spread$q({
20245
- 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)), {
20245
+ className: clsx(classes.root, (_obj2 = {}, _define_property$r(_obj2, classes.focused, isInputFocused), _define_property$r(_obj2, classes.disabled, isDisabled), _define_property$r(_obj2, classes.hasValue, isArrayLikeNotEmpty(value)), _obj2)),
20246
+ ref: refRoot
20247
+ }, addDataAttributes$1(data, testId)), {
20249
20248
  children: [
20250
20249
  /* @__PURE__ */ jsx(SearchInput, {
20251
20250
  value,
@@ -20258,23 +20257,23 @@ function FiltersPaneSearch(param) {
20258
20257
  onBlur: function() {
20259
20258
  return setIsInputFocused(false);
20260
20259
  },
20261
- testId: testId !== void 0 ? "".concat(testId, "-input") : void 0,
20260
+ testId: getTestId(testId, "input"),
20262
20261
  maxLength,
20263
20262
  isDisabled
20264
20263
  }),
20265
20264
  /* @__PURE__ */ jsxs("div", {
20266
20265
  className: classes.selectWrapper,
20267
20266
  children: [
20268
- fields.length > 0 && /* @__PURE__ */ jsxs("div", {
20267
+ isArrayNotEmpty(fields) && /* @__PURE__ */ jsxs("div", _object_spread_props$p(_object_spread$q({
20269
20268
  className: classes.selectBlock,
20270
20269
  onClick: !isDisabled ? function() {
20271
20270
  return setIsOpen(!isOpen);
20272
- } : void 0,
20273
- "data-testid": testId !== void 0 ? "".concat(testId, "-select") : void 0,
20271
+ } : void 0
20272
+ }, addDataTestId(testId, "select")), {
20274
20273
  children: [
20275
20274
  /* @__PURE__ */ jsx("div", {
20276
- className: clsx(classes.selectLabel, selectedFieldLabel !== void 0 && classes.active),
20277
- children: selectedFieldLabel !== null && selectedFieldLabel !== void 0 ? selectedFieldLabel : translates.displayedFields
20275
+ className: clsx(classes.selectLabel, _define_property$r({}, classes.active, isNotEmpty(field))),
20276
+ children: isNotEmpty(field) ? getValueView === null || getValueView === void 0 ? void 0 : getValueView(field) : translates.displayedFields
20278
20277
  }),
20279
20278
  /* @__PURE__ */ jsx("div", {
20280
20279
  className: clsx(classes.chevronIcon, isOpen && classes.open),
@@ -20283,7 +20282,7 @@ function FiltersPaneSearch(param) {
20283
20282
  })
20284
20283
  })
20285
20284
  ]
20286
- }),
20285
+ })),
20287
20286
  isOpen && /* @__PURE__ */ jsx("div", {
20288
20287
  className: classes.dropdown,
20289
20288
  children: /* @__PURE__ */ jsx(FilterSelect, {
@@ -20298,7 +20297,7 @@ function FiltersPaneSearch(param) {
20298
20297
  onChange: handleFieldsChange,
20299
20298
  isSearchEnabled: isSelectSearchEnabled,
20300
20299
  hasClearButton: hasClearSelectButton,
20301
- testId: testId !== void 0 ? "".concat(testId, "-dropdown") : void 0
20300
+ testId: getTestId(testId, "dropdown")
20302
20301
  })
20303
20302
  })
20304
20303
  ]
@@ -20683,7 +20682,7 @@ function FilterWrapper(param) {
20683
20682
  var _obj2;
20684
20683
  return /* @__PURE__ */ jsx("div", _object_spread_props$o(_object_spread$p({
20685
20684
  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), {
20685
+ }, addDataAttributes$1(data, testId), referenceProps), {
20687
20686
  children: /* @__PURE__ */ jsxs("div", {
20688
20687
  onClick: handleLabelClick,
20689
20688
  className: clsx(classes.item, _define_property$q({}, classes.booleanItem, isBoolean)),
@@ -20692,7 +20691,7 @@ function FilterWrapper(param) {
20692
20691
  className: classes.name,
20693
20692
  children: filter.name
20694
20693
  }),
20695
- !isBoolean && value !== void 0 && value !== null && /* @__PURE__ */ jsx("div", {
20694
+ !isBoolean && isNotEmpty(value) && /* @__PURE__ */ jsx("div", {
20696
20695
  className: classes.value,
20697
20696
  children: /* @__PURE__ */ jsx(FilterValueView, {
20698
20697
  value,
@@ -20810,7 +20809,7 @@ function FiltersPane(param) {
20810
20809
  ]);
20811
20810
  var filtersKeys = enabledFilters !== null && enabledFilters !== void 0 ? enabledFilters : Object.keys(filtersConfig);
20812
20811
  var handleClear = function() {
20813
- if (onClear !== void 0) {
20812
+ if (isNotEmpty(onClear)) {
20814
20813
  onClear();
20815
20814
  return;
20816
20815
  }
@@ -20819,9 +20818,9 @@ function FiltersPane(param) {
20819
20818
  search.onChange({});
20820
20819
  }
20821
20820
  };
20822
- var shouldShowClearButton = hasClearButton && (search !== void 0 || filtersKeys.filter(function(key) {
20823
- return filtersConfig[key] !== void 0;
20824
- }).length > 0);
20821
+ var shouldShowClearButton = hasClearButton && (isNotEmpty(search) || filtersKeys.some(function(key) {
20822
+ return isNotEmpty(filtersConfig[key]);
20823
+ }));
20825
20824
  var clearButton = /* @__PURE__ */ jsx("div", {
20826
20825
  className: classes.clear,
20827
20826
  children: /* @__PURE__ */ jsx(Button, {
@@ -20837,7 +20836,7 @@ function FiltersPane(param) {
20837
20836
  var _search_localeKey, _search_localeKey1, _search_isDisabled;
20838
20837
  return /* @__PURE__ */ jsxs("div", _object_spread_props$n(_object_spread$o({
20839
20838
  className: classes.root
20840
- }, addDataTestId(testId), addDataAttributes(data)), {
20839
+ }, addDataAttributes$1(data, testId)), {
20841
20840
  children: [
20842
20841
  onSettingsButtonClick !== void 0 && /* @__PURE__ */ jsx("div", _object_spread_props$n(_object_spread$o({
20843
20842
  className: classes.settings,