@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/dist/esm/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
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 { Typography } from '@snack-uikit/typography';
|
|
7
|
+
import { BaseIcon, ContentItemList, IconItemList, SelectedItemList, TitleWithGoBack, Tooltip, } from '../../helperComponents';
|
|
8
|
+
import styles from './styles.module.css';
|
|
9
|
+
import { findItems } from './utils';
|
|
10
|
+
export function SelectorPlatformDropListPrivate({ items, value, onChange, footer, title, baseTitle, baseIcon, layoutType, mode, }) {
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const [tooltipMobile, setTooltipMobile] = useState({
|
|
13
|
+
open: false,
|
|
14
|
+
});
|
|
15
|
+
const handleCloseTooltipMobile = () => {
|
|
16
|
+
setTooltipMobile({
|
|
17
|
+
open: false,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const itemsView = useMemo(() => items.map(item => ({
|
|
21
|
+
id: item.id,
|
|
22
|
+
content: _jsx(ContentItemList, { title: item.title }),
|
|
23
|
+
beforeContent: _jsx(IconItemList, { icon: item.icon }),
|
|
24
|
+
afterContent: (_jsx(Tooltip, { setTooltipMobile: setTooltipMobile, tooltipText: item.tooltipText, layoutType: layoutType })),
|
|
25
|
+
className: styles.rowItem,
|
|
26
|
+
onClick: item.onClick,
|
|
27
|
+
})), [items, layoutType]);
|
|
28
|
+
const itemsWithDivider = useMemo(() => [...itemsView, { type: 'group', divider: true, items: [] }], [itemsView]);
|
|
29
|
+
const selection = useMemo(() => mode === 'multiple'
|
|
30
|
+
? { value, onChange, mode: 'multiple' }
|
|
31
|
+
: { value, onChange, mode: 'single' }, [mode, onChange, value]);
|
|
32
|
+
const foundItems = useMemo(() => findItems(items, value), [items, value]);
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx(AdaptiveDroplist
|
|
34
|
+
// @ts-expect-error label существует только у MobileDroplist, отсутствует у Droplist
|
|
35
|
+
, {
|
|
36
|
+
// @ts-expect-error label существует только у MobileDroplist, отсутствует у Droplist
|
|
37
|
+
label: _jsx(TitleWithGoBack, { title: '\u041E\u0431\u043B\u0430\u0447\u043D\u0430\u044F \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430' }), layoutType: layoutType, trigger: 'click', open: isOpen, items: footer ? itemsWithDivider : itemsView, onOpenChange: setIsOpen, selection: selection, footer: footer, closeDroplistOnItemClick: true, size: 'm', children: _jsxs("div", { className: styles.root, "data-focus": isOpen, role: 'button', children: [_jsx(BaseIcon, { baseIcon: baseIcon, value: foundItems, lengthDroplist: items.length }), _jsxs("div", { className: styles.titleContainer, children: [_jsx(Typography, { className: styles.valueLabel, family: 'sans', purpose: 'body', size: 's', children: title }), _jsx(SelectedItemList, { lengthDroplist: items.length, baseTitle: baseTitle, value: foundItems })] }), _jsx("div", { className: styles.iconContainer, children: isOpen ? _jsx(ChevronUpSVG, { className: styles.icon }) : _jsx(ChevronDownSVG, { className: styles.icon }) })] }) }), _jsxs(MobileModalCustom, { open: tooltipMobile.open, onClose: handleCloseTooltipMobile, children: [_jsx(MobileModalCustom.Header, { title: _jsx(TitleWithGoBack, { onGoBack: handleCloseTooltipMobile, title: '\u041E\u0431\u043B\u0430\u0447\u043D\u0430\u044F \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430' }) }), _jsx(MobileModalCustom.Body, { content: _jsx(Typography.SansBodyL, { children: tooltipMobile.text }) })] })] }));
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectorPlatformDropListPrivate } from './SelectorPlatformDropListPrivate';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.root{
|
|
2
|
+
cursor:pointer;
|
|
3
|
+
display:flex;
|
|
4
|
+
align-items:center;
|
|
5
|
+
gap:8px;
|
|
6
|
+
height:48px;
|
|
7
|
+
padding:4px 12px 4px 8px;
|
|
8
|
+
background-color:var(--sys-neutral-background1-level, #fdfdfd);
|
|
9
|
+
border:1px solid var(--sys-neutral-decor-default, #dde0ea);
|
|
10
|
+
box-sizing:border-box;
|
|
11
|
+
}
|
|
12
|
+
.root:hover{
|
|
13
|
+
border-color:var(--sys-neutral-decor-hovered, #cfd2dc);
|
|
14
|
+
}
|
|
15
|
+
.root[data-focus=true]{
|
|
16
|
+
outline-width:var(--border-state-focus-m-border-width, 3px);
|
|
17
|
+
outline-style:var(--border-state-focus-m-border-style, solid);
|
|
18
|
+
outline-color:var(--border-state-focus-m-border-color, );
|
|
19
|
+
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
20
|
+
border-color:var(--sys-primary-accent-default, #26d07c);
|
|
21
|
+
outline-color:var(--sys-primary-decor-activated, #8ee7bb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.titleContainer{
|
|
25
|
+
display:flex;
|
|
26
|
+
flex-direction:column;
|
|
27
|
+
justify-content:space-between;
|
|
28
|
+
height:36px;
|
|
29
|
+
width:100%;
|
|
30
|
+
flex:1 1 auto;
|
|
31
|
+
min-width:0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.iconContainer{
|
|
35
|
+
width:24px;
|
|
36
|
+
height:24px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.valueLabel{
|
|
40
|
+
cursor:pointer;
|
|
41
|
+
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.valueTitle{
|
|
45
|
+
color:var(--sys-neutral-text-main, #41424e);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.icon{
|
|
49
|
+
color:var(--sys-graphite-text-main, #222222);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.rowItem{
|
|
53
|
+
box-sizing:border-box;
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function findItems(items, value) {
|
|
2
|
+
if (!value)
|
|
3
|
+
return [];
|
|
4
|
+
if (typeof value === 'string') {
|
|
5
|
+
const foundItem = items.find(item => item.id === value);
|
|
6
|
+
if (!foundItem) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
return [foundItem];
|
|
10
|
+
}
|
|
11
|
+
return items.filter(item => value.find(val => val === item.id));
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
type TitleWithGoBackProps = {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
onGoBack?: MouseEventHandler<SVGElement>;
|
|
5
|
+
};
|
|
6
|
+
export declare function TitleWithGoBack({ onGoBack, title }: TitleWithGoBackProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowLeftSVG } from '@cloud-ru/uikit-product-icons';
|
|
3
|
+
import { Typography } from '@snack-uikit/typography';
|
|
4
|
+
import s from './styles.module.css';
|
|
5
|
+
export function TitleWithGoBack({ onGoBack, title }) {
|
|
6
|
+
return (_jsxs("div", { className: s.wrapper, "data-icon-back": Boolean(onGoBack), children: [onGoBack && _jsx(ArrowLeftSVG, { size: 24, className: s.arrow, onClick: onGoBack }), _jsx(Typography.SansTitleL, { children: title }), onGoBack && _jsx("div", { className: s.buttonStub })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TitleWithGoBack } from './TitleWithGoBack';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TitleWithGoBack } from './TitleWithGoBack';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.wrapper{
|
|
2
|
+
display:flex;
|
|
3
|
+
align-items:center;
|
|
4
|
+
justify-content:space-between;
|
|
5
|
+
width:calc(100vw - 32px);
|
|
6
|
+
}
|
|
7
|
+
.wrapper[data-icon-back=false]{
|
|
8
|
+
justify-content:center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.arrow{
|
|
12
|
+
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.buttonStub{
|
|
16
|
+
width:24px;
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
3
|
+
import { TooltipMobile } from '../../types';
|
|
4
|
+
type TooltipProps = WithLayoutType<{
|
|
5
|
+
tooltipText?: string;
|
|
6
|
+
setTooltipMobile: Dispatch<SetStateAction<TooltipMobile>>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function Tooltip({ layoutType, tooltipText, setTooltipMobile }: TooltipProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { QuestionSVG } from '@cloud-ru/uikit-product-icons';
|
|
3
|
+
import { QuestionTooltip } from '@snack-uikit/tooltip';
|
|
4
|
+
import styles from './styles.module.css';
|
|
5
|
+
export function Tooltip({ layoutType, tooltipText, setTooltipMobile }) {
|
|
6
|
+
if (!tooltipText) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (layoutType !== 'mobile') {
|
|
10
|
+
return _jsx(QuestionTooltip, { className: styles.questionTooltip, tip: tooltipText });
|
|
11
|
+
}
|
|
12
|
+
const handleOpen = (event) => {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
setTooltipMobile({
|
|
15
|
+
open: true,
|
|
16
|
+
text: tooltipText,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return _jsx(QuestionSVG, { className: styles.icon, onClick: handleOpen, size: 16 });
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tooltip } from './Tooltip';
|
|
@@ -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';
|
|
@@ -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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { JSXElementConstructor } from 'react';
|
|
2
|
+
export type IconSelector = JSXElementConstructor<{
|
|
3
|
+
size?: number;
|
|
4
|
+
className?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type Item = {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
icon: IconSelector;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
tooltipText?: string;
|
|
12
|
+
};
|
|
13
|
+
export type TooltipMobile = {
|
|
14
|
+
open: boolean;
|
|
15
|
+
text?: string;
|
|
16
|
+
};
|
|
17
|
+
export type MultipleSelectorPlatformDropListProps = {
|
|
18
|
+
/** Режим выбора */
|
|
19
|
+
mode: 'multiple';
|
|
20
|
+
/** Controlled состояние */
|
|
21
|
+
value: Array<string>;
|
|
22
|
+
/** Controlled обработчик изменения состояния */
|
|
23
|
+
onChange(value: Array<string>): void;
|
|
24
|
+
};
|
|
25
|
+
export type SingleSelectorPlatformDropListProps = {
|
|
26
|
+
/** Режим выбора */
|
|
27
|
+
mode: 'single';
|
|
28
|
+
/** Controlled состояние */
|
|
29
|
+
value: string | undefined;
|
|
30
|
+
/** Controlled обработчик изменения состояния */
|
|
31
|
+
onChange(value: string | undefined): void;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloud-ru/uikit-product-site-selector-platform-drop-list",
|
|
3
|
+
"title": "Site Selector Platform DropList",
|
|
4
|
+
"version": "0.1.4",
|
|
5
|
+
"sideEffects": [
|
|
6
|
+
"*.css",
|
|
7
|
+
"*.woff",
|
|
8
|
+
"*.woff2"
|
|
9
|
+
],
|
|
10
|
+
"description": "Site Selector Platform DropList",
|
|
11
|
+
"types": "./dist/esm/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/esm",
|
|
18
|
+
"dist/cjs",
|
|
19
|
+
"src",
|
|
20
|
+
"./CHANGELOG.md",
|
|
21
|
+
"./LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"homepage": "https://gitverse.ru/cloud-ru-tech/uikit-product/-/tree/master/packages/site-site-selector-platform-drop-list",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://gitverse.ru/cloud-ru-tech/uikit-product.git",
|
|
27
|
+
"directory": "packages/site-site-selector-platform-drop-list"
|
|
28
|
+
},
|
|
29
|
+
"author": "daparfirov <daparfirov@cloud.ru>",
|
|
30
|
+
"contributors": [
|
|
31
|
+
"daparfirov <daparfirov@cloud.ru>"
|
|
32
|
+
],
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"scripts": {},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@cloud-ru/uikit-product-icons": "15.1.6",
|
|
40
|
+
"@cloud-ru/uikit-product-mobile-dropdown": "0.9.26",
|
|
41
|
+
"@cloud-ru/uikit-product-mobile-modal": "0.9.23",
|
|
42
|
+
"@cloud-ru/uikit-product-utils": "8.0.1",
|
|
43
|
+
"@snack-uikit/list": "0.32.7",
|
|
44
|
+
"@snack-uikit/tooltip": "0.18.5",
|
|
45
|
+
"@snack-uikit/typography": "0.8.11"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "9d319ea89df880ac5585f1da30140c8e1ed69086"
|
|
48
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ReactNode, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CloudSVG } from '@cloud-ru/uikit-product-icons';
|
|
4
|
+
import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
5
|
+
|
|
6
|
+
import { SelectorPlatformDropListPrivate } from '../../helperComponents';
|
|
7
|
+
import { Item, MultipleSelectorPlatformDropListProps, SingleSelectorPlatformDropListProps } from '../../types';
|
|
8
|
+
import { PLATFORMS } from './platforms';
|
|
9
|
+
|
|
10
|
+
export type PlatformType = 'advanced' | 'evolution' | 'vmware' | 'all';
|
|
11
|
+
|
|
12
|
+
export type Platform = {
|
|
13
|
+
/** Тип элемента */
|
|
14
|
+
type: PlatformType;
|
|
15
|
+
/** Колбек клика на элемент */
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type BaseSelectorPlatformDropListProps = WithLayoutType<{
|
|
20
|
+
/** Список элементов droplist */
|
|
21
|
+
items: Array<Platform>;
|
|
22
|
+
/** Нижняя часть под списком droplist */
|
|
23
|
+
footer?: ReactNode;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
export type SelectorPlatformDropListProps = BaseSelectorPlatformDropListProps &
|
|
27
|
+
(MultipleSelectorPlatformDropListProps | SingleSelectorPlatformDropListProps);
|
|
28
|
+
|
|
29
|
+
export function SelectorPlatformDropList({
|
|
30
|
+
items,
|
|
31
|
+
value,
|
|
32
|
+
footer,
|
|
33
|
+
onChange,
|
|
34
|
+
layoutType,
|
|
35
|
+
mode,
|
|
36
|
+
}: SelectorPlatformDropListProps) {
|
|
37
|
+
const selection = useMemo(
|
|
38
|
+
() =>
|
|
39
|
+
mode === 'multiple'
|
|
40
|
+
? ({
|
|
41
|
+
value,
|
|
42
|
+
onChange,
|
|
43
|
+
mode: 'multiple',
|
|
44
|
+
} as MultipleSelectorPlatformDropListProps)
|
|
45
|
+
: ({
|
|
46
|
+
value,
|
|
47
|
+
onChange,
|
|
48
|
+
mode: 'single',
|
|
49
|
+
} as SingleSelectorPlatformDropListProps),
|
|
50
|
+
[mode, value, onChange],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const itemsView: Array<Item> = useMemo(
|
|
54
|
+
() => items.map(({ type, onClick }: Platform) => ({ ...PLATFORMS[type], onClick })),
|
|
55
|
+
[items],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<SelectorPlatformDropListPrivate
|
|
60
|
+
layoutType={layoutType === 'tablet' ? 'mobile' : layoutType}
|
|
61
|
+
items={itemsView}
|
|
62
|
+
title={'Облачная платформа'}
|
|
63
|
+
baseTitle={'Все платформы'}
|
|
64
|
+
baseIcon={CloudSVG}
|
|
65
|
+
footer={footer}
|
|
66
|
+
{...selection}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AdvancedSVG, CloudSVG, EvolutionSVG, VMwareBackupServerSVG } from '@cloud-ru/uikit-product-icons';
|
|
2
|
+
|
|
3
|
+
import { Item } from '../../types';
|
|
4
|
+
import { PlatformType } from './SelectorPlatformDropList';
|
|
5
|
+
|
|
6
|
+
export const PLATFORMS: { [key in PlatformType]: Item } = {
|
|
7
|
+
evolution: {
|
|
8
|
+
id: 'evolution',
|
|
9
|
+
title: 'Evolution',
|
|
10
|
+
icon: EvolutionSVG,
|
|
11
|
+
tooltipText:
|
|
12
|
+
'Платформа собственной разработки с доступом к IaaS- и PaaS-сервисам, вычислительным мощностям с GPU, аренде выделенных физических серверов и AI-инструментам.',
|
|
13
|
+
},
|
|
14
|
+
advanced: {
|
|
15
|
+
id: 'advanced',
|
|
16
|
+
title: 'Advanced',
|
|
17
|
+
icon: AdvancedSVG,
|
|
18
|
+
tooltipText:
|
|
19
|
+
'Вендорская платформа с широким набором IaaS- и PaaS-сервисов от одного из лидеров мирового рынка облачных услуг.',
|
|
20
|
+
},
|
|
21
|
+
vmware: {
|
|
22
|
+
id: 'vmware',
|
|
23
|
+
title: 'Облако VMware',
|
|
24
|
+
icon: VMwareBackupServerSVG,
|
|
25
|
+
tooltipText:
|
|
26
|
+
'Вендорская платформа, предоставляющая инфраструктуру как услугу, основанную на технологиях VMware — ведущего поставщика решений IaaS.',
|
|
27
|
+
},
|
|
28
|
+
all: {
|
|
29
|
+
id: 'all',
|
|
30
|
+
title: 'Все платформы',
|
|
31
|
+
icon: CloudSVG,
|
|
32
|
+
tooltipText:
|
|
33
|
+
'Совокупность сервисов, программных и/или аппаратных средств, решающих определенную задачу или группу задач.',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SelectorPlatformDropList';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IconSelector, Item } from '../../types';
|
|
2
|
+
import { IconItemList } from '../IconItemList';
|
|
3
|
+
|
|
4
|
+
type BaseIconProps = {
|
|
5
|
+
baseIcon?: IconSelector;
|
|
6
|
+
value: Array<Item>;
|
|
7
|
+
lengthDroplist: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function BaseIcon({ baseIcon, value, lengthDroplist }: BaseIconProps) {
|
|
11
|
+
if (value.length === 1) {
|
|
12
|
+
return <IconItemList icon={value[0].icon} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!baseIcon || (value.length > 1 && lengthDroplist !== value.length)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return <IconItemList icon={baseIcon} />;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BaseIcon } from './BaseIcon';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Typography } from '@snack-uikit/typography';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
type ContentItemListProps = {
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function ContentItemList({ title }: ContentItemListProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className={styles.container}>
|
|
12
|
+
<Typography.SansTitleS>{title}</Typography.SansTitleS>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContentItemList } from './ContentItemList';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IconSelector } from '../../types';
|
|
2
|
+
import styles from './styles.module.scss';
|
|
3
|
+
|
|
4
|
+
type IconItemListProps = {
|
|
5
|
+
icon: IconSelector;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function IconItemList({ icon: IconComponent }: IconItemListProps) {
|
|
9
|
+
return (
|
|
10
|
+
<div className={styles.container}>
|
|
11
|
+
<IconComponent size={24} className={styles.icon} />
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconItemList } from './IconItemList';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-web/build/scss/styles-theme-variables' as ste;
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
min-width: 32px;
|
|
8
|
+
min-height: 32px;
|
|
9
|
+
background: ste.$sys-graphite-background;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.icon {
|
|
13
|
+
color: ste.$sys-neutral-text-main;
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Typography } from '@snack-uikit/typography';
|
|
2
|
+
|
|
3
|
+
import { Item } from '../../types';
|
|
4
|
+
import styles from './styles.module.scss';
|
|
5
|
+
|
|
6
|
+
type SelectedItemListProps = {
|
|
7
|
+
baseTitle: string;
|
|
8
|
+
value: Array<Item>;
|
|
9
|
+
lengthDroplist: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function SelectedItemList({ baseTitle, value, lengthDroplist }: SelectedItemListProps) {
|
|
13
|
+
if (value.length === 0 || value.length === lengthDroplist) {
|
|
14
|
+
return <Typography.SansTitleS className={styles.text}>{baseTitle}</Typography.SansTitleS>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value.length === 1) {
|
|
18
|
+
return <Typography.SansTitleS className={styles.text}>{value[0]?.title}</Typography.SansTitleS>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className={styles.container}>
|
|
23
|
+
{value.map(({ title, icon: IconComponent }, index) => (
|
|
24
|
+
<div key={title} className={styles.item}>
|
|
25
|
+
{IconComponent && <IconComponent size={12} className={styles.icon} />}
|
|
26
|
+
<Typography.SansLabelM className={styles.text}>
|
|
27
|
+
{`${title}${index !== value.length - 1 ? ',' : ''}`}
|
|
28
|
+
</Typography.SansLabelM>
|
|
29
|
+
</div>
|
|
30
|
+
))}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectedItemList } from './SelectedItemList';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as ste;
|
|
2
|
+
|
|
3
|
+
.iconPlatform {
|
|
4
|
+
color: ste.$sys-primary-text-light;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.text {
|
|
8
|
+
color: ste.$sys-neutral-text-main;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.container {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 8px;
|
|
14
|
+
flex-wrap: nowrap;
|
|
15
|
+
align-items: center;
|
|
16
|
+
margin-bottom: 2px;
|
|
17
|
+
width: 100%;
|
|
18
|
+
|
|
19
|
+
flex: 1 1 auto;
|
|
20
|
+
min-width: 0;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.item {
|
|
27
|
+
display: flex;
|
|
28
|
+
gap: 4px;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.icon {
|
|
34
|
+
color: ste.$sys-primary-text-light;
|
|
35
|
+
}
|