@true-engineering/true-react-common-ui-kit 4.0.0-alpha0 → 4.0.0-alpha10
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.styles.d.ts +1 -1
- 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/FiltersPane.stories.d.ts +3 -3
- 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/Input/Input.d.ts +3 -3
- package/dist/components/Input/Input.stories.d.ts +2 -2
- package/dist/components/Input/Input.styles.d.ts +3 -3
- 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/SearchInput/SearchInput.d.ts +2 -2
- package/dist/components/SearchInput/SearchInput.stories.d.ts +3 -12
- 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 +8 -8
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/TextArea/TextArea.d.ts +2 -2
- package/dist/components/TextArea/TextArea.styles.d.ts +3 -3
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/WithMessages/WithMessages.d.ts +10 -0
- package/dist/components/{ControlGroup/ControlGroup.stories.d.ts → WithMessages/WithMessages.stories.d.ts} +2 -2
- package/dist/components/WithMessages/WithMessages.styles.d.ts +3 -0
- package/dist/components/WithMessages/index.d.ts +2 -0
- 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/components/index.d.ts +1 -1
- 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 +6 -4
- package/dist/true-react-common-ui-kit.js +7304 -6380
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +7071 -6148
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/ControlWrapper/ControlWrapper.styles.ts +5 -5
- package/src/components/ControlWrapper/ControlWrapper.tsx +1 -1
- package/src/components/DatePicker/DatePicker.tsx +9 -4
- package/src/components/DatePicker/components/DatePickerHeader/DatePickerHeader.styles.ts +1 -1
- 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/FilterSelect/FilterSelect.styles.ts +2 -2
- 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/components/FiltersPaneSearch/FiltersPaneSearch.styles.ts +8 -2
- 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.styles.ts +5 -2
- package/src/components/Input/Input.tsx +9 -8
- package/src/components/Input/InputBase.tsx +2 -1
- 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/MultiSelectList/MultiSelectList.styles.ts +1 -1
- package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
- package/src/components/PhoneInput/PhoneInput.styles.ts +2 -2
- package/src/components/PhoneInput/PhoneInput.tsx +5 -2
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.styles.ts +1 -1
- package/src/components/SearchInput/SearchInput.styles.ts +17 -30
- package/src/components/SearchInput/SearchInput.tsx +17 -30
- package/src/components/Select/CustomSelect.stories.tsx +2 -2
- package/src/components/Select/Select.styles.ts +8 -2
- package/src/components/Select/Select.tsx +19 -31
- package/src/components/Select/components/SelectList/SelectList.tsx +1 -1
- package/src/components/Select/index.ts +1 -1
- package/src/components/TextArea/TextArea.styles.ts +7 -3
- package/src/components/TextArea/TextArea.tsx +16 -11
- package/src/components/Tooltip/Tooltip.styles.ts +2 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/{ControlGroup/ControlGroup.stories.tsx → WithMessages/WithMessages.stories.tsx} +10 -10
- package/src/components/{ControlGroup/ControlGroup.styles.ts → WithMessages/WithMessages.styles.ts} +4 -3
- package/src/components/{ControlGroup/ControlGroup.tsx → WithMessages/WithMessages.tsx} +13 -9
- package/src/components/WithMessages/index.ts +2 -0
- 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/components/index.ts +1 -1
- 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 +6 -4
- package/src/types.ts +2 -1
- package/dist/components/ControlGroup/ControlGroup.d.ts +0 -10
- package/dist/components/ControlGroup/ControlGroup.styles.d.ts +0 -3
- package/dist/components/ControlGroup/index.d.ts +0 -2
- package/src/components/ControlGroup/index.ts +0 -2
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { createThemedStyles, ITweakStyles } from '../../theme';
|
|
2
|
-
import { IControlGroupStyles } from '../ControlGroup';
|
|
3
2
|
import { IControlWrapperStyles } from '../ControlWrapper';
|
|
3
|
+
import { IWithMessagesStyles } from '../WithMessages';
|
|
4
4
|
|
|
5
5
|
const PADDING_WITH_UNITS = 8;
|
|
6
6
|
|
|
@@ -69,12 +69,15 @@ export const useStyles = createThemedStyles('Input', {
|
|
|
69
69
|
|
|
70
70
|
withLabel: {},
|
|
71
71
|
|
|
72
|
+
withValue: {},
|
|
73
|
+
|
|
72
74
|
fakeValue: {
|
|
73
75
|
extend: 'inputContent',
|
|
74
76
|
visibility: 'hidden',
|
|
75
77
|
maxWidth: '100%',
|
|
76
78
|
overflow: 'hidden',
|
|
77
79
|
minWidth: 8,
|
|
80
|
+
whiteSpace: 'nowrap',
|
|
78
81
|
},
|
|
79
82
|
|
|
80
83
|
units: {
|
|
@@ -93,6 +96,6 @@ export type IInputStyles = ITweakStyles<
|
|
|
93
96
|
typeof useStyles,
|
|
94
97
|
{
|
|
95
98
|
tweakControlWrapper: IControlWrapperStyles;
|
|
96
|
-
|
|
99
|
+
tweakWithMessages: IWithMessagesStyles;
|
|
97
100
|
}
|
|
98
101
|
>;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
+
import { getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
2
3
|
import { useTweakStyles } from '../../hooks';
|
|
3
|
-
import {
|
|
4
|
+
import { IWithMessagesProps, WithMessages } from '../WithMessages';
|
|
4
5
|
import { IInputBaseProps, InputBase } from './InputBase';
|
|
5
6
|
|
|
6
7
|
export type IInputProps = IInputBaseProps &
|
|
7
|
-
Pick<
|
|
8
|
+
Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'>;
|
|
8
9
|
|
|
9
10
|
export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
10
11
|
({ infoMessage, errorMessage, isInvalid, testId, tweakStyles, ...inputProps }, ref) => {
|
|
11
|
-
const
|
|
12
|
+
const tweakWithMessagesStyles = useTweakStyles({
|
|
12
13
|
tweakStyles,
|
|
13
|
-
className: '
|
|
14
|
+
className: 'tweakWithMessages',
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
return (
|
|
17
|
-
<
|
|
18
|
+
<WithMessages
|
|
18
19
|
errorMessage={errorMessage}
|
|
19
20
|
infoMessage={infoMessage}
|
|
20
|
-
testId={testId}
|
|
21
|
-
tweakStyles={
|
|
21
|
+
testId={getTestId(testId, 'wrapper')}
|
|
22
|
+
tweakStyles={tweakWithMessagesStyles}
|
|
22
23
|
>
|
|
23
24
|
<InputBase
|
|
24
25
|
{...inputProps}
|
|
@@ -27,7 +28,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
|
|
|
27
28
|
tweakStyles={tweakStyles}
|
|
28
29
|
isInvalid={isInvalid}
|
|
29
30
|
/>
|
|
30
|
-
</
|
|
31
|
+
</WithMessages>
|
|
31
32
|
);
|
|
32
33
|
},
|
|
33
34
|
);
|
|
@@ -168,6 +168,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
168
168
|
const props: InputHTMLAttributes<HTMLInputElement> = {
|
|
169
169
|
className: clsx(classes.input, {
|
|
170
170
|
[classes.withUnits]: hasUnits,
|
|
171
|
+
[classes.withValue]: hasValue,
|
|
171
172
|
[classes.withLabel]: isReactNodeNotEmpty(label),
|
|
172
173
|
[classes.autoSized]: isAutoSized,
|
|
173
174
|
[classes.focusedInput]: isFocused,
|
|
@@ -193,7 +194,7 @@ export const InputBase = forwardRef<HTMLInputElement, IInputBaseProps>(
|
|
|
193
194
|
onFocus: handleFocus,
|
|
194
195
|
onBlur: handleBlur,
|
|
195
196
|
onChange: handleChange,
|
|
196
|
-
...addDataTestId(testId
|
|
197
|
+
...addDataTestId(testId),
|
|
197
198
|
};
|
|
198
199
|
|
|
199
200
|
useEffect(() => {
|
|
@@ -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';
|
|
@@ -92,7 +92,7 @@ export const useStyles = createThemedStyles('MultiSelectList', {
|
|
|
92
92
|
export const searchInputStyles: ISearchInputStyles = {
|
|
93
93
|
tweakInput: {
|
|
94
94
|
tweakControlWrapper: {
|
|
95
|
-
|
|
95
|
+
controlWrapper: {
|
|
96
96
|
'--control-height': '40px',
|
|
97
97
|
backgroundColor: 'transparent',
|
|
98
98
|
border: 'none',
|
|
@@ -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} />;
|
|
@@ -73,14 +73,14 @@ export const useStyles = createThemedStyles('PhoneInput', {
|
|
|
73
73
|
|
|
74
74
|
export const inputStyles: IInputStyles = {
|
|
75
75
|
tweakControlWrapper: {
|
|
76
|
-
|
|
76
|
+
controlWrapper: {
|
|
77
77
|
paddingLeft: COUNTRY_SELECT_WIDTH,
|
|
78
78
|
},
|
|
79
79
|
|
|
80
80
|
label: {
|
|
81
81
|
marginLeft: COUNTRY_SELECT_WIDTH,
|
|
82
82
|
},
|
|
83
|
-
}
|
|
83
|
+
},
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
export type IPhoneInputStyles = ITweakStyles<
|
|
@@ -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 { Z_INDEX } = dimensions;
|
|
5
|
-
|
|
6
|
-
export const useStyles = createThemedStyles('SearchInput', {
|
|
7
|
-
root: {
|
|
8
|
-
position: 'relative',
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
icon: {
|
|
12
|
-
display: 'flex',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
position: 'absolute',
|
|
15
|
-
left: 12,
|
|
16
|
-
height: '100%',
|
|
17
|
-
width: 20,
|
|
18
|
-
color: colors.GREY_ACTIVE,
|
|
19
|
-
zIndex: Z_INDEX.CONTROL_FOCUS + 1,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
3
|
export const inputStyles: IInputStyles = {
|
|
24
4
|
tweakControlWrapper: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
endIcon: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: 40,
|
|
8
|
+
left: 0,
|
|
9
|
+
|
|
10
|
+
'&:last-child': {
|
|
11
|
+
paddingRight: 0,
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
'&:not($activeIcon)': {
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
},
|
|
30
17
|
},
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
borderColor: colors.BORDER_MAIN,
|
|
19
|
+
controlWrapper: {
|
|
20
|
+
borderColor: 'transparent',
|
|
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
|
+
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mergeStyles } from '@true-engineering/true-react-platform-helpers';
|
|
2
2
|
import { animations, createThemedStyles, dimensions, type ITweakStyles } from '../../theme';
|
|
3
|
-
import { IControlGroupStyles } from '../ControlGroup';
|
|
4
3
|
import { type IInputStyles } from '../Input';
|
|
5
4
|
import { type ISearchInputStyles } from '../SearchInput';
|
|
5
|
+
import { IWithMessagesStyles } from '../WithMessages';
|
|
6
6
|
import { type ISelectListStyles } from './components';
|
|
7
7
|
|
|
8
8
|
const { CONTROL, Z_INDEX } = dimensions;
|
|
@@ -84,6 +84,12 @@ const baseInputStyles: IInputStyles = {
|
|
|
84
84
|
paddingRight: 32,
|
|
85
85
|
},
|
|
86
86
|
|
|
87
|
+
input: {
|
|
88
|
+
'&[readonly]': {
|
|
89
|
+
cursor: 'pointer',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
87
93
|
tweakControlWrapper: {
|
|
88
94
|
controls: {
|
|
89
95
|
paddingRight: 40,
|
|
@@ -125,7 +131,7 @@ export const getInputStyles = ({
|
|
|
125
131
|
export type ISelectStyles = ITweakStyles<
|
|
126
132
|
typeof useStyles,
|
|
127
133
|
{
|
|
128
|
-
|
|
134
|
+
tweakWithMessages: IWithMessagesStyles;
|
|
129
135
|
tweakInput: IInputStyles;
|
|
130
136
|
tweakSelectList: ISelectListStyles;
|
|
131
137
|
tweakSearchInput: ISearchInputStyles;
|