@true-engineering/true-react-common-ui-kit 3.0.0-alpha.4 → 3.0.0-alpha.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.6",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -1,6 +1,5 @@
1
1
  import { FormEvent, MouseEvent, forwardRef, ChangeEvent } from 'react';
2
2
  import clsx from 'clsx';
3
- import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
4
3
  import { addDataAttributes } from '../../helpers';
5
4
  import { useTweakStyles } from '../../hooks';
6
5
  import { ICommonProps } from '../../types';
@@ -33,7 +32,6 @@ export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(
33
32
  data,
34
33
  isRange,
35
34
  tweakStyles,
36
- testId,
37
35
  onClick,
38
36
  onChange,
39
37
  ...inputProps
@@ -70,12 +68,7 @@ export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(
70
68
  };
71
69
 
72
70
  return (
73
- <div
74
- className={clsx(classes.root, className)}
75
- onClick={onClick}
76
- {...addDataTestId(testId)}
77
- {...addDataAttributes(data)}
78
- >
71
+ <div className={clsx(classes.root, className)} onClick={onClick} {...addDataAttributes(data)}>
79
72
  <Input
80
73
  {...inputProps}
81
74
  ref={ref}
@@ -84,7 +77,6 @@ export const DateInput = forwardRef<HTMLInputElement, IDateInputProps>(
84
77
  placeholder={
85
78
  placeholder ?? (isRange ? EMPTY_DATE_RANGE_INPUT_VALUE : EMPTY_DATE_INPUT_VALUE)
86
79
  }
87
- testId={getTestId(testId, 'input')}
88
80
  tweakStyles={tweakInputStyles}
89
81
  onChange={handleChange}
90
82
  beforeMaskedStateChange={beforeMaskedStateChange}
@@ -47,6 +47,7 @@ const Template: ComponentStory<typeof DatePicker> = (args) => {
47
47
  <DatePicker
48
48
  {...args}
49
49
  locale={ru}
50
+ testId="datepicker"
50
51
  months={months}
51
52
  selectedDate={date}
52
53
  startDate={startDate}
@@ -4,8 +4,6 @@ import 'react-datepicker/dist/react-datepicker.css';
4
4
  import clsx from 'clsx';
5
5
  import { isAfter, isBefore, isValid } from 'date-fns';
6
6
  import {
7
- addDataTestId,
8
- getTestId,
9
7
  isEmpty,
10
8
  isNotEmpty,
11
9
  isStringNotEmpty,
@@ -41,7 +39,6 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
41
39
  (
42
40
  {
43
41
  data,
44
- testId,
45
42
  selectedDate = null,
46
43
  minDate,
47
44
  maxDate,
@@ -126,7 +123,6 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
126
123
  iconType: isClearable && hasDateInputValue ? undefined : 'calendar',
127
124
  tweakStyles: tweakDateInputStyles,
128
125
  ...(isRange ? { startDate: startDateValue, endDate: endDateValue } : { date: dateValue }),
129
- testId: getTestId(testId, 'input'),
130
126
  };
131
127
 
132
128
  const handleChangeDate = (value: Date | null, event?: SyntheticEvent) => {
@@ -236,7 +232,7 @@ export const DatePicker = forwardRef<ReactDatePicker, IDatePickerProps>(
236
232
  }, [selectedDate, startDate, endDate]);
237
233
 
238
234
  return (
239
- <div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
235
+ <div className={classes.root} {...addDataAttributes(data)}>
240
236
  <DatePickerComponent
241
237
  ref={ref}
242
238
  minDate={minDate}
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, RefObject, useCallback, useEffect, useRef, useState } from 'react';
2
2
  import clsx from 'clsx';
3
- import { addDataTestId } from '@true-engineering/true-react-platform-helpers';
3
+ import { addDataTestId, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
4
4
  import { addDataAttributes } from '../../helpers';
5
5
  import { useTweakStyles } from '../../hooks';
6
6
  import { ICommonProps } from '../../types';
@@ -20,6 +20,9 @@ export interface IFlexibleTableProps<Values extends Record<string, any>>
20
20
  isHorizontallyScrollable?: boolean;
21
21
  isFirstColumnSticky?: boolean;
22
22
  infinityScrollConfig?: IInfinityScrollConfig;
23
+ /**
24
+ * @default Индекс строки
25
+ */
23
26
  uniqueField?: keyof Values;
24
27
  onHeadClick?: (column: keyof Values) => void;
25
28
  // TODO: Заменить string на Generic Values[uniqueField]
@@ -42,7 +45,7 @@ export function FlexibleTable<Values extends Record<string, any>>({
42
45
  isHorizontallyScrollable,
43
46
  isFirstColumnSticky,
44
47
  infinityScrollConfig,
45
- uniqueField = 'id',
48
+ uniqueField,
46
49
  onHeadClick,
47
50
  onRowHover,
48
51
  onRowClick,
@@ -171,7 +174,7 @@ export function FlexibleTable<Values extends Record<string, any>>({
171
174
  onRowHover={onRowHover}
172
175
  enabledColumns={enabledColumns}
173
176
  config={config}
174
- key={item[uniqueField] ?? i}
177
+ key={isNotEmpty(uniqueField) ? item[uniqueField] : i}
175
178
  rowAttributes={rowAttributes}
176
179
  tweakStyles={tweakTableRowStyles}
177
180
  expandableRowComponent={expandableRowComponent}