@true-engineering/true-react-common-ui-kit 2.6.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/components/Button/Button.d.ts +2 -1
- package/dist/components/FiltersPane/components/Filter/Filter.d.ts +1 -1
- package/dist/components/FiltersPane/components/FilterValueView/FilterValueView.d.ts +1 -1
- package/dist/components/FiltersPane/constants.d.ts +1 -1
- package/dist/components/FiltersPane/types.d.ts +1 -1
- package/dist/components/Icon/helpers.d.ts +1 -1
- package/dist/components/Icon/icons-list.d.ts +1 -1
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/{helpers/snippets.d.ts → components/Icon/snippet.d.ts} +1 -1
- package/dist/components/Icon/types.d.ts +2 -1
- package/dist/components/Input/Input.d.ts +2 -1
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/List.styles.d.ts +0 -28
- package/dist/components/List/index.d.ts +0 -1
- package/dist/components/ListItem/ListItem.d.ts +6 -0
- package/dist/components/ListItem/ListItem.styles.d.ts +35 -0
- package/dist/components/ListItem/constants.d.ts +1 -0
- package/dist/components/ListItem/index.d.ts +3 -0
- package/dist/components/{List → ListItem}/types.d.ts +6 -1
- package/dist/components/MoreMenu/MoreMenu.d.ts +2 -2
- package/dist/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.d.ts +1 -1
- package/dist/components/NumberInput/helpers.d.ts +1 -1
- package/dist/components/PhoneInput/index.d.ts +0 -1
- package/dist/components/ScrollIntoViewIfNeeded/ScrollIntoViewIfNeeded.d.ts +1 -1
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/phone-info.d.ts +2 -0
- package/dist/helpers/phone.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +24633 -24533
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +24633 -24533
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +2 -4
- package/package.json +2 -1
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/FiltersPane/components/Filter/Filter.tsx +1 -1
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +1 -1
- package/src/components/FiltersPane/constants.ts +1 -1
- package/src/components/FiltersPane/types.ts +1 -1
- package/src/components/Icon/{helpers.ts → helpers.tsx} +1 -1
- package/src/components/Icon/icons-list.ts +30 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/{helpers/snippets.tsx → components/Icon/snippet.tsx} +2 -2
- package/src/components/Icon/types.ts +3 -1
- package/src/components/Input/Input.tsx +2 -3
- package/src/components/List/List.stories.tsx +3 -3
- package/src/components/List/List.styles.ts +0 -38
- package/src/components/List/List.tsx +9 -27
- package/src/components/List/index.ts +0 -1
- package/src/components/ListItem/ListItem.stories.tsx +67 -0
- package/src/components/ListItem/ListItem.styles.ts +48 -0
- package/src/components/ListItem/ListItem.tsx +45 -0
- package/src/components/ListItem/constants.ts +5 -0
- package/src/components/ListItem/index.ts +3 -0
- package/src/components/ListItem/types.ts +19 -0
- package/src/components/MoreMenu/MoreMenu.tsx +2 -2
- package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +2 -1
- package/src/components/NumberInput/helpers.ts +1 -1
- package/src/components/PhoneInput/PhoneInput.stories.tsx +1 -1
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +1 -1
- package/src/components/PhoneInput/index.ts +0 -1
- package/src/components/Select/Select.tsx +2 -2
- package/src/components/Tooltip/Tooltip.styles.ts +1 -1
- package/src/components/index.ts +1 -0
- package/src/constants/index.ts +1 -0
- package/src/{components/PhoneInput → constants}/phone-info.ts +1 -1
- package/src/helpers/phone.ts +2 -1
- package/src/index.ts +1 -1
- package/src/types.ts +2 -10
- package/dist/components/PhoneInput/phone-info.d.ts +0 -2
- package/src/components/List/types.ts +0 -13
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
1
|
import { Styles } from 'react-jss';
|
|
3
2
|
import { Modifier, Placement } from 'react-overlays/usePopper';
|
|
4
|
-
import type { ICommonIcon, IComplexIcon,
|
|
3
|
+
import type { ICommonIcon, IComplexIcon, IPreloaderSvgType, ISvgIcon } from './components';
|
|
5
4
|
export interface IDataAttributes {
|
|
6
5
|
[key: string]: unknown;
|
|
7
6
|
}
|
|
@@ -18,9 +17,8 @@ export interface IDropdownWithPopperOptions {
|
|
|
18
17
|
placement?: Placement;
|
|
19
18
|
flipOptions?: Record<string, any>;
|
|
20
19
|
}
|
|
21
|
-
export declare type IIcon = IIconType | ReactElement;
|
|
22
20
|
export declare type ComponentStyles<StyleSheet, Props = unknown> = Partial<Styles<keyof StyleSheet, Props>>;
|
|
23
|
-
export declare type ComponentName = 'AccountInfo' | 'AddButton' | 'Button' | 'CloseButton' | 'Checkbox' | 'CssBaseline' | 'Colors' | 'DateInput' | 'DatePicker' | 'DatePickerHeader' | 'Description' | 'DotsPreloader' | 'SvgPreloader' | 'FiltersPane' | 'FilterInterval' | 'FilterSelect' | 'FilterWithDates' | 'FilterWithPeriod' | 'FilterWrapper' | 'FilterValueView' | 'FiltersPaneSearch' | 'Flag' | 'FlexibleTable' | 'Icon' | 'IncrementInput' | 'Input' | 'List' | 'Modal' | 'MoreMenu' | 'MultiSelect' | 'MultiSelectInput' | 'MultiSelectList' | 'Notification' | 'PhoneInput' | 'PhoneInputCountryList' | 'RadioButton' | 'SearchInput' | 'Select' | 'SelectList' | 'ScrollIntoViewIfNeeded' | 'Switch' | 'TextArea' | 'TextWithInfo' | 'TextWithTooltip' | 'ThemedPreloader' | 'Tooltip' | 'Toaster';
|
|
21
|
+
export declare type ComponentName = 'AccountInfo' | 'AddButton' | 'Button' | 'CloseButton' | 'Checkbox' | 'CssBaseline' | 'Colors' | 'DateInput' | 'DatePicker' | 'DatePickerHeader' | 'Description' | 'DotsPreloader' | 'SvgPreloader' | 'FiltersPane' | 'FilterInterval' | 'FilterSelect' | 'FilterWithDates' | 'FilterWithPeriod' | 'FilterWrapper' | 'FilterValueView' | 'FiltersPaneSearch' | 'Flag' | 'FlexibleTable' | 'Icon' | 'IncrementInput' | 'Input' | 'List' | 'ListItem' | 'Modal' | 'MoreMenu' | 'MultiSelect' | 'MultiSelectInput' | 'MultiSelectList' | 'Notification' | 'PhoneInput' | 'PhoneInputCountryList' | 'RadioButton' | 'SearchInput' | 'Select' | 'SelectList' | 'ScrollIntoViewIfNeeded' | 'Switch' | 'TextArea' | 'TextWithInfo' | 'TextWithTooltip' | 'ThemedPreloader' | 'Tooltip' | 'Toaster';
|
|
24
22
|
export declare type UiKitAnimations = Record<string, any>;
|
|
25
23
|
export declare type UiKitHelpers = Record<string, Styles | (() => Styles)>;
|
|
26
24
|
export interface UiKitTheme {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@true-engineering/true-react-common-ui-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "True Engineering React UI Kit with theming support",
|
|
5
5
|
"author": "True Engineering (https://trueengineering.ru)",
|
|
6
6
|
"keywords": [
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"eslint": "8.36.0",
|
|
84
84
|
"eslint-config-prettier": "8.7.0",
|
|
85
85
|
"eslint-plugin-react": "7.32.2",
|
|
86
|
+
"eslint-plugin-import": "2.29.0",
|
|
86
87
|
"prettier": "2.8.3",
|
|
87
88
|
"rollup-plugin-swc3": "0.3.0",
|
|
88
89
|
"typescript": "4.9.3",
|
|
@@ -3,9 +3,9 @@ import clsx from 'clsx';
|
|
|
3
3
|
import merge from 'lodash-es/merge';
|
|
4
4
|
import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
5
5
|
import { addDataAttributes } from '../../helpers';
|
|
6
|
-
import { renderIcon } from '../../helpers/snippets';
|
|
7
6
|
import { useTheme } from '../../hooks';
|
|
8
|
-
import { ICommonProps
|
|
7
|
+
import { ICommonProps } from '../../types';
|
|
8
|
+
import { IIcon, renderIcon } from '../Icon';
|
|
9
9
|
import { ThemedPreloader, IThemedPreloaderProps, ThemedPreloaderStyles } from '../ThemedPreloader';
|
|
10
10
|
import { IButtonSize, IButtonView } from './types';
|
|
11
11
|
import { ButtonStyles, styles, dotsPreloaderStyles } from './Button.styles';
|
|
@@ -9,7 +9,7 @@ import { FilterMultiSelect } from '../FilterMultiSelect';
|
|
|
9
9
|
import { FilterSelect } from '../FilterSelect';
|
|
10
10
|
import { FilterWithDates } from '../FilterWithDates';
|
|
11
11
|
import { FilterWithPeriod } from '../FilterWithPeriod';
|
|
12
|
-
import { IFilterWrapperProps } from '../FilterWrapper';
|
|
12
|
+
import type { IFilterWrapperProps } from '../FilterWrapper';
|
|
13
13
|
|
|
14
14
|
export interface IFilterProps<Values, Key extends keyof Values>
|
|
15
15
|
extends IFilterWrapperProps<Values, Key> {
|
|
@@ -5,7 +5,7 @@ import { IMultiSelectListValues } from '../../../MultiSelectList';
|
|
|
5
5
|
import { DEFAULT_DATE_FORMAT } from '../../constants';
|
|
6
6
|
import { defaultConvertFunction, getLocale } from '../../helpers';
|
|
7
7
|
import { IDateRangeConfigItem, IFilterWithDatesValue, IPeriod } from '../../types';
|
|
8
|
-
import { IFilterWrapperProps } from '../FilterWrapper';
|
|
8
|
+
import type { IFilterWrapperProps } from '../FilterWrapper';
|
|
9
9
|
import { styles } from './FilterValueView.styles';
|
|
10
10
|
|
|
11
11
|
export function FilterValueView<Values, Key extends keyof Values>({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { complexIcons } from './complexIcons';
|
|
2
|
-
import { IComplexIcon, IIconType, ISvgIcon } from './types';
|
|
2
|
+
import type { IComplexIcon, IIconType, ISvgIcon } from './types';
|
|
3
3
|
|
|
4
4
|
export const isComplexIcon = (type: IIconType): type is IComplexIcon => type in complexIcons;
|
|
5
5
|
|
|
@@ -370,6 +370,26 @@ export const iconsList = checkIcons({
|
|
|
370
370
|
},
|
|
371
371
|
],
|
|
372
372
|
},
|
|
373
|
+
folder: {
|
|
374
|
+
viewBox: '0 0 20 20',
|
|
375
|
+
paths: [
|
|
376
|
+
{
|
|
377
|
+
d: 'M16.9 5H10.009L8.716 3.795C8.25211 3.34264 7.714 3 7.069 3H3.1C1.942 3 1 3.942 1 5.1V15.9C1 17.058 1.942 18 3.1 18H16.9C18.058 18 19 17.058 19 15.9V7.1C19 5.942 18.058 5 16.9 5Z',
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
},
|
|
381
|
+
'folder-add': {
|
|
382
|
+
viewBox: '0 0 20 20',
|
|
383
|
+
paths: [
|
|
384
|
+
{
|
|
385
|
+
d: 'M16.9 5H10.009C10.009 5 9.19158 4.23037 8.716 3.795C8.24042 3.35963 7.714 3 7.069 3H3.1C1.942 3 1 3.942 1 5.1V15.9C1 17.058 1.942 18 3.1 18H16.9C18.058 18 19 17.058 19 15.9V7.1C19 5.942 18.058 5 16.9 5Z',
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
d: 'M13 13H11V15C11 15.5523 10.5523 16 10 16C9.44772 16 9 15.5523 9 15V13H7C6.44772 13 6 12.5523 6 12C6 11.4477 6.44772 11 7 11H9V9C9 8.44772 9.44772 8 10 8C10.5523 8 11 8.44772 11 9V11H13C13.5523 11 14 11.4477 14 12C14 12.5523 13.5523 13 13 13Z',
|
|
389
|
+
fill: 'white',
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
},
|
|
373
393
|
food: {
|
|
374
394
|
viewBox: '0 0 28 28',
|
|
375
395
|
paths: [
|
|
@@ -495,6 +515,16 @@ export const iconsList = checkIcons({
|
|
|
495
515
|
},
|
|
496
516
|
],
|
|
497
517
|
},
|
|
518
|
+
presentation: {
|
|
519
|
+
viewBox: '0 0 20 20',
|
|
520
|
+
paths: [
|
|
521
|
+
{ d: 'M8 10H12V11H8V10Z' },
|
|
522
|
+
{ d: 'M14 8H6V9H14V8Z' },
|
|
523
|
+
{
|
|
524
|
+
d: 'M4 2C2.89543 2 2 2.89543 2 4V13C2 14.1046 2.89543 15 4 15H7.6906L5.76795 18.3301L7.5 19.3301L10 15L12.5004 19.3301L14.2324 18.3301L12.3098 15H16C17.1046 15 18 14.1046 18 13V4C18 2.89543 17.1046 2 16 2H4ZM16 6H4V13H16V6Z',
|
|
525
|
+
},
|
|
526
|
+
],
|
|
527
|
+
},
|
|
498
528
|
print: {
|
|
499
529
|
paths: [
|
|
500
530
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { Icon } from '
|
|
3
|
-
import { IIcon } from '
|
|
2
|
+
import { Icon } from './Icon';
|
|
3
|
+
import { IIcon } from './types';
|
|
4
4
|
|
|
5
5
|
export const renderIcon = (icon: IIcon): ReactNode =>
|
|
6
6
|
typeof icon === 'string' ? <Icon type={icon} /> : icon;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SVGAttributes } from 'react';
|
|
1
|
+
import { ReactElement, SVGAttributes } from 'react';
|
|
2
2
|
import { complexIcons } from './complexIcons';
|
|
3
3
|
import { iconsList } from './icons-list';
|
|
4
4
|
|
|
@@ -14,3 +14,5 @@ export type ICommonIcon = keyof typeof iconsList;
|
|
|
14
14
|
export type IComplexIcon = keyof typeof complexIcons;
|
|
15
15
|
|
|
16
16
|
export type IIconType = ICommonIcon | IComplexIcon;
|
|
17
|
+
|
|
18
|
+
export type IIcon = IIconType | ReactElement;
|
|
@@ -19,10 +19,9 @@ import {
|
|
|
19
19
|
isStringNotEmpty,
|
|
20
20
|
} from '@true-engineering/true-react-platform-helpers';
|
|
21
21
|
import { addDataAttributes } from '../../helpers';
|
|
22
|
-
import { renderIcon } from '../../helpers/snippets';
|
|
23
22
|
import { useTheme, useTweakStyles } from '../../hooks';
|
|
24
|
-
import { ICommonProps
|
|
25
|
-
import { Icon } from '../Icon';
|
|
23
|
+
import { ICommonProps } from '../../types';
|
|
24
|
+
import { Icon, IIcon, renderIcon } from '../Icon';
|
|
26
25
|
import { ThemedPreloader } from '../ThemedPreloader';
|
|
27
26
|
import { DEFAULT_SIZE } from './constants';
|
|
28
27
|
import { IReactInputMaskProps } from './types';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
2
|
import { colors } from '../../theme';
|
|
3
|
-
import { List } from './List';
|
|
4
|
-
import { IListItem } from './types';
|
|
3
|
+
import { List, IListProps } from './List';
|
|
5
4
|
|
|
6
|
-
const listItems:
|
|
5
|
+
const listItems: IListProps['items'] = [
|
|
7
6
|
{
|
|
8
7
|
item: 'Печатать билет',
|
|
9
8
|
onClick: console.log,
|
|
@@ -12,6 +11,7 @@ const listItems: IListItem[] = [
|
|
|
12
11
|
{ item: 'Выписать', onClick: console.log, withIconGap: true },
|
|
13
12
|
{
|
|
14
13
|
item: 'Аннулировать',
|
|
14
|
+
view: 'destructive',
|
|
15
15
|
onClick: console.log,
|
|
16
16
|
icon: <>2</>,
|
|
17
17
|
},
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { colors } from '../../theme';
|
|
2
2
|
import { ComponentStyles } from '../../types';
|
|
3
3
|
|
|
4
|
-
const ITEM_HORIZONTAL_PADDING = 16;
|
|
5
|
-
const ICON_SIZE = 20;
|
|
6
|
-
const ICON_GAP = 12;
|
|
7
|
-
|
|
8
4
|
export const styles = {
|
|
9
5
|
root: {
|
|
10
6
|
minWidth: 180,
|
|
@@ -13,40 +9,6 @@ export const styles = {
|
|
|
13
9
|
listStyle: 'none',
|
|
14
10
|
margin: 0,
|
|
15
11
|
},
|
|
16
|
-
|
|
17
|
-
item: {
|
|
18
|
-
display: 'flex',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
boxSizing: 'border-box',
|
|
21
|
-
fontSize: 16,
|
|
22
|
-
whiteSpace: 'nowrap',
|
|
23
|
-
minHeight: 40,
|
|
24
|
-
padding: [0, ITEM_HORIZONTAL_PADDING],
|
|
25
|
-
transition: 'background-color 0.25s ease-in-out',
|
|
26
|
-
cursor: 'pointer',
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
disabledItem: {
|
|
30
|
-
cursor: 'default',
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
spacer: {
|
|
34
|
-
height: 1,
|
|
35
|
-
backgroundColor: colors.BORDER_LIGHT,
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
withIconGap: {
|
|
39
|
-
paddingLeft: ITEM_HORIZONTAL_PADDING + ICON_SIZE + ICON_GAP,
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
icon: {
|
|
43
|
-
width: ICON_SIZE,
|
|
44
|
-
height: ICON_SIZE,
|
|
45
|
-
marginRight: ICON_GAP,
|
|
46
|
-
flexShrink: 0,
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
content: {},
|
|
50
12
|
};
|
|
51
13
|
|
|
52
14
|
export type ListStyles = ComponentStyles<typeof styles>;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { FC
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
addDataTestId,
|
|
5
|
-
getTestId,
|
|
6
|
-
isReactNodeNotEmpty,
|
|
7
|
-
} from '@true-engineering/true-react-platform-helpers';
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { addDataTestId, getTestId } from '@true-engineering/true-react-platform-helpers';
|
|
8
3
|
import { addDataAttributes } from '../../helpers';
|
|
9
|
-
import { renderIcon } from '../../helpers/snippets';
|
|
10
4
|
import { useTheme } from '../../hooks';
|
|
11
5
|
import { ICommonProps } from '../../types';
|
|
12
|
-
import { IListItem } from '
|
|
6
|
+
import { ListItem, IListItem } from '../ListItem';
|
|
13
7
|
import { ListStyles, styles } from './List.styles';
|
|
14
8
|
|
|
15
9
|
export interface IListProps extends ICommonProps {
|
|
@@ -30,24 +24,12 @@ export const List: FC<IListProps> = ({ items, testId, data, tweakStyles, onClick
|
|
|
30
24
|
return (
|
|
31
25
|
<div className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
32
26
|
{items.map((item, idx) => (
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})}
|
|
40
|
-
onClick={item.disabled ? undefined : () => handleItemClick(item)}
|
|
41
|
-
{...addDataTestId(item.testId ?? getTestId(testId, `item-${idx}`))}
|
|
42
|
-
{...(item.disabled && addDataAttributes({ disabled: item.disabled }))}
|
|
43
|
-
>
|
|
44
|
-
{isReactNodeNotEmpty(item.icon) && (
|
|
45
|
-
<span className={classes.icon}>{renderIcon(item.icon)}</span>
|
|
46
|
-
)}
|
|
47
|
-
<span className={classes.content}>{item.item}</span>
|
|
48
|
-
</div>
|
|
49
|
-
{item.shouldDrawSpacerBelow && <div className={classes.spacer} />}
|
|
50
|
-
</Fragment>
|
|
27
|
+
<ListItem
|
|
28
|
+
key={idx}
|
|
29
|
+
{...item}
|
|
30
|
+
testId={item.testId ?? getTestId(testId, `item-${idx}`)}
|
|
31
|
+
onClick={() => handleItemClick(item)}
|
|
32
|
+
/>
|
|
51
33
|
))}
|
|
52
34
|
</div>
|
|
53
35
|
);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import { colors } from '../../theme';
|
|
3
|
+
import { ListItem } from './ListItem';
|
|
4
|
+
import { IListItem } from './types';
|
|
5
|
+
|
|
6
|
+
const listItems: IListItem[] = [
|
|
7
|
+
{
|
|
8
|
+
item: 'Печатать билет',
|
|
9
|
+
onClick: console.log,
|
|
10
|
+
icon: 'sign-out',
|
|
11
|
+
},
|
|
12
|
+
{ item: 'Выписать', onClick: console.log, withIconGap: true },
|
|
13
|
+
{
|
|
14
|
+
item: 'Аннулировать',
|
|
15
|
+
view: 'destructive',
|
|
16
|
+
onClick: console.log,
|
|
17
|
+
icon: <>2</>,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
item: 'Вернуть',
|
|
21
|
+
onClick: console.log,
|
|
22
|
+
disabled: true,
|
|
23
|
+
withIconGap: true,
|
|
24
|
+
shouldDrawSpacerBelow: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
item: (() => <div style={{ color: colors.RED_ACTIVE }}>Удалить</div>)(),
|
|
28
|
+
onClick: console.log,
|
|
29
|
+
disabled: true,
|
|
30
|
+
withIconGap: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
item: (() => <div style={{ color: colors.RED_ACTIVE }}>Удалить</div>)(),
|
|
34
|
+
onClick: console.log,
|
|
35
|
+
withIconGap: true,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
title: 'ListItem',
|
|
41
|
+
component: ListItem,
|
|
42
|
+
args: {
|
|
43
|
+
items: listItems,
|
|
44
|
+
},
|
|
45
|
+
parameters: {
|
|
46
|
+
controls: {
|
|
47
|
+
exclude: ['data', 'tweakStyles', 'testId', 'onClick'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
} as ComponentMeta<typeof ListItem>;
|
|
51
|
+
|
|
52
|
+
export const Default: ComponentStory<typeof ListItem> = (args) => (
|
|
53
|
+
<div
|
|
54
|
+
style={{
|
|
55
|
+
border: '1px dotted rgba(0,0,0,.2)',
|
|
56
|
+
display: 'flex',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
flexDirection: 'column',
|
|
59
|
+
padding: 40,
|
|
60
|
+
gap: 10,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{listItems.map((item, idx) => (
|
|
64
|
+
<ListItem key={idx} {...item} {...args} />
|
|
65
|
+
))}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { colors } from '../../theme';
|
|
2
|
+
import type { ComponentStyles } from '../../types';
|
|
3
|
+
|
|
4
|
+
const ITEM_HORIZONTAL_PADDING = 16;
|
|
5
|
+
const ICON_SIZE = 20;
|
|
6
|
+
const ICON_GAP = 12;
|
|
7
|
+
|
|
8
|
+
export const styles = {
|
|
9
|
+
item: {
|
|
10
|
+
display: 'flex',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
boxSizing: 'border-box',
|
|
13
|
+
fontSize: 16,
|
|
14
|
+
whiteSpace: 'nowrap',
|
|
15
|
+
minHeight: 40,
|
|
16
|
+
padding: [0, ITEM_HORIZONTAL_PADDING],
|
|
17
|
+
transition: 'background-color 0.25s ease-in-out',
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
default: {},
|
|
22
|
+
destructive: {},
|
|
23
|
+
custom: {},
|
|
24
|
+
|
|
25
|
+
disabledItem: {
|
|
26
|
+
cursor: 'default',
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
spacer: {
|
|
30
|
+
height: 1,
|
|
31
|
+
backgroundColor: colors.BORDER_LIGHT,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
withIconGap: {
|
|
35
|
+
paddingLeft: ITEM_HORIZONTAL_PADDING + ICON_SIZE + ICON_GAP,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
icon: {
|
|
39
|
+
width: ICON_SIZE,
|
|
40
|
+
height: ICON_SIZE,
|
|
41
|
+
marginRight: ICON_GAP,
|
|
42
|
+
flexShrink: 0,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
content: {},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ListItemStyles = ComponentStyles<typeof styles>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FC, Fragment } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
+
import { addDataAttributes } from '../../helpers';
|
|
5
|
+
import { useTheme } from '../../hooks';
|
|
6
|
+
import { ICommonProps } from '../../types';
|
|
7
|
+
import { renderIcon } from '../Icon';
|
|
8
|
+
import { IListItem } from './types';
|
|
9
|
+
import { styles } from './ListItem.styles';
|
|
10
|
+
|
|
11
|
+
export interface IListItemProps extends ICommonProps, IListItem {}
|
|
12
|
+
|
|
13
|
+
export const ListItem: FC<IListItemProps> = ({
|
|
14
|
+
disabled,
|
|
15
|
+
icon,
|
|
16
|
+
item,
|
|
17
|
+
shouldDrawSpacerAbove,
|
|
18
|
+
shouldDrawSpacerBelow,
|
|
19
|
+
testId,
|
|
20
|
+
tweakStyles,
|
|
21
|
+
view = 'default',
|
|
22
|
+
withIconGap,
|
|
23
|
+
onClick,
|
|
24
|
+
}) => {
|
|
25
|
+
const { classes } = useTheme('ListItem', styles, tweakStyles);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Fragment>
|
|
29
|
+
{shouldDrawSpacerAbove && <div className={classes.spacer} />}
|
|
30
|
+
<div
|
|
31
|
+
className={clsx(classes.item, classes[view], {
|
|
32
|
+
[classes.disabledItem]: disabled,
|
|
33
|
+
[classes.withIconGap]: withIconGap,
|
|
34
|
+
})}
|
|
35
|
+
onClick={disabled ? undefined : onClick}
|
|
36
|
+
{...addDataTestId(testId)}
|
|
37
|
+
{...(disabled && addDataAttributes({ disabled }))}
|
|
38
|
+
>
|
|
39
|
+
{isReactNodeNotEmpty(icon) && <span className={classes.icon}>{renderIcon(icon)}</span>}
|
|
40
|
+
<span className={classes.content}>{item}</span>
|
|
41
|
+
</div>
|
|
42
|
+
{shouldDrawSpacerBelow && <div className={classes.spacer} />}
|
|
43
|
+
</Fragment>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { IIcon } from '../Icon';
|
|
3
|
+
import { LIST_ITEM_VIEW } from './constants';
|
|
4
|
+
import type { ListItemStyles } from './ListItem.styles';
|
|
5
|
+
|
|
6
|
+
export type IListItemView = (typeof LIST_ITEM_VIEW)[number];
|
|
7
|
+
|
|
8
|
+
export interface IListItem {
|
|
9
|
+
item: ReactNode;
|
|
10
|
+
view?: IListItemView;
|
|
11
|
+
icon?: IIcon;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
shouldDrawSpacerAbove?: boolean;
|
|
14
|
+
shouldDrawSpacerBelow?: boolean;
|
|
15
|
+
withIconGap?: boolean;
|
|
16
|
+
testId?: string;
|
|
17
|
+
tweakStyles?: ListItemStyles;
|
|
18
|
+
onClick(): void;
|
|
19
|
+
}
|
|
@@ -5,12 +5,12 @@ import { addDataAttributes } from '../../helpers';
|
|
|
5
5
|
import { useTheme, useTweakStyles, useOnClickOutsideWithRef } from '../../hooks';
|
|
6
6
|
import { ICommonProps } from '../../types';
|
|
7
7
|
import { Icon } from '../Icon';
|
|
8
|
-
import {
|
|
8
|
+
import { List, IListProps } from '../List';
|
|
9
9
|
import { MoreMenuStyles, styles } from './MoreMenu.styles';
|
|
10
10
|
|
|
11
11
|
export interface IMoreMenuProps extends ICommonProps {
|
|
12
12
|
tweakStyles?: MoreMenuStyles;
|
|
13
|
-
items:
|
|
13
|
+
items: IListProps['items'];
|
|
14
14
|
isDisabled?: boolean;
|
|
15
15
|
/**
|
|
16
16
|
* @default true
|
|
@@ -2,7 +2,8 @@ import { ReactElement } from 'react';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useTheme } from '../../../../hooks';
|
|
4
4
|
import { ICommonProps } from '../../../../types';
|
|
5
|
-
import { Icon
|
|
5
|
+
import { Icon } from '../../../Icon';
|
|
6
|
+
import type { IMultiSelectListValues } from '../../../MultiSelectList';
|
|
6
7
|
import { styles } from './MultiSelectInput.styles';
|
|
7
8
|
|
|
8
9
|
export interface IMultiSelectInputProps<Value> extends ICommonProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isStringNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
2
2
|
import { formatNumber, isSpaceChar } from '../../helpers';
|
|
3
|
-
import { INumberInputProps } from './NumberInput';
|
|
3
|
+
import type { INumberInputProps } from './NumberInput';
|
|
4
4
|
|
|
5
5
|
const getPrevSpaces = (val: string, position: number): number =>
|
|
6
6
|
val
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { phoneInfo } from '../../constants';
|
|
3
4
|
import { iconsList } from '../Icon';
|
|
4
5
|
import { PhoneInput } from './PhoneInput';
|
|
5
|
-
import { phoneInfo } from './phone-info';
|
|
6
6
|
import { IPhoneValue } from './types';
|
|
7
7
|
|
|
8
8
|
const iconTypes = [undefined, ...Object.keys(iconsList)];
|
package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, MouseEvent, useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
+
import { phoneInfo } from '../../../../constants';
|
|
3
4
|
import {
|
|
4
5
|
checkSearchStringInCountry,
|
|
5
6
|
getCountryTextByLocale,
|
|
@@ -12,7 +13,6 @@ import { Flag } from '../../../Flag';
|
|
|
12
13
|
import { Icon } from '../../../Icon';
|
|
13
14
|
import { Input } from '../../../Input';
|
|
14
15
|
import { ScrollIntoViewIfNeeded } from '../../../ScrollIntoViewIfNeeded';
|
|
15
|
-
import { phoneInfo } from '../../phone-info';
|
|
16
16
|
import { IPhoneInfo } from '../../types';
|
|
17
17
|
import { PhoneInputCountryListStyles, styles } from './PhoneInputCountryList.styles';
|
|
18
18
|
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
createFilter,
|
|
23
23
|
} from '@true-engineering/true-react-platform-helpers';
|
|
24
24
|
import { hasExactParent } from '../../helpers';
|
|
25
|
-
import { renderIcon } from '../../helpers/snippets';
|
|
26
25
|
import {
|
|
27
26
|
useIsMounted,
|
|
28
27
|
useTheme,
|
|
@@ -30,7 +29,8 @@ import {
|
|
|
30
29
|
useDropdown,
|
|
31
30
|
useTweakStyles,
|
|
32
31
|
} from '../../hooks';
|
|
33
|
-
import { IDropdownWithPopperOptions
|
|
32
|
+
import { IDropdownWithPopperOptions } from '../../types';
|
|
33
|
+
import { IIcon, renderIcon } from '../Icon';
|
|
34
34
|
import { IInputProps, Input } from '../Input';
|
|
35
35
|
import { ISearchInputProps, SearchInput } from '../SearchInput';
|
|
36
36
|
import { SelectList } from './components';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rgba } from '../../helpers';
|
|
2
2
|
import { colors, dimensions } from '../../theme';
|
|
3
3
|
import { ComponentStyles } from '../../types';
|
|
4
|
-
import { ITooltipProps } from './Tooltip';
|
|
4
|
+
import type { ITooltipProps } from './Tooltip';
|
|
5
5
|
|
|
6
6
|
interface IStyleProps {
|
|
7
7
|
type: NonNullable<ITooltipProps['type']>;
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './phone-info';
|
package/src/helpers/phone.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNotEmpty, isEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
2
|
-
import {
|
|
2
|
+
import type { IPhoneInfo, IPhoneValue } from '../components';
|
|
3
|
+
import { phoneInfo } from '../constants';
|
|
3
4
|
|
|
4
5
|
export const findCountryByCode = (
|
|
5
6
|
countryCode?: string,
|