@true-engineering/true-react-common-ui-kit 4.0.0-alpha1 → 4.0.0-alpha11
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 +11 -567
- package/dist/components/Button/Button.styles.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.styles.d.ts +1 -1
- package/dist/components/ControlWrapper/ControlWrapper.d.ts +2 -0
- package/dist/components/ControlWrapper/ControlWrapper.styles.d.ts +2 -1
- package/dist/components/ControlWrapper/index.d.ts +1 -0
- package/dist/components/ControlWrapper/types.d.ts +3 -0
- package/dist/components/DatePicker/DatePicker.d.ts +2 -2
- package/dist/components/DatePicker/helpers.d.ts +3 -0
- package/dist/components/DatePicker/types.d.ts +3 -1
- package/dist/components/FiltersPane/FiltersPane.d.ts +4 -2
- package/dist/components/FiltersPane/components/Filter/Filter.d.ts +2 -2
- package/dist/components/FiltersPane/components/Filter/helpers.d.ts +4 -0
- package/dist/components/FiltersPane/components/FilterInterval/FilterInterval.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterSelect/FilterSelect.styles.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +3 -1
- package/dist/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.d.ts +2 -2
- package/dist/components/FiltersPane/components/FilterWrapper/FilterWrapper.d.ts +2 -2
- package/dist/components/FiltersPane/types.d.ts +15 -5
- package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
- package/dist/components/Flag/customFlags/index.d.ts +1 -0
- package/dist/components/FlexibleTable/FlexibleTable.d.ts +4 -2
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +6 -6
- package/dist/components/FlexibleTable/constants.d.ts +18 -2
- package/dist/components/FlexibleTable/types.d.ts +1 -1
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/IconButton/IconButton.styles.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +3 -2
- package/dist/components/Input/InputBase.d.ts +2 -2
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/index.d.ts +2 -1
- package/dist/components/List/types.d.ts +4 -0
- package/dist/components/Modal/Modal.styles.d.ts +1 -1
- package/dist/components/Notification/Notification.styles.d.ts +1 -1
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +2 -2
- package/dist/components/SearchInput/SearchInput.styles.d.ts +3 -5
- package/dist/components/Select/Select.d.ts +5 -3
- package/dist/components/Select/Select.styles.d.ts +4 -4
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Status/Status.styles.d.ts +3 -2
- package/dist/components/Status/constants.d.ts +0 -1
- package/dist/components/Status/types.d.ts +5 -2
- package/dist/components/TextArea/TextArea.d.ts +2 -3
- package/dist/components/TextArea/index.d.ts +0 -1
- package/dist/components/TextButton/TextButton.styles.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/WithMessages/WithMessages.styles.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.d.ts +21 -6
- package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
- package/dist/components/WithPopup/helpers.d.ts +2 -0
- package/dist/components/WithPopup/types.d.ts +3 -0
- package/dist/components/WithTooltip/WithTooltip.styles.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-merge.d.ts +1 -0
- package/dist/hooks/use-mixed-styles.d.ts +3 -1
- package/dist/hooks/use-tweak-styles.d.ts +5 -5
- package/dist/theme/Provider.d.ts +6 -3
- package/dist/theme/common.d.ts +4 -2
- package/dist/theme/create-themed-styles.d.ts +2 -0
- package/dist/theme/helpers.d.ts +9 -3
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/true-jss/ThemedStylesManager.d.ts +18 -0
- package/dist/theme/true-jss/TweakStylesManager.d.ts +34 -0
- package/dist/theme/true-jss/index.d.ts +2 -0
- package/dist/theme/true-jss/jss-context.d.ts +9 -0
- package/dist/theme/types.d.ts +4 -2
- package/dist/true-react-common-ui-kit.js +7308 -6412
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +7136 -6241
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +10 -3
- package/package.json +1 -1
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +6 -5
- package/src/components/ControlWrapper/ControlWrapper.tsx +8 -2
- package/src/components/ControlWrapper/index.ts +1 -0
- package/src/components/ControlWrapper/types.ts +3 -0
- package/src/components/DatePicker/DatePicker.tsx +9 -4
- package/src/components/DatePicker/helpers.ts +13 -1
- package/src/components/DatePicker/types.ts +4 -1
- package/src/components/FiltersPane/FiltersPane.stories.tsx +4 -2
- package/src/components/FiltersPane/FiltersPane.tsx +14 -9
- package/src/components/FiltersPane/components/Filter/Filter.tsx +24 -17
- package/src/components/FiltersPane/components/Filter/helpers.ts +18 -0
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.styles.ts +1 -1
- package/src/components/FiltersPane/components/FilterInterval/FilterInterval.tsx +6 -1
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +27 -22
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.styles.ts +1 -0
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +1 -1
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +7 -5
- package/src/components/FiltersPane/types.ts +23 -5
- package/src/components/Flag/Flag.stories.tsx +2 -1
- package/src/components/Flag/Flag.styles.ts +4 -0
- package/src/components/Flag/Flag.tsx +23 -9
- package/src/components/Flag/customFlags/AB.svg +1 -0
- package/src/components/Flag/customFlags/OS.svg +1 -0
- package/src/components/Flag/customFlags/augment.d.ts +1 -0
- package/src/components/Flag/customFlags/customFlags.ts +13 -0
- package/src/components/Flag/customFlags/index.ts +1 -0
- package/src/components/FlexibleTable/FlexibleTable.tsx +13 -12
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +9 -8
- package/src/components/FlexibleTable/constants.ts +6 -3
- package/src/components/FlexibleTable/types.ts +1 -5
- package/src/components/IncrementInput/IncrementInput.styles.ts +1 -1
- package/src/components/Input/Input.tsx +5 -3
- package/src/components/Input/InputBase.tsx +22 -19
- package/src/components/List/List.tsx +5 -2
- package/src/components/List/index.ts +2 -1
- package/src/components/List/types.ts +5 -0
- package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
- package/src/components/PhoneInput/PhoneInput.tsx +5 -2
- package/src/components/SearchInput/SearchInput.styles.ts +16 -29
- package/src/components/SearchInput/SearchInput.tsx +17 -30
- package/src/components/Select/Select.tsx +12 -2
- package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
- package/src/components/Select/index.ts +1 -1
- package/src/components/Status/Status.stories.tsx +54 -1
- package/src/components/Status/Status.styles.ts +2 -37
- package/src/components/Status/constants.ts +0 -10
- package/src/components/Status/types.ts +7 -3
- package/src/components/TextArea/TextArea.tsx +29 -14
- package/src/components/TextArea/index.ts +0 -1
- package/src/components/Tooltip/Tooltip.styles.ts +2 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/WithPopup/WithPopup.stories.tsx +1 -0
- package/src/components/WithPopup/WithPopup.styles.ts +2 -0
- package/src/components/WithPopup/WithPopup.tsx +64 -16
- package/src/components/WithPopup/helpers.ts +9 -0
- package/src/components/WithPopup/types.ts +7 -0
- package/src/components/WithTooltip/WithTooltip.styles.ts +6 -0
- package/src/components/WithTooltip/WithTooltip.tsx +7 -2
- package/src/constants/phone-info.ts +20 -33
- package/src/helpers/phone.ts +19 -15
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-merge.ts +8 -0
- package/src/hooks/use-mixed-styles.ts +9 -11
- package/src/hooks/use-tweak-styles.ts +49 -27
- package/src/theme/Provider.tsx +10 -5
- package/src/theme/common.ts +5 -2
- package/src/theme/create-themed-styles.ts +78 -0
- package/src/theme/helpers.ts +39 -39
- package/src/theme/index.ts +2 -0
- package/src/theme/true-jss/ThemedStylesManager.ts +92 -0
- package/src/theme/true-jss/TweakStylesManager.ts +157 -0
- package/src/theme/true-jss/index.ts +2 -0
- package/src/theme/true-jss/jss-context.tsx +34 -0
- package/src/theme/types.ts +4 -2
- package/src/types.ts +17 -4
- package/dist/components/AccountInfo/AccountInfo.stories.d.ts +0 -6
- package/dist/components/AddButton/AddButton.stories.d.ts +0 -6
- package/dist/components/Button/Button.stories.d.ts +0 -6
- package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -8
- package/dist/components/CloseButton/CloseButton.stories.d.ts +0 -5
- package/dist/components/Colors/Colors.stories.d.ts +0 -5
- package/dist/components/ControlWrapper/ControlWrapper.stories.d.ts +0 -6
- package/dist/components/DateInput/DateInput.stories.d.ts +0 -7
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -7
- package/dist/components/Description/Description.stories.d.ts +0 -16
- package/dist/components/FileInput/FileInput.stories.d.ts +0 -7
- package/dist/components/FileItem/FileItem.stories.d.ts +0 -8
- package/dist/components/FiltersPane/FiltersPane.stories.d.ts +0 -31
- package/dist/components/Flag/Flag.stories.d.ts +0 -12
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +0 -19
- package/dist/components/Icon/Icon.stories.d.ts +0 -6
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -6
- package/dist/components/IncrementInput/IncrementInput.stories.d.ts +0 -6
- package/dist/components/Input/Input.stories.d.ts +0 -25
- package/dist/components/List/List.stories.d.ts +0 -5
- package/dist/components/Modal/Modal.stories.d.ts +0 -29
- package/dist/components/MoreMenu/MoreMenu.stories.d.ts +0 -6
- package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -13
- package/dist/components/NewMoreMenu/NewMoreMenu.stories.d.ts +0 -12
- package/dist/components/Notification/Notification.stories.d.ts +0 -8
- package/dist/components/NumberInput/NumberInput.stories.d.ts +0 -7
- package/dist/components/PhoneInput/PhoneInput.stories.d.ts +0 -28
- package/dist/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.stories.d.ts +0 -5
- package/dist/components/RadioButton/RadioButton.stories.d.ts +0 -7
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -16
- package/dist/components/Select/CustomSelect.stories.d.ts +0 -11
- package/dist/components/Select/MultiSelect.stories.d.ts +0 -15
- package/dist/components/Select/Select.stories.d.ts +0 -15
- package/dist/components/Selector/Selector.stories.d.ts +0 -7
- package/dist/components/Skeleton/Skeleton.stories.d.ts +0 -6
- package/dist/components/SmartInput/SmartInput.stories.d.ts +0 -18
- package/dist/components/Status/Status.stories.d.ts +0 -6
- package/dist/components/Switch/Switch.stories.d.ts +0 -16
- package/dist/components/TextArea/TextArea.stories.d.ts +0 -17
- package/dist/components/TextArea/types.d.ts +0 -2
- package/dist/components/TextButton/TextButton.stories.d.ts +0 -6
- package/dist/components/TextWithInfo/TextWithInfo.stories.d.ts +0 -12
- package/dist/components/TextWithTooltip/TextWithTooltip.stories.d.ts +0 -24
- package/dist/components/ThemedPreloader/ThemedPreloader.stories.d.ts +0 -17
- package/dist/components/Toaster/Toaster.stories.d.ts +0 -5
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -5
- package/dist/components/WithMessages/WithMessages.stories.d.ts +0 -7
- package/dist/components/WithPopup/WithPopup.stories.d.ts +0 -16
- package/dist/components/WithTooltip/WithTooltip.stories.d.ts +0 -6
- package/src/components/TextArea/types.ts +0 -6
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { countries } from 'country-flag-icons';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
3
|
import { Flag } from './Flag';
|
|
4
|
+
import { customFlags } from './customFlags';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
title: 'Data Display/Flag',
|
|
7
8
|
component: Flag,
|
|
8
9
|
argTypes: {
|
|
9
|
-
countryCode: { control: 'select', options: countries },
|
|
10
|
+
countryCode: { control: 'select', options: [...countries, ...Object.keys(customFlags)] },
|
|
10
11
|
},
|
|
11
12
|
};
|
|
12
13
|
|
|
@@ -2,6 +2,10 @@ import { colors, ITweakStyles, createThemedStyles } from '../../theme';
|
|
|
2
2
|
|
|
3
3
|
export const useStyles = createThemedStyles('Flag', {
|
|
4
4
|
root: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
boxSizing: 'border-box',
|
|
5
9
|
// приходится хардкодить в компоненте, тк либа Flags выдает флаги с 2-3 пиксельным отступом снизу
|
|
6
10
|
// если будет нужно, то можно вынести border на уровень пропсов
|
|
7
11
|
border: [1, 'solid', colors.BORDER_MAIN],
|
|
@@ -3,6 +3,7 @@ import { hasFlag } from 'country-flag-icons';
|
|
|
3
3
|
import Flags from 'country-flag-icons/react/3x2';
|
|
4
4
|
import { ICommonProps } from '../../types';
|
|
5
5
|
import { Icon } from '../Icon';
|
|
6
|
+
import { customFlags } from './customFlags';
|
|
6
7
|
import { useStyles, IFlagStyles } from './Flag.styles';
|
|
7
8
|
|
|
8
9
|
export interface IFlagProps extends Pick<ICommonProps<IFlagStyles>, 'tweakStyles'> {
|
|
@@ -12,15 +13,28 @@ export interface IFlagProps extends Pick<ICommonProps<IFlagStyles>, 'tweakStyles
|
|
|
12
13
|
|
|
13
14
|
export const Flag: FC<IFlagProps> = ({ countryCode = '', tweakStyles }) => {
|
|
14
15
|
const classes = useStyles({ theme: tweakStyles });
|
|
15
|
-
const
|
|
16
|
+
const countryFlagKey = countryCode.toUpperCase();
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
? Flags[CC as keyof typeof Flags]
|
|
19
|
-
: () => (
|
|
20
|
-
<div className={classes.noFlag}>
|
|
21
|
-
<Icon type="minus" />
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
18
|
+
const hasFlagInLibrary = hasFlag(countryFlagKey);
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
if (hasFlagInLibrary) {
|
|
21
|
+
const FlagComponent = Flags[countryFlagKey as keyof typeof Flags];
|
|
22
|
+
return (
|
|
23
|
+
<div className={classes.root}>
|
|
24
|
+
<FlagComponent />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const CustomFlag = customFlags[countryFlagKey as keyof typeof customFlags];
|
|
30
|
+
|
|
31
|
+
if (CustomFlag !== undefined) {
|
|
32
|
+
return <div className={classes.root} dangerouslySetInnerHTML={{ __html: CustomFlag }} />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className={classes.noFlag}>
|
|
37
|
+
<Icon type="minus" />
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
26
40
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#FFF" d="M0 0h512v341.3H0z"/><g fill="#6DA544"><path d="M0 0h512v48.8H0zM0 97.5h512v48.8H0zM0 195h512v48.8H0zM0 292.6h512v48.8H0z"/></g><path fill="#D80027" d="M0 0h256v146.3H0z"/><path fill="#FFF" d="m116.9 114.4-7.5-14.8V69.9L128 59l18.6 10.9v22.3l7.4-7.4 4.2 3-4.2 11.8-14.9 14.8z"/><circle fill="#FFF" cx="82" cy="82.8" r="5.4"/><circle fill="#FFF" cx="90.8" cy="61.7" r="5.4"/><circle fill="#FFF" cx="106.6" cy="46.2" r="5.4"/><circle fill="#FFF" cx="128" cy="40.8" r="5.4"/><circle fill="#FFF" cx="149.4" cy="46.2" r="5.4"/><circle fill="#FFF" cx="165.2" cy="61.7" r="5.4"/><circle fill="#FFF" cx="174" cy="82.8" r="5.4"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 450 300"><path fill="#FFF" d="M0 0h450v300H0z"/><path fill="red" d="M0 100h450v200H0z"/><path fill="#FFDF00" d="M0 200h450v100H0z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.svg?raw';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './customFlags';
|
|
@@ -34,10 +34,10 @@ export interface IFlexibleTableProps<
|
|
|
34
34
|
| 'uniqueField'
|
|
35
35
|
| 'rowAttributes'
|
|
36
36
|
| 'isFirstColumnSticky'
|
|
37
|
-
| 'isExpandableRowComponentInitiallyOpen'
|
|
38
37
|
| 'expandableRowComponent'
|
|
39
38
|
| 'onRowClick'
|
|
40
39
|
| 'onRowHover'
|
|
40
|
+
| 'rowRef'
|
|
41
41
|
> {
|
|
42
42
|
content: Row[];
|
|
43
43
|
/** @default 'table' */
|
|
@@ -62,6 +62,8 @@ export interface IFlexibleTableProps<
|
|
|
62
62
|
nothingFoundContent?: ReactNode;
|
|
63
63
|
/** @default true */
|
|
64
64
|
shouldRenderHeader?: boolean;
|
|
65
|
+
/** @default false */
|
|
66
|
+
isExpandableRowComponentInitiallyOpen?: boolean | ((row: Row, index: number) => boolean);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export function FlexibleTable<
|
|
@@ -88,6 +90,7 @@ export function FlexibleTable<
|
|
|
88
90
|
tweakStyles,
|
|
89
91
|
shouldRenderHeader = true,
|
|
90
92
|
onHeadClick,
|
|
93
|
+
isExpandableRowComponentInitiallyOpen: isRowInitiallyOpen,
|
|
91
94
|
...restProps
|
|
92
95
|
}: IFlexibleTableProps<Row, HeaderContent, UniqueField>): JSX.Element {
|
|
93
96
|
const classes = useStyles({ theme: tweakStyles });
|
|
@@ -105,11 +108,12 @@ export function FlexibleTable<
|
|
|
105
108
|
|
|
106
109
|
const hasInfiniteScroll = isNotEmpty(infinityScrollConfig);
|
|
107
110
|
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
>
|
|
111
|
+
const getTableRowProps = (
|
|
112
|
+
item: Row,
|
|
113
|
+
index: number,
|
|
114
|
+
): IFlexibleTableRowProps<Row, HeaderContent, UniqueField> => ({
|
|
112
115
|
...restProps,
|
|
116
|
+
item,
|
|
113
117
|
renderMode,
|
|
114
118
|
config,
|
|
115
119
|
columns,
|
|
@@ -118,7 +122,8 @@ export function FlexibleTable<
|
|
|
118
122
|
isFirstColumnSticky,
|
|
119
123
|
isFocusable: isRowFocusable,
|
|
120
124
|
tweakStyles: tweakTableRowStyles,
|
|
121
|
-
|
|
125
|
+
isExpandableRowComponentInitiallyOpen: applyAction(isRowInitiallyOpen, item, index),
|
|
126
|
+
});
|
|
122
127
|
|
|
123
128
|
const getDataScrollAttributeSetter = useCallback(
|
|
124
129
|
(key: string, setter: (el: HTMLDivElement) => boolean) => (el?: HTMLDivElement) => {
|
|
@@ -267,9 +272,7 @@ export function FlexibleTable<
|
|
|
267
272
|
)}
|
|
268
273
|
<Table.Body className={classes.body}>
|
|
269
274
|
{isLoading ? (
|
|
270
|
-
indexMap(6, (i) => (
|
|
271
|
-
<FlexibleTableRow {...tableRowProps} key={i} item={{} as Row} index={i} />
|
|
272
|
-
))
|
|
275
|
+
indexMap(6, (i) => <FlexibleTableRow {...getTableRowProps({} as Row, i)} key={i} />)
|
|
273
276
|
) : (
|
|
274
277
|
<>
|
|
275
278
|
{shouldShowNothingFound && (
|
|
@@ -282,11 +285,9 @@ export function FlexibleTable<
|
|
|
282
285
|
|
|
283
286
|
{content.map((item, i) => (
|
|
284
287
|
<FlexibleTableRow
|
|
285
|
-
{...
|
|
288
|
+
{...getTableRowProps(item, i)}
|
|
286
289
|
isActive={activeRowsSet.has(i)}
|
|
287
290
|
key={isNotEmpty(uniqueField) ? item[uniqueField] : i}
|
|
288
|
-
item={item}
|
|
289
|
-
index={i}
|
|
290
291
|
/>
|
|
291
292
|
))}
|
|
292
293
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ReactNode, useState, memo, MouseEvent } from 'react';
|
|
1
|
+
import { ReactNode, useState, memo, MouseEvent, RefCallback } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
3
|
+
import { isEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
4
|
import { addDataAttributes } from '../../../../helpers';
|
|
5
5
|
import { useTweakStyles } from '../../../../hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { IDataAttributes, ITweakStylesProps } from '../../../../types';
|
|
7
7
|
import { TableRenders } from '../../constants';
|
|
8
8
|
import {
|
|
9
9
|
ITableRow,
|
|
@@ -19,9 +19,8 @@ export interface IFlexibleTableRowProps<
|
|
|
19
19
|
Row extends ITableRow,
|
|
20
20
|
HeaderContent extends IHeaderContent<Row>,
|
|
21
21
|
UniqueField extends keyof Row,
|
|
22
|
-
> extends
|
|
22
|
+
> extends ITweakStylesProps<IFlexibleTableRowStyles> {
|
|
23
23
|
item: Row;
|
|
24
|
-
index: number;
|
|
25
24
|
uniqueField?: UniqueField;
|
|
26
25
|
renderMode: IFlexibleTableRenderMode;
|
|
27
26
|
/** @default false */
|
|
@@ -37,7 +36,8 @@ export interface IFlexibleTableRowProps<
|
|
|
37
36
|
columns: Array<keyof Row & string>;
|
|
38
37
|
rowAttributes?: Array<keyof Row>;
|
|
39
38
|
/** @default false */
|
|
40
|
-
isExpandableRowComponentInitiallyOpen?: boolean
|
|
39
|
+
isExpandableRowComponentInitiallyOpen?: boolean;
|
|
40
|
+
rowRef?: RefCallback<HTMLTableRowElement>;
|
|
41
41
|
/** Возвращает React-элемент, который отрисуется под строкой при нажатии на неё */
|
|
42
42
|
expandableRowComponent?: (item: Row, isOpen: boolean, close: () => void) => ReactNode;
|
|
43
43
|
onRowHover?: (id?: Row[UniqueField]) => void;
|
|
@@ -50,7 +50,6 @@ function FlexibleTableRowInner<
|
|
|
50
50
|
UniqueField extends keyof Row,
|
|
51
51
|
>({
|
|
52
52
|
item,
|
|
53
|
-
index,
|
|
54
53
|
config,
|
|
55
54
|
columns,
|
|
56
55
|
uniqueField,
|
|
@@ -61,6 +60,7 @@ function FlexibleTableRowInner<
|
|
|
61
60
|
isLoading = false,
|
|
62
61
|
rowAttributes,
|
|
63
62
|
isExpandableRowComponentInitiallyOpen = false,
|
|
63
|
+
rowRef,
|
|
64
64
|
tweakStyles,
|
|
65
65
|
expandableRowComponent,
|
|
66
66
|
onRowHover,
|
|
@@ -76,7 +76,7 @@ function FlexibleTableRowInner<
|
|
|
76
76
|
|
|
77
77
|
const [isFocused, setFocused] = useState(false);
|
|
78
78
|
const [nestedComponent, setNestedComponent] = useState<INestedComponent>(() => ({
|
|
79
|
-
isOpen:
|
|
79
|
+
isOpen: isExpandableRowComponentInitiallyOpen,
|
|
80
80
|
}));
|
|
81
81
|
|
|
82
82
|
const isEditable = !isLoading && (isNotEmpty(onRowClick) || isNotEmpty(onRowHover));
|
|
@@ -139,6 +139,7 @@ function FlexibleTableRowInner<
|
|
|
139
139
|
return (
|
|
140
140
|
<>
|
|
141
141
|
<Table.Row
|
|
142
|
+
ref={rowRef}
|
|
142
143
|
className={clsx(classes.root, {
|
|
143
144
|
[classes.active]: isActive,
|
|
144
145
|
[classes.editable]: isEditable,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFlexibleTableRenderElement, IFlexibleTableRenderMode } from './types';
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_DATE_FORMAT = 'dd.MM.yyyy';
|
|
4
4
|
|
|
5
|
-
export const TableRenders
|
|
5
|
+
export const TableRenders = {
|
|
6
6
|
table: { Root: 'table', Head: 'thead', Body: 'tbody', Row: 'tr', Header: 'th', Cell: 'td' },
|
|
7
7
|
divs: { Root: 'div', Head: 'div', Body: 'div', Row: 'div', Header: 'div', Cell: 'div' },
|
|
8
|
-
}
|
|
8
|
+
} satisfies Record<
|
|
9
|
+
IFlexibleTableRenderMode,
|
|
10
|
+
Record<IFlexibleTableRenderElement, keyof JSX.IntrinsicElements>
|
|
11
|
+
>;
|
|
@@ -2,11 +2,7 @@ import { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
|
2
2
|
import { IRenderNode } from '../../types';
|
|
3
3
|
|
|
4
4
|
export type IFlexibleTableRenderMode = 'table' | 'divs';
|
|
5
|
-
|
|
6
|
-
export type IFlexibleTableRender = Record<
|
|
7
|
-
'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell',
|
|
8
|
-
keyof JSX.IntrinsicElements
|
|
9
|
-
>;
|
|
5
|
+
export type IFlexibleTableRenderElement = 'Root' | 'Head' | 'Body' | 'Row' | 'Header' | 'Cell';
|
|
10
6
|
|
|
11
7
|
// TODO: Заменить Record<string, any> на Record<string, unknown>
|
|
12
8
|
export type ITableRow = Record<string, any>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
2
3
|
import { useTweakStyles } from '../../hooks';
|
|
3
4
|
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
4
5
|
import { IInputBaseProps, InputBase } from './InputBase';
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
-
|
|
7
|
+
export interface IInputProps
|
|
8
|
+
extends IInputBaseProps,
|
|
9
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {}
|
|
8
10
|
|
|
9
11
|
export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
10
12
|
({ infoMessage, errorMessage, isInvalid, testId, tweakStyles, ...inputProps }, ref) => {
|
|
@@ -17,7 +19,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
17
19
|
<WithMessages
|
|
18
20
|
errorMessage={errorMessage}
|
|
19
21
|
infoMessage={infoMessage}
|
|
20
|
-
testId={testId}
|
|
22
|
+
testId={getTestId(testId, 'wrapper')}
|
|
21
23
|
tweakStyles={tweakWithMessagesStyles}
|
|
22
24
|
>
|
|
23
25
|
<InputBase
|
|
@@ -28,6 +28,7 @@ import { IInputStyles, useStyles } from './Input.styles';
|
|
|
28
28
|
|
|
29
29
|
export interface IInputBaseProps
|
|
30
30
|
extends ICommonProps<IInputStyles>,
|
|
31
|
+
Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'>,
|
|
31
32
|
Pick<
|
|
32
33
|
IControlWrapperProps,
|
|
33
34
|
| 'label'
|
|
@@ -38,20 +39,7 @@ export interface IInputBaseProps
|
|
|
38
39
|
| 'isLoading'
|
|
39
40
|
| 'isDisabled'
|
|
40
41
|
| 'onIconClick'
|
|
41
|
-
|
|
42
|
-
Pick<
|
|
43
|
-
InputHTMLAttributes<HTMLInputElement>,
|
|
44
|
-
| 'type'
|
|
45
|
-
| 'inputMode'
|
|
46
|
-
| 'autoComplete'
|
|
47
|
-
| 'name'
|
|
48
|
-
| 'maxLength'
|
|
49
|
-
| 'tabIndex'
|
|
50
|
-
| 'placeholder'
|
|
51
|
-
| 'onFocus'
|
|
52
|
-
| 'onBlur'
|
|
53
|
-
| 'onPaste'
|
|
54
|
-
| 'onKeyDown'
|
|
42
|
+
| 'size'
|
|
55
43
|
>,
|
|
56
44
|
Pick<
|
|
57
45
|
Partial<ReactInputMaskBaseProps>,
|
|
@@ -71,7 +59,7 @@ export interface IInputBaseProps
|
|
|
71
59
|
isAutoSized?: boolean;
|
|
72
60
|
/** @default false */
|
|
73
61
|
shouldAlwaysShowPlaceholder?: boolean;
|
|
74
|
-
onChange(value: string, event: IChangeInputEvent)
|
|
62
|
+
onChange: (value: string, event: IChangeInputEvent) => void;
|
|
75
63
|
}
|
|
76
64
|
|
|
77
65
|
export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
@@ -96,6 +84,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
96
84
|
units,
|
|
97
85
|
testId,
|
|
98
86
|
tabIndex,
|
|
87
|
+
shouldAlwaysShowPlaceholder,
|
|
99
88
|
onChange,
|
|
100
89
|
onPaste,
|
|
101
90
|
onFocus,
|
|
@@ -105,9 +94,16 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
105
94
|
mask,
|
|
106
95
|
maskPlaceholder,
|
|
107
96
|
alwaysShowMask,
|
|
108
|
-
shouldAlwaysShowPlaceholder,
|
|
109
97
|
beforeMaskedStateChange,
|
|
110
|
-
|
|
98
|
+
// Пропсы ControlWrapper
|
|
99
|
+
data,
|
|
100
|
+
groupPlacement,
|
|
101
|
+
icon,
|
|
102
|
+
isLoading,
|
|
103
|
+
isRequired,
|
|
104
|
+
size,
|
|
105
|
+
onIconClick,
|
|
106
|
+
...inputProps
|
|
111
107
|
},
|
|
112
108
|
ref,
|
|
113
109
|
) => {
|
|
@@ -194,7 +190,8 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
194
190
|
onFocus: handleFocus,
|
|
195
191
|
onBlur: handleBlur,
|
|
196
192
|
onChange: handleChange,
|
|
197
|
-
...addDataTestId(testId
|
|
193
|
+
...addDataTestId(testId),
|
|
194
|
+
...inputProps,
|
|
198
195
|
};
|
|
199
196
|
|
|
200
197
|
useEffect(() => {
|
|
@@ -238,7 +235,13 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
238
235
|
isFullWidth={!isAutoSized}
|
|
239
236
|
tweakStyles={tweakControlWrapperStyles}
|
|
240
237
|
onClear={isClearable && hasValue ? handleInputClear : undefined}
|
|
241
|
-
{
|
|
238
|
+
data={data}
|
|
239
|
+
groupPlacement={groupPlacement}
|
|
240
|
+
icon={icon}
|
|
241
|
+
isLoading={isLoading}
|
|
242
|
+
isRequired={isRequired}
|
|
243
|
+
onIconClick={onIconClick}
|
|
244
|
+
size={size}
|
|
242
245
|
>
|
|
243
246
|
{hasUnits || isAutoSized ? (
|
|
244
247
|
<div className={classes.autoSizeWrapper}>{inputContent}</div>
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
import { addDataAttributes } from '../../helpers';
|
|
9
9
|
import { ICommonProps } from '../../types';
|
|
10
10
|
import { WithPopup } from '../WithPopup';
|
|
11
|
-
import { IListItemProps,
|
|
11
|
+
import { IListItemProps, ListItem } from './components';
|
|
12
|
+
import { IListItem } from './types';
|
|
12
13
|
import { useStyles, IListStyles, withPopupStyles } from './List.styles';
|
|
13
14
|
|
|
14
15
|
export interface IListProps extends ICommonProps<IListStyles> {
|
|
@@ -29,9 +30,11 @@ export const List: FC<IListProps> = ({ items, testId, data, tweakStyles, onClick
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
const filteredItems = items.filter(({ isHidden }) => !isHidden);
|
|
34
|
+
|
|
32
35
|
return (
|
|
33
36
|
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
34
|
-
{
|
|
37
|
+
{filteredItems.map((item, i) => {
|
|
35
38
|
const itemProps: IListItemProps = {
|
|
36
39
|
testId: getTestId(testId, `item-${i}`),
|
|
37
40
|
...item,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './List';
|
|
2
2
|
export type { IListStyles } from './List.styles';
|
|
3
|
-
export
|
|
3
|
+
export type { IListItem } from './types';
|
|
4
|
+
export { type IListItemStyles, type IListItemProps, ListItem } from './components';
|
|
@@ -26,7 +26,8 @@ export default {
|
|
|
26
26
|
const Template: ComponentStory<typeof PhoneInput> = (args) => {
|
|
27
27
|
const [value, setValue] = useState<IPhoneValue>({
|
|
28
28
|
dialCode: '7',
|
|
29
|
-
phoneNumber: '
|
|
29
|
+
phoneNumber: '9134567890',
|
|
30
|
+
countryCode: 'RU',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
return <PhoneInput {...args} value={value} onChange={setValue} />;
|
|
@@ -76,7 +76,7 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
76
76
|
|
|
77
77
|
const countryCode = useMemo(
|
|
78
78
|
() => value?.countryCode ?? getCountryCodeFromPhone(phoneWithCode),
|
|
79
|
-
[value.dialCode, value.phoneNumber],
|
|
79
|
+
[value.countryCode, value.dialCode, value.phoneNumber],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const handleClose = () => {
|
|
@@ -122,7 +122,10 @@ export const PhoneInput: FC<IPhoneInputProps> = ({
|
|
|
122
122
|
if (newPhoneInfo.countryCode !== countryCode) {
|
|
123
123
|
onChange(
|
|
124
124
|
{
|
|
125
|
-
phoneNumber:
|
|
125
|
+
phoneNumber:
|
|
126
|
+
newPhoneInfo.dialCode !== value.dialCode
|
|
127
|
+
? ''
|
|
128
|
+
: getPhoneObjFromString(phoneWithCode).phoneNumber,
|
|
126
129
|
dialCode: newPhoneInfo.dialCode,
|
|
127
130
|
countryCode: newPhoneInfo.countryCode,
|
|
128
131
|
},
|
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
import { colors, createThemedStyles, dimensions, ITweakStyles } from '../../theme';
|
|
2
1
|
import { IInputStyles } from '../Input';
|
|
3
2
|
|
|
4
|
-
const
|
|
3
|
+
export const inputStyles: IInputStyles = {
|
|
4
|
+
tweakControlWrapper: {
|
|
5
|
+
endIcon: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: 40,
|
|
8
|
+
left: 0,
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
+
'&:last-child': {
|
|
11
|
+
paddingRight: 0,
|
|
12
|
+
},
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
left: 12,
|
|
16
|
-
height: '100%',
|
|
17
|
-
width: 20,
|
|
18
|
-
color: colors.GREY_ACTIVE,
|
|
19
|
-
zIndex: Z_INDEX.CONTROL_FOCUS + 1,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
14
|
+
'&:not($activeIcon)': {
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
22
18
|
|
|
23
|
-
export const inputStyles: IInputStyles = {
|
|
24
|
-
tweakControlWrapper: {
|
|
25
19
|
controlWrapper: {
|
|
26
20
|
borderColor: 'transparent',
|
|
27
|
-
borderRadius: 18,
|
|
28
|
-
paddingLeft: 0,
|
|
29
|
-
transitionProperty: 'background-color, border-color',
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
focused: {
|
|
33
|
-
backgroundColor: colors.CLASSIC_WHITE,
|
|
34
|
-
borderColor: colors.BORDER_MAIN,
|
|
35
21
|
},
|
|
36
22
|
},
|
|
37
|
-
|
|
38
23
|
inputContent: {
|
|
39
24
|
fontSize: 14,
|
|
40
25
|
paddingLeft: 44,
|
|
41
26
|
},
|
|
42
27
|
};
|
|
43
28
|
|
|
44
|
-
export
|
|
29
|
+
export interface ISearchInputStyles {
|
|
30
|
+
tweakInput?: IInputStyles;
|
|
31
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { addDataAttributes } from '../../helpers';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
4
3
|
import { useTweakStyles } from '../../hooks';
|
|
5
4
|
import { ICommonProps } from '../../types';
|
|
6
|
-
import { Icon } from '../Icon';
|
|
7
5
|
import { IInputProps, Input } from '../Input';
|
|
8
|
-
import { inputStyles, ISearchInputStyles
|
|
6
|
+
import { inputStyles, ISearchInputStyles } from './SearchInput.styles';
|
|
9
7
|
|
|
10
8
|
export type ISearchInputProps = Omit<
|
|
11
9
|
IInputProps,
|
|
@@ -13,37 +11,26 @@ export type ISearchInputProps = Omit<
|
|
|
13
11
|
> &
|
|
14
12
|
ICommonProps<ISearchInputStyles>;
|
|
15
13
|
|
|
16
|
-
export const SearchInput
|
|
17
|
-
isClearable = true,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}) => {
|
|
25
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
14
|
+
export const SearchInput = forwardRef<HTMLInputElement, ISearchInputProps>(
|
|
15
|
+
({ isClearable = true, placeholder, value, testId, tweakStyles, data, ...props }, ref) => {
|
|
16
|
+
const tweakInputStyles = useTweakStyles({
|
|
17
|
+
innerStyles: inputStyles,
|
|
18
|
+
tweakStyles,
|
|
19
|
+
className: 'tweakInput',
|
|
20
|
+
currentComponentName: 'SearchInput',
|
|
21
|
+
});
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
innerStyles: inputStyles,
|
|
29
|
-
tweakStyles,
|
|
30
|
-
className: 'tweakInput',
|
|
31
|
-
currentComponentName: 'SearchInput',
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
36
|
-
<div className={classes.icon}>
|
|
37
|
-
<Icon type="search" />
|
|
38
|
-
</div>
|
|
23
|
+
return (
|
|
39
24
|
<Input
|
|
25
|
+
ref={ref}
|
|
40
26
|
value={value}
|
|
41
27
|
placeholder={placeholder}
|
|
28
|
+
icon="search"
|
|
42
29
|
isClearable={isClearable}
|
|
43
30
|
testId={getTestId(testId, 'input')}
|
|
44
31
|
tweakStyles={tweakInputStyles}
|
|
45
32
|
{...props}
|
|
46
33
|
/>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
KeyboardEvent,
|
|
6
6
|
MouseEvent,
|
|
7
7
|
ReactNode,
|
|
8
|
+
Ref,
|
|
8
9
|
SyntheticEvent,
|
|
9
10
|
useCallback,
|
|
10
11
|
useEffect,
|
|
@@ -63,7 +64,11 @@ export interface ISelectProps<Value>
|
|
|
63
64
|
/** @default true */
|
|
64
65
|
shouldScrollToList?: boolean;
|
|
65
66
|
isMultiSelect?: false;
|
|
66
|
-
searchInput?: {
|
|
67
|
+
searchInput?: {
|
|
68
|
+
/** @default false */
|
|
69
|
+
shouldRenderInList?: boolean;
|
|
70
|
+
ref?: Ref<HTMLInputElement>;
|
|
71
|
+
} & Pick<ISearchInputProps, 'placeholder' | 'shouldFocusOnMount'>;
|
|
67
72
|
isOptionDisabled?: (option: Value) => boolean;
|
|
68
73
|
onChange: (value: Value | undefined, event: IChangeSelectEvent) => void; // подумать как возвращать индекс
|
|
69
74
|
onBlur?: (event: Event | SyntheticEvent) => void;
|
|
@@ -248,10 +253,14 @@ export function Select<Value>(
|
|
|
248
253
|
|
|
249
254
|
const handleListClose = useCallback(
|
|
250
255
|
(event: Event | SyntheticEvent) => {
|
|
256
|
+
if (!isListOpen) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
closeList();
|
|
252
261
|
onBlur?.(event);
|
|
253
262
|
},
|
|
254
|
-
[closeList, onBlur],
|
|
263
|
+
[isListOpen, closeList, onBlur],
|
|
255
264
|
);
|
|
256
265
|
|
|
257
266
|
const handleListOpen = () => {
|
|
@@ -581,6 +590,7 @@ export function Select<Value>(
|
|
|
581
590
|
errorMessage={errorMessage}
|
|
582
591
|
infoMessage={infoMessage}
|
|
583
592
|
tweakStyles={tweakWithMessagesStyles}
|
|
593
|
+
testId={getTestId(testId, 'wrapper')}
|
|
584
594
|
>
|
|
585
595
|
<div className={classes.root} onKeyDown={handleKeyDown} ref={root}>
|
|
586
596
|
<div
|
|
@@ -84,7 +84,7 @@ export function SelectList<Value>({
|
|
|
84
84
|
})}
|
|
85
85
|
>
|
|
86
86
|
{isHeaderNotEmpty && <div className={classes.listHeader}>{customListHeader}</div>}
|
|
87
|
-
<div className={classes.list} {...addDataTestId(testId)}>
|
|
87
|
+
<div className={classes.list} {...addDataTestId(testId)} tabIndex={-1}>
|
|
88
88
|
{isLoading ? (
|
|
89
89
|
<div className={clsx(classes.cell, classes.loading)}>{loadingLabel}</div>
|
|
90
90
|
) : (
|