@true-engineering/true-react-common-ui-kit 3.9.0 → 3.9.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.
Files changed (108) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +6 -0
  3. package/dist/true-react-common-ui-kit.js +61 -60
  4. package/dist/true-react-common-ui-kit.js.map +1 -1
  5. package/dist/true-react-common-ui-kit.umd.cjs +61 -60
  6. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  7. package/package.json +1 -1
  8. package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
  9. package/src/components/AccountInfo/AccountInfo.tsx +80 -80
  10. package/src/components/AddButton/AddButton.stories.tsx +21 -21
  11. package/src/components/AddButton/AddButton.tsx +52 -52
  12. package/src/components/Button/Button.stories.tsx +56 -56
  13. package/src/components/Button/Button.tsx +129 -129
  14. package/src/components/Checkbox/Checkbox.stories.tsx +28 -28
  15. package/src/components/CloseButton/CloseButton.tsx +34 -34
  16. package/src/components/Colors/Colors.stories.tsx +7 -7
  17. package/src/components/DateInput/DateInput.tsx +90 -90
  18. package/src/components/DateInput/constants.ts +2 -2
  19. package/src/components/DatePicker/DatePicker.tsx +308 -308
  20. package/src/components/Description/Description.stories.tsx +27 -27
  21. package/src/components/Description/Description.tsx +61 -61
  22. package/src/components/FiltersPane/FiltersPane.tsx +158 -158
  23. package/src/components/FiltersPane/components/Filter/Filter.tsx +203 -203
  24. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
  25. package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
  26. package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
  27. package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +167 -167
  28. package/src/components/Flag/Flag.stories.tsx +29 -29
  29. package/src/components/Flag/Flag.tsx +26 -26
  30. package/src/components/Flag/augment.d.ts +1 -1
  31. package/src/components/FlexibleTable/FlexibleTable.stories.tsx +267 -267
  32. package/src/components/FlexibleTable/FlexibleTable.styles.ts +110 -110
  33. package/src/components/FlexibleTable/FlexibleTable.tsx +271 -271
  34. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +38 -38
  35. package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +83 -83
  36. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
  37. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +196 -196
  38. package/src/components/FlexibleTable/helpers.ts +13 -13
  39. package/src/components/FlexibleTable/types.ts +52 -52
  40. package/src/components/Icon/Icon.stories.tsx +86 -86
  41. package/src/components/Icon/complexIcons/augment.d.ts +1 -1
  42. package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
  43. package/src/components/Icon/complexIcons/index.ts +1 -1
  44. package/src/components/IncrementInput/IncrementInput.tsx +105 -105
  45. package/src/components/Input/Input.tsx +297 -297
  46. package/src/components/Input/types.ts +32 -32
  47. package/src/components/List/List.stories.tsx +70 -70
  48. package/src/components/List/List.tsx +33 -33
  49. package/src/components/List/components/ListItem/ListItem.tsx +57 -57
  50. package/src/components/Modal/Modal.stories.tsx +105 -105
  51. package/src/components/Modal/Modal.tsx +196 -196
  52. package/src/components/MoreMenu/MoreMenu.styles.ts +68 -68
  53. package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
  54. package/src/components/MultiSelect/MultiSelect.tsx +106 -106
  55. package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
  56. package/src/components/MultiSelectList/MultiSelectList.tsx +461 -461
  57. package/src/components/Notification/Notification.stories.tsx +46 -46
  58. package/src/components/Notification/Notification.tsx +69 -69
  59. package/src/components/NumberInput/NumberInput.tsx +137 -137
  60. package/src/components/NumberInput/index.ts +1 -1
  61. package/src/components/PhoneInput/PhoneInput.tsx +214 -214
  62. package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
  63. package/src/components/PhoneInput/types.ts +16 -16
  64. package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
  65. package/src/components/RadioButton/RadioButton.tsx +57 -57
  66. package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
  67. package/src/components/Select/CustomSelect.stories.tsx +217 -217
  68. package/src/components/Select/MultiSelect.stories.tsx +240 -240
  69. package/src/components/Select/Select.stories.tsx +235 -235
  70. package/src/components/Select/constants.ts +2 -2
  71. package/src/components/Select/types.ts +1 -1
  72. package/src/components/Selector/Selector.stories.tsx +62 -62
  73. package/src/components/Selector/Selector.styles.ts +164 -164
  74. package/src/components/Selector/Selector.tsx +115 -115
  75. package/src/components/Selector/index.ts +2 -2
  76. package/src/components/Selector/types.ts +12 -12
  77. package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
  78. package/src/components/SmartInput/SmartInput.tsx +134 -134
  79. package/src/components/Status/Status.stories.tsx +73 -73
  80. package/src/components/Status/Status.styles.ts +143 -143
  81. package/src/components/Status/Status.tsx +49 -49
  82. package/src/components/Status/constants.ts +11 -11
  83. package/src/components/Status/index.ts +3 -3
  84. package/src/components/Status/types.ts +5 -5
  85. package/src/components/Switch/Switch.stories.tsx +40 -40
  86. package/src/components/Switch/Switch.tsx +75 -75
  87. package/src/components/TextArea/TextArea.tsx +180 -180
  88. package/src/components/TextButton/TextButton.stories.tsx +46 -46
  89. package/src/components/TextButton/TextButton.styles.ts +129 -129
  90. package/src/components/TextButton/TextButton.tsx +103 -103
  91. package/src/components/TextButton/index.ts +4 -4
  92. package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
  93. package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
  94. package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
  95. package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
  96. package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
  97. package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
  98. package/src/components/Toaster/Toaster.stories.tsx +30 -30
  99. package/src/components/Toaster/Toaster.tsx +108 -108
  100. package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
  101. package/src/components/Tooltip/Tooltip.tsx +35 -35
  102. package/src/components/Tooltip/types.ts +1 -1
  103. package/src/components/WithPopup/WithPopup.tsx +1 -0
  104. package/src/helpers/popper-helpers.ts +17 -17
  105. package/src/hooks/use-dropdown.ts +84 -84
  106. package/src/hooks/use-is-mounted.ts +15 -15
  107. package/src/theme/helpers.ts +76 -76
  108. package/src/vite-env.d.ts +1 -1
@@ -1,61 +1,61 @@
1
- import { FC, useState } from 'react';
2
- import { addDataTestId } from '@true-engineering/true-react-platform-helpers';
3
- import { addDataAttributes } from '../../helpers';
4
- import { ICommonProps } from '../../types';
5
- import { LINK_REGEXP } from './constants';
6
- import { useStyles, IDescriptionStyles } from './Description.styles';
7
-
8
- export interface IDescriptionProps extends ICommonProps<IDescriptionStyles> {
9
- text: string;
10
- moreTitle?: string;
11
- lessTitle?: string;
12
- /** @default 150 */
13
- truncateIndex?: number;
14
- /** @default true */
15
- isAlwaysOpen?: boolean;
16
- }
17
-
18
- export const Description: FC<IDescriptionProps> = ({
19
- text,
20
- moreTitle,
21
- lessTitle,
22
- truncateIndex = 150,
23
- isAlwaysOpen = true,
24
- testId,
25
- data,
26
- tweakStyles,
27
- }) => {
28
- const classes = useStyles({ theme: tweakStyles });
29
-
30
- const isTooShort = text.length < truncateIndex;
31
- const [isOpen, setIsOpen] = useState(isAlwaysOpen);
32
- const link = text.match(LINK_REGEXP);
33
- const linkText = link && link[0];
34
- const textWithNoLink = text.replace(LINK_REGEXP, '');
35
-
36
- const shortText = text.slice(0, text.slice(0, truncateIndex).lastIndexOf(' '));
37
-
38
- return (
39
- <div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
40
- {isAlwaysOpen || isOpen || isTooShort ? (
41
- <div>
42
- <span>{textWithNoLink} </span>
43
- {!!linkText && (
44
- <a className={classes.link} href={linkText} target="_blank" rel="noopener noreferrer">
45
- {linkText}
46
- </a>
47
- )}
48
- </div>
49
- ) : (
50
- <div>
51
- <span>{shortText}</span>
52
- </div>
53
- )}
54
- {isAlwaysOpen || isTooShort ? undefined : (
55
- <div className={classes.button} onClick={() => setIsOpen(!isOpen)}>
56
- {isOpen ? lessTitle : moreTitle}
57
- </div>
58
- )}
59
- </div>
60
- );
61
- };
1
+ import { FC, useState } from 'react';
2
+ import { addDataTestId } from '@true-engineering/true-react-platform-helpers';
3
+ import { addDataAttributes } from '../../helpers';
4
+ import { ICommonProps } from '../../types';
5
+ import { LINK_REGEXP } from './constants';
6
+ import { useStyles, IDescriptionStyles } from './Description.styles';
7
+
8
+ export interface IDescriptionProps extends ICommonProps<IDescriptionStyles> {
9
+ text: string;
10
+ moreTitle?: string;
11
+ lessTitle?: string;
12
+ /** @default 150 */
13
+ truncateIndex?: number;
14
+ /** @default true */
15
+ isAlwaysOpen?: boolean;
16
+ }
17
+
18
+ export const Description: FC<IDescriptionProps> = ({
19
+ text,
20
+ moreTitle,
21
+ lessTitle,
22
+ truncateIndex = 150,
23
+ isAlwaysOpen = true,
24
+ testId,
25
+ data,
26
+ tweakStyles,
27
+ }) => {
28
+ const classes = useStyles({ theme: tweakStyles });
29
+
30
+ const isTooShort = text.length < truncateIndex;
31
+ const [isOpen, setIsOpen] = useState(isAlwaysOpen);
32
+ const link = text.match(LINK_REGEXP);
33
+ const linkText = link && link[0];
34
+ const textWithNoLink = text.replace(LINK_REGEXP, '');
35
+
36
+ const shortText = text.slice(0, text.slice(0, truncateIndex).lastIndexOf(' '));
37
+
38
+ return (
39
+ <div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
40
+ {isAlwaysOpen || isOpen || isTooShort ? (
41
+ <div>
42
+ <span>{textWithNoLink} </span>
43
+ {!!linkText && (
44
+ <a className={classes.link} href={linkText} target="_blank" rel="noopener noreferrer">
45
+ {linkText}
46
+ </a>
47
+ )}
48
+ </div>
49
+ ) : (
50
+ <div>
51
+ <span>{shortText}</span>
52
+ </div>
53
+ )}
54
+ {isAlwaysOpen || isTooShort ? undefined : (
55
+ <div className={classes.button} onClick={() => setIsOpen(!isOpen)}>
56
+ {isOpen ? lessTitle : moreTitle}
57
+ </div>
58
+ )}
59
+ </div>
60
+ );
61
+ };
@@ -1,158 +1,158 @@
1
- import { useMemo, useRef } from 'react';
2
- import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
3
- import { addDataAttributes } from '../../helpers';
4
- import { useTweakStyles } from '../../hooks';
5
- import { ICommonProps } from '../../types';
6
- import { Button } from '../Button';
7
- import { Icon } from '../Icon';
8
- import { FilterWrapper, IFiltersPaneSearchProps, FiltersPaneSearch } from './components';
9
- import { getLocale } from './helpers';
10
- import { ConfigType, IFilterLocaleKey, IPartialFilterLocale } from './types';
11
- import { useStyles, IFiltersPaneStyles, clearButtonStyles } from './FiltersPane.styles';
12
-
13
- export interface IFiltersPaneProps<Values, Content = Values>
14
- extends ICommonProps<IFiltersPaneStyles> {
15
- filtersConfig: ConfigType<Values>;
16
- enabledFilters?: Array<keyof ConfigType<Values>>;
17
- /** @default {} */
18
- values?: Partial<Values>;
19
- search?: IFiltersPaneSearchProps<keyof Content>;
20
- localeKey?: IFilterLocaleKey;
21
- locale?: IPartialFilterLocale;
22
- /** @default false */
23
- isDisabled?: boolean;
24
- /** @default true */
25
- hasClearButton?: boolean;
26
- onChangeFilters: (values: Partial<Values>) => void;
27
- onSettingsButtonClick?: () => void;
28
- onClear?: () => void;
29
- }
30
-
31
- export function FiltersPane<Values extends Record<string, unknown>, Content = Values>({
32
- data,
33
- tweakStyles,
34
- filtersConfig,
35
- enabledFilters,
36
- values = {} as Values,
37
- localeKey,
38
- locale,
39
- search,
40
- isDisabled = false,
41
- hasClearButton = true,
42
- testId,
43
- onChangeFilters,
44
- onSettingsButtonClick,
45
- onClear,
46
- }: IFiltersPaneProps<Values, Content>): JSX.Element {
47
- const classes = useStyles({ theme: tweakStyles });
48
-
49
- const tweakClearButtonStyles = useTweakStyles({
50
- innerStyles: clearButtonStyles,
51
- tweakStyles,
52
- className: 'tweakClearButton',
53
- currentComponentName: 'FiltersPane',
54
- });
55
-
56
- const translates = useMemo(() => getLocale(localeKey, locale), [localeKey, locale]);
57
-
58
- const ref = useRef<HTMLDivElement>(null);
59
-
60
- const filtersKeys = enabledFilters || Object.keys(filtersConfig);
61
-
62
- const handleClear = () => {
63
- if (onClear !== undefined) {
64
- onClear();
65
- return;
66
- }
67
- onChangeFilters({});
68
- if (search !== undefined) {
69
- search.onChange({});
70
- }
71
- };
72
-
73
- const shouldShowClearButton =
74
- hasClearButton &&
75
- (search !== undefined ||
76
- filtersKeys.filter((key) => filtersConfig[key] !== undefined).length > 0);
77
-
78
- const clearButton = (
79
- <div className={classes.clear}>
80
- <Button
81
- onClick={handleClear}
82
- size="s"
83
- view="text"
84
- isDisabled={isDisabled}
85
- testId={getTestId(testId, 'clear-button')}
86
- tweakStyles={tweakClearButtonStyles}
87
- >
88
- {translates.clear}
89
- </Button>
90
- </div>
91
- );
92
-
93
- return (
94
- <div className={classes.root} ref={ref} {...addDataTestId(testId)} {...addDataAttributes(data)}>
95
- {/* Settings */}
96
- {onSettingsButtonClick !== undefined && (
97
- <div
98
- className={classes.settings}
99
- tabIndex={0}
100
- {...addDataTestId(testId, 'settings-button')}
101
- onClick={!isDisabled ? onSettingsButtonClick : undefined}
102
- >
103
- <div className={classes.settingsIcon}>
104
- <Icon type="filter" />
105
- </div>
106
- </div>
107
- )}
108
- {/* Search */}
109
- {search !== undefined && (
110
- <FiltersPaneSearch
111
- {...search}
112
- locale={getLocale(search.localeKey ?? localeKey, search.locale, locale)}
113
- localeKey={search.localeKey ?? localeKey}
114
- isDisabled={search.isDisabled ?? isDisabled}
115
- testId={getTestId(testId, 'search')}
116
- />
117
- )}
118
- {/* Filters */}
119
- {filtersKeys.map((key, index) => {
120
- const isLast = index === filtersKeys.length - 1;
121
- const currentValue = values[key];
122
- const filter = filtersConfig[key];
123
- if (filter === undefined) {
124
- console.error(`enabledFilters содержит фильтр ${String(key)}, не описанный в конфиге`);
125
- if (isLast) {
126
- return clearButton;
127
- }
128
- return null;
129
- }
130
-
131
- const filterWrapper = (
132
- <FilterWrapper
133
- filter={filter}
134
- locale={locale}
135
- localeKey={localeKey}
136
- onChange={(value) => onChangeFilters({ ...values, [key]: value })}
137
- value={currentValue}
138
- key={key as string}
139
- isDisabled={isDisabled || filter?.requiredFilledFilters?.some((item) => !values[item])}
140
- filtersPaneRef={ref}
141
- testId={getTestId(testId, `filter-${String(key)}`)}
142
- />
143
- );
144
-
145
- if (isLast) {
146
- return (
147
- <div className={classes.filterWithClearButton} key={key as string}>
148
- {filterWrapper}
149
- {shouldShowClearButton && <>{clearButton}</>}
150
- </div>
151
- );
152
- }
153
-
154
- return filterWrapper;
155
- })}
156
- </div>
157
- );
158
- }
1
+ import { useMemo, useRef } from 'react';
2
+ import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
3
+ import { addDataAttributes } from '../../helpers';
4
+ import { useTweakStyles } from '../../hooks';
5
+ import { ICommonProps } from '../../types';
6
+ import { Button } from '../Button';
7
+ import { Icon } from '../Icon';
8
+ import { FilterWrapper, IFiltersPaneSearchProps, FiltersPaneSearch } from './components';
9
+ import { getLocale } from './helpers';
10
+ import { ConfigType, IFilterLocaleKey, IPartialFilterLocale } from './types';
11
+ import { useStyles, IFiltersPaneStyles, clearButtonStyles } from './FiltersPane.styles';
12
+
13
+ export interface IFiltersPaneProps<Values, Content = Values>
14
+ extends ICommonProps<IFiltersPaneStyles> {
15
+ filtersConfig: ConfigType<Values>;
16
+ enabledFilters?: Array<keyof ConfigType<Values>>;
17
+ /** @default {} */
18
+ values?: Partial<Values>;
19
+ search?: IFiltersPaneSearchProps<keyof Content>;
20
+ localeKey?: IFilterLocaleKey;
21
+ locale?: IPartialFilterLocale;
22
+ /** @default false */
23
+ isDisabled?: boolean;
24
+ /** @default true */
25
+ hasClearButton?: boolean;
26
+ onChangeFilters: (values: Partial<Values>) => void;
27
+ onSettingsButtonClick?: () => void;
28
+ onClear?: () => void;
29
+ }
30
+
31
+ export function FiltersPane<Values extends Record<string, unknown>, Content = Values>({
32
+ data,
33
+ tweakStyles,
34
+ filtersConfig,
35
+ enabledFilters,
36
+ values = {} as Values,
37
+ localeKey,
38
+ locale,
39
+ search,
40
+ isDisabled = false,
41
+ hasClearButton = true,
42
+ testId,
43
+ onChangeFilters,
44
+ onSettingsButtonClick,
45
+ onClear,
46
+ }: IFiltersPaneProps<Values, Content>): JSX.Element {
47
+ const classes = useStyles({ theme: tweakStyles });
48
+
49
+ const tweakClearButtonStyles = useTweakStyles({
50
+ innerStyles: clearButtonStyles,
51
+ tweakStyles,
52
+ className: 'tweakClearButton',
53
+ currentComponentName: 'FiltersPane',
54
+ });
55
+
56
+ const translates = useMemo(() => getLocale(localeKey, locale), [localeKey, locale]);
57
+
58
+ const ref = useRef<HTMLDivElement>(null);
59
+
60
+ const filtersKeys = enabledFilters || Object.keys(filtersConfig);
61
+
62
+ const handleClear = () => {
63
+ if (onClear !== undefined) {
64
+ onClear();
65
+ return;
66
+ }
67
+ onChangeFilters({});
68
+ if (search !== undefined) {
69
+ search.onChange({});
70
+ }
71
+ };
72
+
73
+ const shouldShowClearButton =
74
+ hasClearButton &&
75
+ (search !== undefined ||
76
+ filtersKeys.filter((key) => filtersConfig[key] !== undefined).length > 0);
77
+
78
+ const clearButton = (
79
+ <div className={classes.clear}>
80
+ <Button
81
+ onClick={handleClear}
82
+ size="s"
83
+ view="text"
84
+ isDisabled={isDisabled}
85
+ testId={getTestId(testId, 'clear-button')}
86
+ tweakStyles={tweakClearButtonStyles}
87
+ >
88
+ {translates.clear}
89
+ </Button>
90
+ </div>
91
+ );
92
+
93
+ return (
94
+ <div className={classes.root} ref={ref} {...addDataTestId(testId)} {...addDataAttributes(data)}>
95
+ {/* Settings */}
96
+ {onSettingsButtonClick !== undefined && (
97
+ <div
98
+ className={classes.settings}
99
+ tabIndex={0}
100
+ {...addDataTestId(testId, 'settings-button')}
101
+ onClick={!isDisabled ? onSettingsButtonClick : undefined}
102
+ >
103
+ <div className={classes.settingsIcon}>
104
+ <Icon type="filter" />
105
+ </div>
106
+ </div>
107
+ )}
108
+ {/* Search */}
109
+ {search !== undefined && (
110
+ <FiltersPaneSearch
111
+ {...search}
112
+ locale={getLocale(search.localeKey ?? localeKey, search.locale, locale)}
113
+ localeKey={search.localeKey ?? localeKey}
114
+ isDisabled={search.isDisabled ?? isDisabled}
115
+ testId={getTestId(testId, 'search')}
116
+ />
117
+ )}
118
+ {/* Filters */}
119
+ {filtersKeys.map((key, index) => {
120
+ const isLast = index === filtersKeys.length - 1;
121
+ const currentValue = values[key];
122
+ const filter = filtersConfig[key];
123
+ if (filter === undefined) {
124
+ console.error(`enabledFilters содержит фильтр ${String(key)}, не описанный в конфиге`);
125
+ if (isLast) {
126
+ return clearButton;
127
+ }
128
+ return null;
129
+ }
130
+
131
+ const filterWrapper = (
132
+ <FilterWrapper
133
+ filter={filter}
134
+ locale={locale}
135
+ localeKey={localeKey}
136
+ onChange={(value) => onChangeFilters({ ...values, [key]: value })}
137
+ value={currentValue}
138
+ key={key as string}
139
+ isDisabled={isDisabled || filter?.requiredFilledFilters?.some((item) => !values[item])}
140
+ filtersPaneRef={ref}
141
+ testId={getTestId(testId, `filter-${String(key)}`)}
142
+ />
143
+ );
144
+
145
+ if (isLast) {
146
+ return (
147
+ <div className={classes.filterWithClearButton} key={key as string}>
148
+ {filterWrapper}
149
+ {shouldShowClearButton && <>{clearButton}</>}
150
+ </div>
151
+ );
152
+ }
153
+
154
+ return filterWrapper;
155
+ })}
156
+ </div>
157
+ );
158
+ }