@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.
Files changed (132) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +201 -0
  3. package/README.md +24 -0
  4. package/dist/cjs/components/SelectorPlatformDropList/SelectorPlatformDropList.d.ts +19 -0
  5. package/dist/cjs/components/SelectorPlatformDropList/SelectorPlatformDropList.js +23 -0
  6. package/dist/cjs/components/SelectorPlatformDropList/index.d.ts +2 -0
  7. package/dist/cjs/components/SelectorPlatformDropList/index.js +5 -0
  8. package/dist/cjs/components/SelectorPlatformDropList/platforms.d.ts +5 -0
  9. package/dist/cjs/components/SelectorPlatformDropList/platforms.js +30 -0
  10. package/dist/cjs/components/index.d.ts +1 -0
  11. package/dist/cjs/components/index.js +17 -0
  12. package/dist/cjs/helperComponents/BaseIcon/BaseIcon.d.ts +8 -0
  13. package/dist/cjs/helperComponents/BaseIcon/BaseIcon.js +14 -0
  14. package/dist/cjs/helperComponents/BaseIcon/index.d.ts +1 -0
  15. package/dist/cjs/helperComponents/BaseIcon/index.js +5 -0
  16. package/dist/cjs/helperComponents/ContentItemList/ContentItemList.d.ts +5 -0
  17. package/dist/cjs/helperComponents/ContentItemList/ContentItemList.js +12 -0
  18. package/dist/cjs/helperComponents/ContentItemList/index.d.ts +1 -0
  19. package/dist/cjs/helperComponents/ContentItemList/index.js +5 -0
  20. package/dist/cjs/helperComponents/ContentItemList/styles.module.css +5 -0
  21. package/dist/cjs/helperComponents/IconItemList/IconItemList.d.ts +6 -0
  22. package/dist/cjs/helperComponents/IconItemList/IconItemList.js +11 -0
  23. package/dist/cjs/helperComponents/IconItemList/index.d.ts +1 -0
  24. package/dist/cjs/helperComponents/IconItemList/index.js +5 -0
  25. package/dist/cjs/helperComponents/IconItemList/styles.module.css +12 -0
  26. package/dist/cjs/helperComponents/SelectedItemList/SelectedItemList.d.ts +8 -0
  27. package/dist/cjs/helperComponents/SelectedItemList/SelectedItemList.js +19 -0
  28. package/dist/cjs/helperComponents/SelectedItemList/index.d.ts +1 -0
  29. package/dist/cjs/helperComponents/SelectedItemList/index.js +5 -0
  30. package/dist/cjs/helperComponents/SelectedItemList/styles.module.css +32 -0
  31. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.d.ts +18 -0
  32. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.js +44 -0
  33. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/index.d.ts +2 -0
  34. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/index.js +5 -0
  35. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/styles.module.css +54 -0
  36. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/utils.d.ts +2 -0
  37. package/dist/cjs/helperComponents/SelectorPlatformDropListPrivate/utils.js +15 -0
  38. package/dist/cjs/helperComponents/TitleWithGoBack/TitleWithGoBack.d.ts +7 -0
  39. package/dist/cjs/helperComponents/TitleWithGoBack/TitleWithGoBack.js +13 -0
  40. package/dist/cjs/helperComponents/TitleWithGoBack/index.d.ts +1 -0
  41. package/dist/cjs/helperComponents/TitleWithGoBack/index.js +5 -0
  42. package/dist/cjs/helperComponents/TitleWithGoBack/styles.module.css +17 -0
  43. package/dist/cjs/helperComponents/Tooltip/Tooltip.d.ts +9 -0
  44. package/dist/cjs/helperComponents/Tooltip/Tooltip.js +26 -0
  45. package/dist/cjs/helperComponents/Tooltip/index.d.ts +1 -0
  46. package/dist/cjs/helperComponents/Tooltip/index.js +5 -0
  47. package/dist/cjs/helperComponents/Tooltip/styles.module.css +8 -0
  48. package/dist/cjs/helperComponents/index.d.ts +7 -0
  49. package/dist/cjs/helperComponents/index.js +17 -0
  50. package/dist/cjs/index.d.ts +1 -0
  51. package/dist/cjs/index.js +17 -0
  52. package/dist/cjs/types.d.ts +32 -0
  53. package/dist/cjs/types.js +2 -0
  54. package/dist/esm/components/SelectorPlatformDropList/SelectorPlatformDropList.d.ts +19 -0
  55. package/dist/esm/components/SelectorPlatformDropList/SelectorPlatformDropList.js +20 -0
  56. package/dist/esm/components/SelectorPlatformDropList/index.d.ts +2 -0
  57. package/dist/esm/components/SelectorPlatformDropList/index.js +1 -0
  58. package/dist/esm/components/SelectorPlatformDropList/platforms.d.ts +5 -0
  59. package/dist/esm/components/SelectorPlatformDropList/platforms.js +27 -0
  60. package/dist/esm/components/index.d.ts +1 -0
  61. package/dist/esm/components/index.js +1 -0
  62. package/dist/esm/helperComponents/BaseIcon/BaseIcon.d.ts +8 -0
  63. package/dist/esm/helperComponents/BaseIcon/BaseIcon.js +11 -0
  64. package/dist/esm/helperComponents/BaseIcon/index.d.ts +1 -0
  65. package/dist/esm/helperComponents/BaseIcon/index.js +1 -0
  66. package/dist/esm/helperComponents/ContentItemList/ContentItemList.d.ts +5 -0
  67. package/dist/esm/helperComponents/ContentItemList/ContentItemList.js +6 -0
  68. package/dist/esm/helperComponents/ContentItemList/index.d.ts +1 -0
  69. package/dist/esm/helperComponents/ContentItemList/index.js +1 -0
  70. package/dist/esm/helperComponents/ContentItemList/styles.module.css +5 -0
  71. package/dist/esm/helperComponents/IconItemList/IconItemList.d.ts +6 -0
  72. package/dist/esm/helperComponents/IconItemList/IconItemList.js +5 -0
  73. package/dist/esm/helperComponents/IconItemList/index.d.ts +1 -0
  74. package/dist/esm/helperComponents/IconItemList/index.js +1 -0
  75. package/dist/esm/helperComponents/IconItemList/styles.module.css +12 -0
  76. package/dist/esm/helperComponents/SelectedItemList/SelectedItemList.d.ts +8 -0
  77. package/dist/esm/helperComponents/SelectedItemList/SelectedItemList.js +13 -0
  78. package/dist/esm/helperComponents/SelectedItemList/index.d.ts +1 -0
  79. package/dist/esm/helperComponents/SelectedItemList/index.js +1 -0
  80. package/dist/esm/helperComponents/SelectedItemList/styles.module.css +32 -0
  81. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.d.ts +18 -0
  82. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.js +38 -0
  83. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/index.d.ts +2 -0
  84. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/index.js +1 -0
  85. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/styles.module.css +54 -0
  86. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/utils.d.ts +2 -0
  87. package/dist/esm/helperComponents/SelectorPlatformDropListPrivate/utils.js +12 -0
  88. package/dist/esm/helperComponents/TitleWithGoBack/TitleWithGoBack.d.ts +7 -0
  89. package/dist/esm/helperComponents/TitleWithGoBack/TitleWithGoBack.js +7 -0
  90. package/dist/esm/helperComponents/TitleWithGoBack/index.d.ts +1 -0
  91. package/dist/esm/helperComponents/TitleWithGoBack/index.js +1 -0
  92. package/dist/esm/helperComponents/TitleWithGoBack/styles.module.css +17 -0
  93. package/dist/esm/helperComponents/Tooltip/Tooltip.d.ts +9 -0
  94. package/dist/esm/helperComponents/Tooltip/Tooltip.js +20 -0
  95. package/dist/esm/helperComponents/Tooltip/index.d.ts +1 -0
  96. package/dist/esm/helperComponents/Tooltip/index.js +1 -0
  97. package/dist/esm/helperComponents/Tooltip/styles.module.css +8 -0
  98. package/dist/esm/helperComponents/index.d.ts +7 -0
  99. package/dist/esm/helperComponents/index.js +7 -0
  100. package/dist/esm/index.d.ts +1 -0
  101. package/dist/esm/index.js +1 -0
  102. package/dist/esm/types.d.ts +32 -0
  103. package/dist/esm/types.js +1 -0
  104. package/package.json +48 -0
  105. package/src/components/SelectorPlatformDropList/SelectorPlatformDropList.tsx +69 -0
  106. package/src/components/SelectorPlatformDropList/index.ts +2 -0
  107. package/src/components/SelectorPlatformDropList/platforms.ts +35 -0
  108. package/src/components/index.ts +1 -0
  109. package/src/helperComponents/BaseIcon/BaseIcon.tsx +20 -0
  110. package/src/helperComponents/BaseIcon/index.ts +1 -0
  111. package/src/helperComponents/ContentItemList/ContentItemList.tsx +15 -0
  112. package/src/helperComponents/ContentItemList/index.ts +1 -0
  113. package/src/helperComponents/ContentItemList/styles.module.scss +5 -0
  114. package/src/helperComponents/IconItemList/IconItemList.tsx +14 -0
  115. package/src/helperComponents/IconItemList/index.ts +1 -0
  116. package/src/helperComponents/IconItemList/styles.module.scss +14 -0
  117. package/src/helperComponents/SelectedItemList/SelectedItemList.tsx +33 -0
  118. package/src/helperComponents/SelectedItemList/index.ts +1 -0
  119. package/src/helperComponents/SelectedItemList/styles.module.scss +35 -0
  120. package/src/helperComponents/SelectorPlatformDropListPrivate/SelectorPlatformDropListPrivate.tsx +132 -0
  121. package/src/helperComponents/SelectorPlatformDropListPrivate/index.ts +2 -0
  122. package/src/helperComponents/SelectorPlatformDropListPrivate/styles.module.scss +59 -0
  123. package/src/helperComponents/SelectorPlatformDropListPrivate/utils.ts +15 -0
  124. package/src/helperComponents/TitleWithGoBack/TitleWithGoBack.tsx +21 -0
  125. package/src/helperComponents/TitleWithGoBack/index.ts +1 -0
  126. package/src/helperComponents/TitleWithGoBack/styles.module.scss +21 -0
  127. package/src/helperComponents/Tooltip/Tooltip.tsx +33 -0
  128. package/src/helperComponents/Tooltip/index.ts +1 -0
  129. package/src/helperComponents/Tooltip/styles.module.scss +10 -0
  130. package/src/helperComponents/index.ts +7 -0
  131. package/src/index.ts +1 -0
  132. package/src/types.ts +37 -0
@@ -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,2 @@
1
+ export { SelectorPlatformDropListPrivate } from './SelectorPlatformDropListPrivate';
2
+ export type { SelectorPlatformDropListPrivateProps } from './SelectorPlatformDropListPrivate';
@@ -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,2 @@
1
+ import { Item } from '../../types';
2
+ export declare function findItems(items: Array<Item>, value: Array<string> | string | undefined): Item[];
@@ -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,8 @@
1
+ .questionTooltip{
2
+ margin:auto 0;
3
+ }
4
+
5
+ .icon{
6
+ color:var(--sys-neutral-text-light, #8b8e9b);
7
+ margin:auto 0;
8
+ }
@@ -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,2 @@
1
+ export { SelectorPlatformDropList } from './SelectorPlatformDropList';
2
+ export type { SelectorPlatformDropListProps, PlatformType, Platform } from './SelectorPlatformDropList';
@@ -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,5 @@
1
+ .container {
2
+ display: flex;
3
+ align-items: center;
4
+ min-height: 24px;
5
+ }
@@ -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
+ }