@true-engineering/true-react-common-ui-kit 3.52.0 → 3.53.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/README.md CHANGED
@@ -12,6 +12,13 @@
12
12
 
13
13
  # Release Notes
14
14
 
15
+ ## 3.53.0
16
+
17
+ ### Changes
18
+
19
+ - **FiltersPane**: Добавлен проп `shouldRenderDataId`, который добавляет атрибут `data-id` со значением из конфига.
20
+ - **FiltersPane**: Изменена типизация дженериков, добавлены тайпгарды
21
+
15
22
  ## 3.52.0
16
23
 
17
24
  ### Changes
@@ -3,7 +3,7 @@ import { ICommonProps } from '../../types';
3
3
  import { IFiltersPaneSearchProps } from './components';
4
4
  import { ConfigType, IFilterLocaleKey, IPartialFilterLocale } from './types';
5
5
  import { IFiltersPaneStyles } from './FiltersPane.styles';
6
- export interface IFiltersPaneProps<Values, Content = Values> extends ICommonProps<IFiltersPaneStyles> {
6
+ export interface IFiltersPaneProps<Values extends Record<string, unknown>, Content = Values> extends ICommonProps<IFiltersPaneStyles> {
7
7
  filtersConfig: ConfigType<Values>;
8
8
  enabledFilters?: Array<keyof ConfigType<Values>>;
9
9
  /** @default {} */
@@ -15,8 +15,10 @@ export interface IFiltersPaneProps<Values, Content = Values> extends ICommonProp
15
15
  isDisabled?: boolean;
16
16
  /** @default true */
17
17
  hasClearButton?: boolean;
18
+ /** @default false */
19
+ shouldRenderDataId?: boolean;
18
20
  onChangeFilters: (values: Partial<Values>) => void;
19
21
  onSettingsButtonClick?: () => void;
20
22
  onClear?: () => void;
21
23
  }
22
- export declare function FiltersPane<Values extends Record<string, unknown>, Content = Values>({ data, tweakStyles, filtersConfig, enabledFilters, values, localeKey, locale, search, isDisabled, hasClearButton, testId, onChangeFilters, onSettingsButtonClick, onClear, }: IFiltersPaneProps<Values, Content>): JSX.Element;
24
+ export declare function FiltersPane<Values extends Record<string, unknown>, Content = Values>({ data, tweakStyles, filtersConfig, enabledFilters, values, localeKey, locale, search, isDisabled, hasClearButton, shouldRenderDataId, testId, onChangeFilters, onSettingsButtonClick, onClear, }: IFiltersPaneProps<Values, Content>): JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { IFiltersPaneProps } from './FiltersPane';
2
- interface IFiltersPaneWithCustomProps<Values, Content> extends IFiltersPaneProps<Values, Content> {
2
+ interface IFiltersPaneWithCustomProps<Values extends Record<string, unknown>, Content> extends IFiltersPaneProps<Values, Content> {
3
3
  containerWidth: number;
4
4
  isSearchDisabled: boolean;
5
5
  isSearchAutosizeable: boolean;
@@ -9,7 +9,7 @@ interface IFiltersPaneWithCustomProps<Values, Content> extends IFiltersPaneProps
9
9
  checkboxPosition: 'left' | 'right';
10
10
  isClearableFields: boolean;
11
11
  }
12
- declare function FiltersPaneWithCustomProps<Values, Content>({ containerWidth, isSearchDisabled, isSearchAutosizeable, shouldShowSettingsButton, withFieldNameInLabel, isGroupingEnabled, checkboxPosition, isClearableFields, ...args }: IFiltersPaneWithCustomProps<Values, Content>): import("react/jsx-runtime").JSX.Element;
12
+ declare function FiltersPaneWithCustomProps<Values extends Record<string, unknown>, Content>({ containerWidth, isSearchDisabled, isSearchAutosizeable, shouldShowSettingsButton, withFieldNameInLabel, isGroupingEnabled, checkboxPosition, isClearableFields, ...args }: IFiltersPaneWithCustomProps<Values, Content>): import("react/jsx-runtime").JSX.Element;
13
13
  declare const _default: {
14
14
  title: string;
15
15
  component: typeof FiltersPaneWithCustomProps;
@@ -29,4 +29,4 @@ declare const _default: {
29
29
  };
30
30
  };
31
31
  export default _default;
32
- export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, IFiltersPaneWithCustomProps<unknown, unknown>>;
32
+ export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, IFiltersPaneWithCustomProps<Record<string, unknown>, unknown>>;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { IFilterWrapperProps } from '../FilterWrapper';
3
- export interface IFilterProps<Values, Key extends keyof Values> extends IFilterWrapperProps<Values, Key> {
3
+ export interface IFilterProps<Values extends Record<string, unknown>, Key extends keyof Values> extends IFilterWrapperProps<Values, Key> {
4
4
  onChange: <V>(v: V) => void;
5
5
  onClose?: () => void;
6
6
  }
7
- export declare function Filter<Values, Key extends keyof Values>(props: IFilterProps<Values, Key>): JSX.Element | null;
7
+ export declare function Filter<Values extends Record<string, unknown>, Key extends keyof Values>(props: IFilterProps<Values, Key>): JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { IDatePeriod, IFilterMultiSelectValues, IPeriod } from '../../types';
2
+ export declare const isDatePeriodValue: (value: any) => value is IDatePeriod;
3
+ export declare const isPeriodValue: (value: any) => value is IPeriod;
4
+ export declare const isMultiSelectValue: <T extends string>(value: any) => value is IFilterMultiSelectValues<T>;
@@ -2,4 +2,6 @@
2
2
  import { ICommonProps } from '../../../../types';
3
3
  import type { IFilterWrapperProps } from '../FilterWrapper';
4
4
  import { IFilterValueViewStyles } from './FilterValueView.styles';
5
- export declare function FilterValueView<Values, Key extends keyof Values>({ locale, localeKey, filter, value, tweakStyles, }: Omit<IFilterWrapperProps<Values, Key>, 'onChange' | 'filtersPaneRef' | 'tweakStyles'> & ICommonProps<IFilterValueViewStyles>): JSX.Element;
5
+ export interface IFilterValueView<Values extends Record<string, unknown>, Key extends keyof Values> extends Omit<IFilterWrapperProps<Values, Key>, 'filtersPaneRef' | 'tweakStyles' | 'onChange'>, ICommonProps<IFilterValueViewStyles> {
6
+ }
7
+ export declare function FilterValueView<Values extends Record<string, unknown>, Key extends keyof Values>({ value, filter, locale, localeKey, tweakStyles, }: IFilterValueView<Values, Key>): JSX.Element;
@@ -2,7 +2,7 @@
2
2
  import { ICommonProps } from '../../../../types';
3
3
  import { ConfigItem, IFilterLocaleKey, IPartialFilterLocale } from '../../types';
4
4
  import { IFilterWrapperStyles } from './FilterWrapper.styles';
5
- export interface IFilterWrapperProps<Values, Key extends keyof Values> extends ICommonProps<IFilterWrapperStyles> {
5
+ export interface IFilterWrapperProps<Values extends Record<string, unknown>, Key extends keyof Values> extends ICommonProps<IFilterWrapperStyles> {
6
6
  filter: ConfigItem<Values[Key]>;
7
7
  value?: Values[Key];
8
8
  isDisabled?: boolean;
@@ -10,4 +10,4 @@ export interface IFilterWrapperProps<Values, Key extends keyof Values> extends I
10
10
  locale?: IPartialFilterLocale;
11
11
  onChange: <V>(value: V) => void;
12
12
  }
13
- export declare function FilterWrapper<Values, Key extends keyof Values>({ filter, value, isDisabled, locale, localeKey, data, testId, tweakStyles, onChange, }: IFilterWrapperProps<Values, Key>): JSX.Element;
13
+ export declare function FilterWrapper<Values extends Record<string, unknown>, Key extends keyof Values>({ filter, value, isDisabled, locale, localeKey, data, testId, tweakStyles, onChange, }: IFilterWrapperProps<Values, Key>): JSX.Element;
@@ -18006,6 +18006,7 @@ function FilterSelect(param) {
18006
18006
  }
18007
18007
  var useStyles$q = createThemedStyles("FilterWithDates", {
18008
18008
  root: {
18009
+ width: 320,
18009
18010
  background: colors.CLASSIC_WHITE,
18010
18011
  position: "relative",
18011
18012
  zIndex: 20
@@ -18600,9 +18601,6 @@ var FilterWithPeriod = function(param) {
18600
18601
  }),
18601
18602
  isDatePickerShown && /* @__PURE__ */ jsx("div", {
18602
18603
  className: classes.picker,
18603
- style: {
18604
- width: 320
18605
- },
18606
18604
  ref: refDatePicker,
18607
18605
  children: /* @__PURE__ */ jsx(FilterWithDates, {
18608
18606
  onStartBtnSubmit: function() {
@@ -18626,6 +18624,25 @@ var FilterWithPeriod = function(param) {
18626
18624
  ]
18627
18625
  });
18628
18626
  };
18627
+ function _instanceof$2(left2, right2) {
18628
+ if (right2 != null && typeof Symbol !== "undefined" && right2[Symbol.hasInstance]) {
18629
+ return !!right2[Symbol.hasInstance](left2);
18630
+ } else {
18631
+ return left2 instanceof right2;
18632
+ }
18633
+ }
18634
+ var isDateOrEmpty = function(value) {
18635
+ return isEmpty(value) || _instanceof$2(value, Date);
18636
+ };
18637
+ var isDatePeriodValue = function(value) {
18638
+ return isDateOrEmpty(value === null || value === void 0 ? void 0 : value.from) && isDateOrEmpty(value === null || value === void 0 ? void 0 : value.to);
18639
+ };
18640
+ var isPeriodValue = function(value) {
18641
+ return isString(value === null || value === void 0 ? void 0 : value.periodType) && isDatePeriodValue(value);
18642
+ };
18643
+ var isMultiSelectValue = function(value) {
18644
+ return Array.isArray(value === null || value === void 0 ? void 0 : value.include);
18645
+ };
18629
18646
  function _define_property$s(obj, key, value) {
18630
18647
  if (key in obj) {
18631
18648
  Object.defineProperty(obj, key, {
@@ -18700,8 +18717,9 @@ function Filter(props) {
18700
18717
  }, filter));
18701
18718
  }
18702
18719
  if (filter.type === "dateRange") {
18720
+ var preparedValue = isPeriodValue(value) ? _object_spread$r({}, value) : void 0;
18703
18721
  return /* @__PURE__ */ jsx(FilterWithPeriod, _object_spread$r({
18704
- value: _object_spread$r({}, value),
18722
+ value: preparedValue,
18705
18723
  onChange,
18706
18724
  onClose,
18707
18725
  localeKey: translatesLocaleKey,
@@ -18710,29 +18728,26 @@ function Filter(props) {
18710
18728
  }, filter));
18711
18729
  }
18712
18730
  if (filter.type === "dateRangeWithoutPeriod") {
18713
- return /* @__PURE__ */ jsx("div", {
18714
- style: {
18715
- width: 320
18731
+ var preparedValue1 = isDatePeriodValue(value) ? value : void 0;
18732
+ return /* @__PURE__ */ jsx(FilterWithDates, _object_spread$r({
18733
+ value: preparedValue1,
18734
+ onChange: function(v) {
18735
+ return onChange(_object_spread_props$q(_object_spread$r({}, v), {
18736
+ periodType: "CUSTOM"
18737
+ }));
18716
18738
  },
18717
- children: /* @__PURE__ */ jsx(FilterWithDates, _object_spread$r({
18718
- value,
18719
- onChange: function(v) {
18720
- return onChange(_object_spread_props$q(_object_spread$r({}, v), {
18721
- periodType: "CUSTOM"
18722
- }));
18723
- },
18724
- onEndBtnSubmit: function() {
18725
- return onChange(void 0);
18726
- },
18727
- localeKey: translatesLocaleKey,
18728
- locale: translates,
18729
- testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
18730
- }, filter))
18731
- });
18739
+ onEndBtnSubmit: function() {
18740
+ return onChange(void 0);
18741
+ },
18742
+ localeKey: translatesLocaleKey,
18743
+ locale: translates,
18744
+ testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
18745
+ }, filter));
18732
18746
  }
18733
18747
  if (filter.type === "multiSelect") {
18748
+ var preparedValue2 = isMultiSelectValue(value) ? value : void 0;
18734
18749
  return /* @__PURE__ */ jsx(FilterMultiSelect, _object_spread$r({
18735
- value,
18750
+ value: preparedValue2,
18736
18751
  onChange,
18737
18752
  onClose,
18738
18753
  localeKey: translatesLocaleKey,
@@ -18741,8 +18756,9 @@ function Filter(props) {
18741
18756
  }, filter));
18742
18757
  }
18743
18758
  if (filter.type === "interval") {
18759
+ var preparedValue3 = Array.isArray(value) ? value : void 0;
18744
18760
  return /* @__PURE__ */ jsx(FilterInterval, _object_spread$r({
18745
- value,
18761
+ value: preparedValue3,
18746
18762
  onChange,
18747
18763
  localeKey: translatesLocaleKey,
18748
18764
  locale: translates,
@@ -19102,7 +19118,7 @@ function _instanceof$1(left2, right2) {
19102
19118
  }
19103
19119
  }
19104
19120
  function FilterValueView(param) {
19105
- var locale2 = param.locale, localeKey = param.localeKey, filter = param.filter, value = param.value, tweakStyles = param.tweakStyles;
19121
+ var value = param.value, filter = param.filter, locale2 = param.locale, localeKey = param.localeKey, tweakStyles = param.tweakStyles;
19106
19122
  var classes = useStyles$n({
19107
19123
  theme: tweakStyles
19108
19124
  });
@@ -19475,8 +19491,8 @@ function FilterWrapper(param) {
19475
19491
  children: /* @__PURE__ */ jsx(FilterValueView, {
19476
19492
  value,
19477
19493
  filter,
19478
- localeKey,
19479
19494
  locale: locale2,
19495
+ localeKey,
19480
19496
  testId: getTestId(testId, "value"),
19481
19497
  tweakStyles: tweakFilterValueViewStyles
19482
19498
  })
@@ -19503,8 +19519,8 @@ function FilterWrapper(param) {
19503
19519
  return /* @__PURE__ */ jsx(Filter, {
19504
19520
  value,
19505
19521
  filter,
19506
- localeKey,
19507
19522
  locale: locale2,
19523
+ localeKey,
19508
19524
  onClose,
19509
19525
  onChange,
19510
19526
  testId
@@ -19565,7 +19581,7 @@ function _object_spread_props$n(target, source) {
19565
19581
  return target;
19566
19582
  }
19567
19583
  function FiltersPane(param) {
19568
- var data = param.data, tweakStyles = param.tweakStyles, filtersConfig = param.filtersConfig, enabledFilters = param.enabledFilters, _param_values = param.values, values = _param_values === void 0 ? {} : _param_values, localeKey = param.localeKey, locale2 = param.locale, search = param.search, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, _param_hasClearButton = param.hasClearButton, hasClearButton = _param_hasClearButton === void 0 ? true : _param_hasClearButton, testId = param.testId, onChangeFilters = param.onChangeFilters, onSettingsButtonClick = param.onSettingsButtonClick, onClear = param.onClear;
19584
+ var data = param.data, tweakStyles = param.tweakStyles, filtersConfig = param.filtersConfig, enabledFilters = param.enabledFilters, _param_values = param.values, values = _param_values === void 0 ? {} : _param_values, localeKey = param.localeKey, locale2 = param.locale, search = param.search, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, _param_hasClearButton = param.hasClearButton, hasClearButton = _param_hasClearButton === void 0 ? true : _param_hasClearButton, _param_shouldRenderDataId = param.shouldRenderDataId, shouldRenderDataId = _param_shouldRenderDataId === void 0 ? false : _param_shouldRenderDataId, testId = param.testId, onChangeFilters = param.onChangeFilters, onSettingsButtonClick = param.onSettingsButtonClick, onClear = param.onClear;
19569
19585
  var classes = useStyles$u({
19570
19586
  theme: tweakStyles
19571
19587
  });
@@ -19586,7 +19602,7 @@ function FiltersPane(param) {
19586
19602
  localeKey,
19587
19603
  locale2
19588
19604
  ]);
19589
- var filtersKeys = enabledFilters || Object.keys(filtersConfig);
19605
+ var filtersKeys = enabledFilters !== null && enabledFilters !== void 0 ? enabledFilters : Object.keys(filtersConfig);
19590
19606
  var handleClear = function() {
19591
19607
  if (onClear !== void 0) {
19592
19608
  onClear();
@@ -19638,10 +19654,11 @@ function FiltersPane(param) {
19638
19654
  filtersKeys.map(function(key, index) {
19639
19655
  var _filter_requiredFilledFilters;
19640
19656
  var isLast = index === filtersKeys.length - 1;
19641
- var currentValue = values[key];
19642
- var filter = filtersConfig[key];
19657
+ var filterKey = String(key);
19658
+ var currentValue = values[filterKey];
19659
+ var filter = filtersConfig[filterKey];
19643
19660
  if (filter === void 0) {
19644
- console.error("enabledFilters содержит фильтр ".concat(String(key), ", не описанный в конфиге"));
19661
+ console.error("enabledFilters содержит фильтр ".concat(filterKey, ", не описанный в конфиге"));
19645
19662
  if (isLast) {
19646
19663
  return clearButton;
19647
19664
  }
@@ -19652,15 +19669,18 @@ function FiltersPane(param) {
19652
19669
  locale: locale2,
19653
19670
  localeKey,
19654
19671
  onChange: function(value) {
19655
- return onChangeFilters(_object_spread_props$n(_object_spread$o({}, values), _define_property$p({}, key, value)));
19672
+ return onChangeFilters(_object_spread_props$n(_object_spread$o({}, values), _define_property$p({}, filterKey, value)));
19656
19673
  },
19657
19674
  value: currentValue,
19658
19675
  isDisabled: isDisabled || (filter === null || filter === void 0 ? void 0 : (_filter_requiredFilledFilters = filter.requiredFilledFilters) === null || _filter_requiredFilledFilters === void 0 ? void 0 : _filter_requiredFilledFilters.some(function(item) {
19659
19676
  return !values[item];
19660
19677
  })),
19661
19678
  tweakStyles: tweakFilterWrapperStyles,
19662
- testId: getTestId(testId, "filter-".concat(String(key)))
19663
- }, key);
19679
+ data: shouldRenderDataId ? {
19680
+ id: filterKey
19681
+ } : void 0,
19682
+ testId: getTestId(testId, "filter-".concat(filterKey))
19683
+ }, filterKey);
19664
19684
  if (isLast) {
19665
19685
  return /* @__PURE__ */ jsxs("div", {
19666
19686
  className: classes.filterWithClearButton,
@@ -19670,7 +19690,7 @@ function FiltersPane(param) {
19670
19690
  children: clearButton
19671
19691
  })
19672
19692
  ]
19673
- }, key);
19693
+ }, filterKey);
19674
19694
  }
19675
19695
  return filterWrapper;
19676
19696
  })