@cloud-ru/uikit-product-site-selector-platform-drop-list 0.1.4
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/CHANGELOG.md +64 -0
- package/LICENSE +201 -0
- package/README.md +24 -0
- package/dist/cjs/components/SelectorPlatformDropList/SelectorPlatformDropList.d.ts +19 -0
- package/dist/cjs/components/SelectorPlatformDropList/SelectorPlatformDropList.js +23 -0
- package/dist/cjs/components/SelectorPlatformDropList/index.d.ts +2 -0
- package/dist/cjs/components/SelectorPlatformDropList/index.js +5 -0
- package/dist/cjs/components/SelectorPlatformDropList/platforms.d.ts +5 -0
- package/dist/cjs/components/SelectorPlatformDropList/platforms.js +30 -0
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +17 -0
- package/dist/cjs/helperComponents/BaseIcon/BaseIcon.d.ts +8 -0
- package/dist/cjs/helperComponents/BaseIcon/BaseIcon.js +14 -0
- package/dist/cjs/helperComponents/BaseIcon/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BaseIcon/index.js +5 -0
- package/dist/cjs/helperComponents/ContentItemList/ContentItemList.d.ts +5 -0
- package/dist/cjs/helperComponents/ContentItemList/ContentItemList.js +12 -0
- package/dist/cjs/helperComponents/ContentItemList/index.d.ts +1 -0
- package/dist/cjs/helperComponents/ContentItemList/index.js +5 -0
- package/dist/cjs/helperComponents/ContentItemList/styles.module.css +5 -0
- package/dist/cjs/helperComponents/IconItemList/IconItemList.d.ts +6 -0
- package/dist/cjs/helperComponents/IconItemList/IconItemList.js +11 -0
- package/dist/cjs/helperComponents/IconItemList/index.d.ts +1 -0
- package/dist/cjs/helperComponents/IconItemList/index.js +5 -0
- package/dist/cjs/helperComponents/IconItemList/styles.module.css +12 -0
- package/dist/cjs/helperComponents/SelectedItemList/SelectedItemList.d.ts +8 -0
- package/dist/cjs/helperComponents/SelectedItemList/SelectedItemList.js +19 -0
- package/dist/cjs/helperComponents/SelectedItemList/index.d.ts +1 -0
- package/dist/cjs/helperComponents/SelectedItemList/index.js +5 -0
- package/dist/cjs/helperComponents/SelectedItemList/styles.module.css +32 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.d.ts +18 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.js +44 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/index.d.ts +2 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/index.js +5 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/styles.module.css +54 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/utils.d.ts +2 -0
- package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/utils.js +15 -0
- package/dist/cjs/helperComponents/TitleWithGoBack/TitleWithGoBack.d.ts +7 -0
- package/dist/cjs/helperComponents/TitleWithGoBack/TitleWithGoBack.js +13 -0
- package/dist/cjs/helperComponents/TitleWithGoBack/index.d.ts +1 -0
- package/dist/cjs/helperComponents/TitleWithGoBack/index.js +5 -0
- package/dist/cjs/helperComponents/TitleWithGoBack/styles.module.css +17 -0
- package/dist/cjs/helperComponents/Tooltip/Tooltip.d.ts +9 -0
- package/dist/cjs/helperComponents/Tooltip/Tooltip.js +26 -0
- package/dist/cjs/helperComponents/Tooltip/index.d.ts +1 -0
- package/dist/cjs/helperComponents/Tooltip/index.js +5 -0
- package/dist/cjs/helperComponents/Tooltip/styles.module.css +8 -0
- package/dist/cjs/helperComponents/index.d.ts +7 -0
- package/dist/cjs/helperComponents/index.js +17 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/types.d.ts +32 -0
- package/dist/cjs/types.js +2 -0
- package/dist/esm/components/SelectorPlatformDropList/SelectorPlatformDropList.d.ts +19 -0
- package/dist/esm/components/SelectorPlatformDropList/SelectorPlatformDropList.js +20 -0
- package/dist/esm/components/SelectorPlatformDropList/index.d.ts +2 -0
- package/dist/esm/components/SelectorPlatformDropList/index.js +1 -0
- package/dist/esm/components/SelectorPlatformDropList/platforms.d.ts +5 -0
- package/dist/esm/components/SelectorPlatformDropList/platforms.js +27 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/helperComponents/BaseIcon/BaseIcon.d.ts +8 -0
- package/dist/esm/helperComponents/BaseIcon/BaseIcon.js +11 -0
- package/dist/esm/helperComponents/BaseIcon/index.d.ts +1 -0
- package/dist/esm/helperComponents/BaseIcon/index.js +1 -0
- package/dist/esm/helperComponents/ContentItemList/ContentItemList.d.ts +5 -0
- package/dist/esm/helperComponents/ContentItemList/ContentItemList.js +6 -0
- package/dist/esm/helperComponents/ContentItemList/index.d.ts +1 -0
- package/dist/esm/helperComponents/ContentItemList/index.js +1 -0
- package/dist/esm/helperComponents/ContentItemList/styles.module.css +5 -0
- package/dist/esm/helperComponents/IconItemList/IconItemList.d.ts +6 -0
- package/dist/esm/helperComponents/IconItemList/IconItemList.js +5 -0
- package/dist/esm/helperComponents/IconItemList/index.d.ts +1 -0
- package/dist/esm/helperComponents/IconItemList/index.js +1 -0
- package/dist/esm/helperComponents/IconItemList/styles.module.css +12 -0
- package/dist/esm/helperComponents/SelectedItemList/SelectedItemList.d.ts +8 -0
- package/dist/esm/helperComponents/SelectedItemList/SelectedItemList.js +13 -0
- package/dist/esm/helperComponents/SelectedItemList/index.d.ts +1 -0
- package/dist/esm/helperComponents/SelectedItemList/index.js +1 -0
- package/dist/esm/helperComponents/SelectedItemList/styles.module.css +32 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.d.ts +18 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.js +38 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/index.d.ts +2 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/index.js +1 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/styles.module.css +54 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/utils.d.ts +2 -0
- package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/utils.js +12 -0
- package/dist/esm/helperComponents/TitleWithGoBack/TitleWithGoBack.d.ts +7 -0
- package/dist/esm/helperComponents/TitleWithGoBack/TitleWithGoBack.js +7 -0
- package/dist/esm/helperComponents/TitleWithGoBack/index.d.ts +1 -0
- package/dist/esm/helperComponents/TitleWithGoBack/index.js +1 -0
- package/dist/esm/helperComponents/TitleWithGoBack/styles.module.css +17 -0
- package/dist/esm/helperComponents/Tooltip/Tooltip.d.ts +9 -0
- package/dist/esm/helperComponents/Tooltip/Tooltip.js +20 -0
- package/dist/esm/helperComponents/Tooltip/index.d.ts +1 -0
- package/dist/esm/helperComponents/Tooltip/index.js +1 -0
- package/dist/esm/helperComponents/Tooltip/styles.module.css +8 -0
- package/dist/esm/helperComponents/index.d.ts +7 -0
- package/dist/esm/helperComponents/index.js +7 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.d.ts +32 -0
- package/dist/esm/types.js +1 -0
- package/package.json +48 -0
- package/src/components/SelectorPlatformDropList/SelectorPlatformDropList.tsx +69 -0
- package/src/components/SelectorPlatformDropList/index.ts +2 -0
- package/src/components/SelectorPlatformDropList/platforms.ts +35 -0
- package/src/components/index.ts +1 -0
- package/src/helperComponents/BaseIcon/BaseIcon.tsx +20 -0
- package/src/helperComponents/BaseIcon/index.ts +1 -0
- package/src/helperComponents/ContentItemList/ContentItemList.tsx +15 -0
- package/src/helperComponents/ContentItemList/index.ts +1 -0
- package/src/helperComponents/ContentItemList/styles.module.scss +5 -0
- package/src/helperComponents/IconItemList/IconItemList.tsx +14 -0
- package/src/helperComponents/IconItemList/index.ts +1 -0
- package/src/helperComponents/IconItemList/styles.module.scss +14 -0
- package/src/helperComponents/SelectedItemList/SelectedItemList.tsx +33 -0
- package/src/helperComponents/SelectedItemList/index.ts +1 -0
- package/src/helperComponents/SelectedItemList/styles.module.scss +35 -0
- package/src/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.tsx +132 -0
- package/src/helperComponents/SelectorPlatformDropListPrivate/index.ts +2 -0
- package/src/helperComponents/SelectorPlatformDropListPrivate/styles.module.scss +59 -0
- package/src/helperComponents/SelectorPlatformDropListPrivate/utils.ts +15 -0
- package/src/helperComponents/TitleWithGoBack/TitleWithGoBack.tsx +21 -0
- package/src/helperComponents/TitleWithGoBack/index.ts +1 -0
- package/src/helperComponents/TitleWithGoBack/styles.module.scss +21 -0
- package/src/helperComponents/Tooltip/Tooltip.tsx +33 -0
- package/src/helperComponents/Tooltip/index.ts +1 -0
- package/src/helperComponents/Tooltip/styles.module.scss +10 -0
- package/src/helperComponents/index.ts +7 -0
- package/src/index.ts +1 -0
- package/src/types.ts +37 -0
package/src/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.tsx
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ReactNode, useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { ChevronDownSVG, ChevronUpSVG } from '@cloud-ru/uikit-product-icons';
|
|
4
|
+
import { AdaptiveDroplist } from '@cloud-ru/uikit-product-mobile-dropdown';
|
|
5
|
+
import { MobileModalCustom } from '@cloud-ru/uikit-product-mobile-modal';
|
|
6
|
+
import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
7
|
+
import { DroplistProps } from '@snack-uikit/list';
|
|
8
|
+
import { Typography } from '@snack-uikit/typography';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
BaseIcon,
|
|
12
|
+
ContentItemList,
|
|
13
|
+
IconItemList,
|
|
14
|
+
SelectedItemList,
|
|
15
|
+
TitleWithGoBack,
|
|
16
|
+
Tooltip,
|
|
17
|
+
} from '../../helperComponents';
|
|
18
|
+
import {
|
|
19
|
+
IconSelector,
|
|
20
|
+
Item,
|
|
21
|
+
MultipleSelectorPlatformDropListProps,
|
|
22
|
+
SingleSelectorPlatformDropListProps,
|
|
23
|
+
TooltipMobile,
|
|
24
|
+
} from '../../types';
|
|
25
|
+
import styles from './styles.module.scss';
|
|
26
|
+
import { findItems } from './utils';
|
|
27
|
+
|
|
28
|
+
type BaseSelectorPlatformDropListPrivateProps = WithLayoutType<{
|
|
29
|
+
/** Заголовок верхней части блока выбора */
|
|
30
|
+
title: string;
|
|
31
|
+
/** Базовый заголовок нижней части блока выбора, отображается когда ничего не выбрано */
|
|
32
|
+
baseTitle: string;
|
|
33
|
+
/** Базовая иконка блока выбора слева, отображается когда ничего не выбрано */
|
|
34
|
+
baseIcon?: IconSelector;
|
|
35
|
+
/** Список элементов droplist */
|
|
36
|
+
items: Array<Item>;
|
|
37
|
+
/** Нижняя часть под списком droplist */
|
|
38
|
+
footer?: ReactNode;
|
|
39
|
+
}>;
|
|
40
|
+
|
|
41
|
+
export type SelectorPlatformDropListPrivateProps = BaseSelectorPlatformDropListPrivateProps &
|
|
42
|
+
(MultipleSelectorPlatformDropListProps | SingleSelectorPlatformDropListProps);
|
|
43
|
+
|
|
44
|
+
export function SelectorPlatformDropListPrivate({
|
|
45
|
+
items,
|
|
46
|
+
value,
|
|
47
|
+
onChange,
|
|
48
|
+
footer,
|
|
49
|
+
title,
|
|
50
|
+
baseTitle,
|
|
51
|
+
baseIcon,
|
|
52
|
+
layoutType,
|
|
53
|
+
mode,
|
|
54
|
+
}: SelectorPlatformDropListPrivateProps) {
|
|
55
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
56
|
+
const [tooltipMobile, setTooltipMobile] = useState<TooltipMobile>({
|
|
57
|
+
open: false,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const handleCloseTooltipMobile = () => {
|
|
61
|
+
setTooltipMobile({
|
|
62
|
+
open: false,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const itemsView = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
items.map(item => ({
|
|
69
|
+
id: item.id,
|
|
70
|
+
content: <ContentItemList title={item.title} />,
|
|
71
|
+
beforeContent: <IconItemList icon={item.icon} />,
|
|
72
|
+
afterContent: (
|
|
73
|
+
<Tooltip setTooltipMobile={setTooltipMobile} tooltipText={item.tooltipText} layoutType={layoutType} />
|
|
74
|
+
),
|
|
75
|
+
className: styles.rowItem,
|
|
76
|
+
onClick: item.onClick,
|
|
77
|
+
})),
|
|
78
|
+
[items, layoutType],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const itemsWithDivider: DroplistProps['items'] = useMemo(
|
|
82
|
+
() => [...itemsView, { type: 'group', divider: true, items: [] }],
|
|
83
|
+
[itemsView],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const selection = useMemo(
|
|
87
|
+
() =>
|
|
88
|
+
mode === 'multiple'
|
|
89
|
+
? ({ value, onChange, mode: 'multiple' } as MultipleSelectorPlatformDropListProps)
|
|
90
|
+
: ({ value, onChange, mode: 'single' } as SingleSelectorPlatformDropListProps),
|
|
91
|
+
[mode, onChange, value],
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const foundItems = useMemo(() => findItems(items, value), [items, value]);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
<AdaptiveDroplist
|
|
99
|
+
// @ts-expect-error label существует только у MobileDroplist, отсутствует у Droplist
|
|
100
|
+
label={<TitleWithGoBack title='Облачная платформа' />}
|
|
101
|
+
layoutType={layoutType}
|
|
102
|
+
trigger='click'
|
|
103
|
+
open={isOpen}
|
|
104
|
+
items={footer ? itemsWithDivider : itemsView}
|
|
105
|
+
onOpenChange={setIsOpen}
|
|
106
|
+
selection={selection}
|
|
107
|
+
footer={footer}
|
|
108
|
+
closeDroplistOnItemClick
|
|
109
|
+
size='m'
|
|
110
|
+
>
|
|
111
|
+
<div className={styles.root} data-focus={isOpen} role='button'>
|
|
112
|
+
<BaseIcon baseIcon={baseIcon} value={foundItems} lengthDroplist={items.length} />
|
|
113
|
+
<div className={styles.titleContainer}>
|
|
114
|
+
<Typography className={styles.valueLabel} family='sans' purpose='body' size='s'>
|
|
115
|
+
{title}
|
|
116
|
+
</Typography>
|
|
117
|
+
<SelectedItemList lengthDroplist={items.length} baseTitle={baseTitle} value={foundItems} />
|
|
118
|
+
</div>
|
|
119
|
+
<div className={styles.iconContainer}>
|
|
120
|
+
{isOpen ? <ChevronUpSVG className={styles.icon} /> : <ChevronDownSVG className={styles.icon} />}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</AdaptiveDroplist>
|
|
124
|
+
<MobileModalCustom open={tooltipMobile.open} onClose={handleCloseTooltipMobile}>
|
|
125
|
+
<MobileModalCustom.Header
|
|
126
|
+
title={<TitleWithGoBack onGoBack={handleCloseTooltipMobile} title='Облачная платформа' />}
|
|
127
|
+
/>
|
|
128
|
+
<MobileModalCustom.Body content={<Typography.SansBodyL>{tooltipMobile.text}</Typography.SansBodyL>} />
|
|
129
|
+
</MobileModalCustom>
|
|
130
|
+
</>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-web/build/scss/components/styles-tokens-element' as ste;
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 8px;
|
|
8
|
+
height: 48px;
|
|
9
|
+
padding: 4px 12px 4px 8px;
|
|
10
|
+
background-color: ste.$sys-neutral-background1-level;
|
|
11
|
+
border: 1px solid ste.$sys-neutral-decor-default;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
border-color: ste.$sys-neutral-decor-hovered;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&[data-focus='true'] {
|
|
19
|
+
@include ste.outline-var(ste.$container-focused-m);
|
|
20
|
+
|
|
21
|
+
background-color: ste.simple-var(ste.$sys-neutral-background2-level);
|
|
22
|
+
border-color: ste.simple-var(ste.$theme-variables, 'sys', 'primary', 'accent-default');
|
|
23
|
+
outline-color: ste.simple-var(ste.$theme-variables, 'sys', 'primary', 'decor-activated');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.titleContainer {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
height: 36px;
|
|
32
|
+
width: 100%;
|
|
33
|
+
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.iconContainer {
|
|
39
|
+
width: 24px;
|
|
40
|
+
height: 24px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.valueLabel {
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
color: ste.$sys-neutral-text-light;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.valueTitle {
|
|
49
|
+
color: ste.$sys-neutral-text-main;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.icon {
|
|
53
|
+
color: ste.$sys-graphite-text-main;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rowItem {
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
}
|
|
59
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Item } from '../../types';
|
|
2
|
+
|
|
3
|
+
export function findItems(items: Array<Item>, value: Array<string> | string | undefined) {
|
|
4
|
+
if (!value) return [];
|
|
5
|
+
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
const foundItem = items.find(item => item.id === value);
|
|
8
|
+
if (!foundItem) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return [foundItem];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return items.filter(item => value.find(val => val === item.id));
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { ArrowLeftSVG } from '@cloud-ru/uikit-product-icons';
|
|
4
|
+
import { Typography } from '@snack-uikit/typography';
|
|
5
|
+
|
|
6
|
+
import s from './styles.module.scss';
|
|
7
|
+
|
|
8
|
+
type TitleWithGoBackProps = {
|
|
9
|
+
title: ReactNode;
|
|
10
|
+
onGoBack?: MouseEventHandler<SVGElement>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function TitleWithGoBack({ onGoBack, title }: TitleWithGoBackProps) {
|
|
14
|
+
return (
|
|
15
|
+
<div className={s.wrapper} data-icon-back={Boolean(onGoBack)}>
|
|
16
|
+
{onGoBack && <ArrowLeftSVG size={24} className={s.arrow} onClick={onGoBack} />}
|
|
17
|
+
<Typography.SansTitleL>{title}</Typography.SansTitleL>
|
|
18
|
+
{onGoBack && <div className={s.buttonStub} />}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TitleWithGoBack } from './TitleWithGoBack';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as ste;
|
|
2
|
+
|
|
3
|
+
.wrapper {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: space-between;
|
|
7
|
+
// оставляем, потому нет возможности отцентрировать через пропс, в компоненте AdaptiveDroplist ->MobileDroplist -> MobileModalCustom.Header не передается align, который в MobileModalCustom.Header имеется
|
|
8
|
+
width: calc(100vw - 32px);
|
|
9
|
+
|
|
10
|
+
&[data-icon-back="false"] {
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.arrow {
|
|
16
|
+
color: ste.$sys-neutral-text-light;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.buttonStub {
|
|
20
|
+
width: 24px;
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Dispatch, MouseEvent, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
import { QuestionSVG } from '@cloud-ru/uikit-product-icons';
|
|
4
|
+
import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
5
|
+
import { QuestionTooltip } from '@snack-uikit/tooltip';
|
|
6
|
+
|
|
7
|
+
import { TooltipMobile } from '../../types';
|
|
8
|
+
import styles from './styles.module.scss';
|
|
9
|
+
|
|
10
|
+
type TooltipProps = WithLayoutType<{
|
|
11
|
+
tooltipText?: string;
|
|
12
|
+
setTooltipMobile: Dispatch<SetStateAction<TooltipMobile>>;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export function Tooltip({ layoutType, tooltipText, setTooltipMobile }: TooltipProps) {
|
|
16
|
+
if (!tooltipText) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (layoutType !== 'mobile') {
|
|
21
|
+
return <QuestionTooltip className={styles.questionTooltip} tip={tooltipText} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const handleOpen = (event: MouseEvent<SVGElement>) => {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
setTooltipMobile({
|
|
27
|
+
open: true,
|
|
28
|
+
text: tooltipText,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return <QuestionSVG className={styles.icon} onClick={handleOpen} size={16} />;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tooltip } from './Tooltip';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { SelectedItemList } from './SelectedItemList';
|
|
2
|
+
export { ContentItemList } from './ContentItemList';
|
|
3
|
+
export { IconItemList } from './IconItemList';
|
|
4
|
+
export { BaseIcon } from './BaseIcon';
|
|
5
|
+
export { TitleWithGoBack } from './TitleWithGoBack';
|
|
6
|
+
export { Tooltip } from './Tooltip';
|
|
7
|
+
export { SelectorPlatformDropListPrivate } from './SelectorPlatformDropListPrivate';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { JSXElementConstructor } from 'react';
|
|
2
|
+
|
|
3
|
+
export type IconSelector = JSXElementConstructor<{
|
|
4
|
+
size?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
}>;
|
|
7
|
+
|
|
8
|
+
export type Item = {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
icon: IconSelector;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
tooltipText?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type TooltipMobile = {
|
|
17
|
+
open: boolean;
|
|
18
|
+
text?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type MultipleSelectorPlatformDropListProps = {
|
|
22
|
+
/** Режим выбора */
|
|
23
|
+
mode: 'multiple';
|
|
24
|
+
/** Controlled состояние */
|
|
25
|
+
value: Array<string>;
|
|
26
|
+
/** Controlled обработчик изменения состояния */
|
|
27
|
+
onChange(value: Array<string>): void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type SingleSelectorPlatformDropListProps = {
|
|
31
|
+
/** Режим выбора */
|
|
32
|
+
mode: 'single';
|
|
33
|
+
/** Controlled состояние */
|
|
34
|
+
value: string | undefined;
|
|
35
|
+
/** Controlled обработчик изменения состояния */
|
|
36
|
+
onChange(value: string | undefined): void;
|
|
37
|
+
};
|