@true-engineering/true-react-common-ui-kit 3.52.0 → 3.53.1

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,20 @@
12
12
 
13
13
  # Release Notes
14
14
 
15
+ ## 3.53.1
16
+
17
+ ### Changes
18
+
19
+ - **PhoneInput**: Исправлено обрезание лейбла многоточием
20
+ - **SearchInput**: Исправлено обрезание лейбла многоточием
21
+
22
+ ## 3.53.0
23
+
24
+ ### Changes
25
+
26
+ - **FiltersPane**: Добавлен проп `shouldRenderDataId`, который добавляет атрибут `data-id` со значением из конфига.
27
+ - **FiltersPane**: Изменена типизация дженериков, добавлены тайпгарды
28
+
15
29
  ## 3.52.0
16
30
 
17
31
  ### Changes
@@ -41,7 +55,8 @@
41
55
 
42
56
  - **DateInput**
43
57
  - **NumberInput**
44
- - **PhoneInput**
58
+ - **PhoneInput** – если вы переопределяли через твик-стайлы правило `margin-left` для класса `label`,
59
+ это переопределение нужно удалить, т.к. `margin-left` теперь в стандартном случае не должно быть
45
60
  - **PhoneInputCountryList**
46
61
  - **SearchInput** – если вы переопределяли через твик-стайлы правило `left` для класса `label`,
47
62
  это переопределение нужно удалить, т.к. `left` теперь в стандартном случае должно быть равно `0`
@@ -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;
@@ -10593,6 +10593,7 @@ var inputStyles$4 = {
10593
10593
  paddingLeft: 0
10594
10594
  },
10595
10595
  label: {
10596
+ "--label-max-width": "100%",
10596
10597
  left: 0,
10597
10598
  fontSize: 14
10598
10599
  }
@@ -18006,6 +18007,7 @@ function FilterSelect(param) {
18006
18007
  }
18007
18008
  var useStyles$q = createThemedStyles("FilterWithDates", {
18008
18009
  root: {
18010
+ width: 320,
18009
18011
  background: colors.CLASSIC_WHITE,
18010
18012
  position: "relative",
18011
18013
  zIndex: 20
@@ -18600,9 +18602,6 @@ var FilterWithPeriod = function(param) {
18600
18602
  }),
18601
18603
  isDatePickerShown && /* @__PURE__ */ jsx("div", {
18602
18604
  className: classes.picker,
18603
- style: {
18604
- width: 320
18605
- },
18606
18605
  ref: refDatePicker,
18607
18606
  children: /* @__PURE__ */ jsx(FilterWithDates, {
18608
18607
  onStartBtnSubmit: function() {
@@ -18626,6 +18625,25 @@ var FilterWithPeriod = function(param) {
18626
18625
  ]
18627
18626
  });
18628
18627
  };
18628
+ function _instanceof$2(left2, right2) {
18629
+ if (right2 != null && typeof Symbol !== "undefined" && right2[Symbol.hasInstance]) {
18630
+ return !!right2[Symbol.hasInstance](left2);
18631
+ } else {
18632
+ return left2 instanceof right2;
18633
+ }
18634
+ }
18635
+ var isDateOrEmpty = function(value) {
18636
+ return isEmpty(value) || _instanceof$2(value, Date);
18637
+ };
18638
+ var isDatePeriodValue = function(value) {
18639
+ return isDateOrEmpty(value === null || value === void 0 ? void 0 : value.from) && isDateOrEmpty(value === null || value === void 0 ? void 0 : value.to);
18640
+ };
18641
+ var isPeriodValue = function(value) {
18642
+ return isString(value === null || value === void 0 ? void 0 : value.periodType) && isDatePeriodValue(value);
18643
+ };
18644
+ var isMultiSelectValue = function(value) {
18645
+ return Array.isArray(value === null || value === void 0 ? void 0 : value.include);
18646
+ };
18629
18647
  function _define_property$s(obj, key, value) {
18630
18648
  if (key in obj) {
18631
18649
  Object.defineProperty(obj, key, {
@@ -18700,8 +18718,9 @@ function Filter(props) {
18700
18718
  }, filter));
18701
18719
  }
18702
18720
  if (filter.type === "dateRange") {
18721
+ var preparedValue = isPeriodValue(value) ? _object_spread$r({}, value) : void 0;
18703
18722
  return /* @__PURE__ */ jsx(FilterWithPeriod, _object_spread$r({
18704
- value: _object_spread$r({}, value),
18723
+ value: preparedValue,
18705
18724
  onChange,
18706
18725
  onClose,
18707
18726
  localeKey: translatesLocaleKey,
@@ -18710,29 +18729,26 @@ function Filter(props) {
18710
18729
  }, filter));
18711
18730
  }
18712
18731
  if (filter.type === "dateRangeWithoutPeriod") {
18713
- return /* @__PURE__ */ jsx("div", {
18714
- style: {
18715
- width: 320
18732
+ var preparedValue1 = isDatePeriodValue(value) ? value : void 0;
18733
+ return /* @__PURE__ */ jsx(FilterWithDates, _object_spread$r({
18734
+ value: preparedValue1,
18735
+ onChange: function(v) {
18736
+ return onChange(_object_spread_props$q(_object_spread$r({}, v), {
18737
+ periodType: "CUSTOM"
18738
+ }));
18716
18739
  },
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
- });
18740
+ onEndBtnSubmit: function() {
18741
+ return onChange(void 0);
18742
+ },
18743
+ localeKey: translatesLocaleKey,
18744
+ locale: translates,
18745
+ testId: testId !== void 0 ? "".concat(testId, "-dates") : void 0
18746
+ }, filter));
18732
18747
  }
18733
18748
  if (filter.type === "multiSelect") {
18749
+ var preparedValue2 = isMultiSelectValue(value) ? value : void 0;
18734
18750
  return /* @__PURE__ */ jsx(FilterMultiSelect, _object_spread$r({
18735
- value,
18751
+ value: preparedValue2,
18736
18752
  onChange,
18737
18753
  onClose,
18738
18754
  localeKey: translatesLocaleKey,
@@ -18741,8 +18757,9 @@ function Filter(props) {
18741
18757
  }, filter));
18742
18758
  }
18743
18759
  if (filter.type === "interval") {
18760
+ var preparedValue3 = Array.isArray(value) ? value : void 0;
18744
18761
  return /* @__PURE__ */ jsx(FilterInterval, _object_spread$r({
18745
- value,
18762
+ value: preparedValue3,
18746
18763
  onChange,
18747
18764
  localeKey: translatesLocaleKey,
18748
18765
  locale: translates,
@@ -19102,7 +19119,7 @@ function _instanceof$1(left2, right2) {
19102
19119
  }
19103
19120
  }
19104
19121
  function FilterValueView(param) {
19105
- var locale2 = param.locale, localeKey = param.localeKey, filter = param.filter, value = param.value, tweakStyles = param.tweakStyles;
19122
+ var value = param.value, filter = param.filter, locale2 = param.locale, localeKey = param.localeKey, tweakStyles = param.tweakStyles;
19106
19123
  var classes = useStyles$n({
19107
19124
  theme: tweakStyles
19108
19125
  });
@@ -19475,8 +19492,8 @@ function FilterWrapper(param) {
19475
19492
  children: /* @__PURE__ */ jsx(FilterValueView, {
19476
19493
  value,
19477
19494
  filter,
19478
- localeKey,
19479
19495
  locale: locale2,
19496
+ localeKey,
19480
19497
  testId: getTestId(testId, "value"),
19481
19498
  tweakStyles: tweakFilterValueViewStyles
19482
19499
  })
@@ -19503,8 +19520,8 @@ function FilterWrapper(param) {
19503
19520
  return /* @__PURE__ */ jsx(Filter, {
19504
19521
  value,
19505
19522
  filter,
19506
- localeKey,
19507
19523
  locale: locale2,
19524
+ localeKey,
19508
19525
  onClose,
19509
19526
  onChange,
19510
19527
  testId
@@ -19565,7 +19582,7 @@ function _object_spread_props$n(target, source) {
19565
19582
  return target;
19566
19583
  }
19567
19584
  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;
19585
+ 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
19586
  var classes = useStyles$u({
19570
19587
  theme: tweakStyles
19571
19588
  });
@@ -19586,7 +19603,7 @@ function FiltersPane(param) {
19586
19603
  localeKey,
19587
19604
  locale2
19588
19605
  ]);
19589
- var filtersKeys = enabledFilters || Object.keys(filtersConfig);
19606
+ var filtersKeys = enabledFilters !== null && enabledFilters !== void 0 ? enabledFilters : Object.keys(filtersConfig);
19590
19607
  var handleClear = function() {
19591
19608
  if (onClear !== void 0) {
19592
19609
  onClear();
@@ -19638,10 +19655,11 @@ function FiltersPane(param) {
19638
19655
  filtersKeys.map(function(key, index) {
19639
19656
  var _filter_requiredFilledFilters;
19640
19657
  var isLast = index === filtersKeys.length - 1;
19641
- var currentValue = values[key];
19642
- var filter = filtersConfig[key];
19658
+ var filterKey = String(key);
19659
+ var currentValue = values[filterKey];
19660
+ var filter = filtersConfig[filterKey];
19643
19661
  if (filter === void 0) {
19644
- console.error("enabledFilters содержит фильтр ".concat(String(key), ", не описанный в конфиге"));
19662
+ console.error("enabledFilters содержит фильтр ".concat(filterKey, ", не описанный в конфиге"));
19645
19663
  if (isLast) {
19646
19664
  return clearButton;
19647
19665
  }
@@ -19652,15 +19670,18 @@ function FiltersPane(param) {
19652
19670
  locale: locale2,
19653
19671
  localeKey,
19654
19672
  onChange: function(value) {
19655
- return onChangeFilters(_object_spread_props$n(_object_spread$o({}, values), _define_property$p({}, key, value)));
19673
+ return onChangeFilters(_object_spread_props$n(_object_spread$o({}, values), _define_property$p({}, filterKey, value)));
19656
19674
  },
19657
19675
  value: currentValue,
19658
19676
  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
19677
  return !values[item];
19660
19678
  })),
19661
19679
  tweakStyles: tweakFilterWrapperStyles,
19662
- testId: getTestId(testId, "filter-".concat(String(key)))
19663
- }, key);
19680
+ data: shouldRenderDataId ? {
19681
+ id: filterKey
19682
+ } : void 0,
19683
+ testId: getTestId(testId, "filter-".concat(filterKey))
19684
+ }, filterKey);
19664
19685
  if (isLast) {
19665
19686
  return /* @__PURE__ */ jsxs("div", {
19666
19687
  className: classes.filterWithClearButton,
@@ -19670,7 +19691,7 @@ function FiltersPane(param) {
19670
19691
  children: clearButton
19671
19692
  })
19672
19693
  ]
19673
- }, key);
19694
+ }, filterKey);
19674
19695
  }
19675
19696
  return filterWrapper;
19676
19697
  })
@@ -28626,9 +28647,6 @@ var useStyles$9 = createThemedStyles("PhoneInput", {
28626
28647
  var inputStyles = {
28627
28648
  inputWrapper: {
28628
28649
  paddingLeft: COUNTRY_SELECT_WIDTH
28629
- },
28630
- label: {
28631
- marginLeft: COUNTRY_SELECT_WIDTH
28632
28650
  }
28633
28651
  };
28634
28652
  function _array_like_to_array$2(arr, len) {