@cloud-ru/uikit-product-calculator 0.33.3
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 +1508 -0
- package/LICENSE +201 -0
- package/README.md +85 -0
- package/package.json +75 -0
- package/src/components/Calculator/Calculator.tsx +79 -0
- package/src/components/Calculator/index.ts +1 -0
- package/src/components/CalculatorContent/CalculatorContent.tsx +38 -0
- package/src/components/CalculatorContent/index.ts +1 -0
- package/src/components/CalculatorContent/styles.module.scss +79 -0
- package/src/components/Catalog/Catalog.tsx +225 -0
- package/src/components/Catalog/components/PrivateCardHeader.tsx +63 -0
- package/src/components/Catalog/components/index.ts +1 -0
- package/src/components/Catalog/components/styles.module.scss +35 -0
- package/src/components/Catalog/index.ts +1 -0
- package/src/components/Catalog/styles.module.scss +104 -0
- package/src/components/Controls/AlertControl/AlertControl.tsx +44 -0
- package/src/components/Controls/AlertControl/index.ts +1 -0
- package/src/components/Controls/ArrayControl/ArrayControl.tsx +105 -0
- package/src/components/Controls/ArrayControl/index.ts +1 -0
- package/src/components/Controls/ArrayControl/styles.module.scss +33 -0
- package/src/components/Controls/CarouselControl/CarouselControl.tsx +173 -0
- package/src/components/Controls/CarouselControl/index.ts +1 -0
- package/src/components/Controls/CarouselControl/styles.module.scss +32 -0
- package/src/components/Controls/Control/Control.tsx +205 -0
- package/src/components/Controls/Control/index.ts +1 -0
- package/src/components/Controls/ObjectControl/ObjectControl.tsx +150 -0
- package/src/components/Controls/ObjectControl/index.ts +1 -0
- package/src/components/Controls/ObjectControl/styles.module.scss +18 -0
- package/src/components/Controls/ObjectDecorator/ObjectDecorator.tsx +23 -0
- package/src/components/Controls/ObjectDecorator/index.ts +1 -0
- package/src/components/Controls/ObjectDecorator/styles.module.scss +15 -0
- package/src/components/Controls/SegmentedControl/SegmentedControl.tsx +79 -0
- package/src/components/Controls/SegmentedControl/SegmentedControlCard.tsx +38 -0
- package/src/components/Controls/SegmentedControl/index.ts +1 -0
- package/src/components/Controls/SegmentedControl/styles.module.scss +8 -0
- package/src/components/Controls/SelectControl/SelectControl.tsx +172 -0
- package/src/components/Controls/SelectControl/index.ts +1 -0
- package/src/components/Controls/SelectControl/styles.module.scss +5 -0
- package/src/components/Controls/SliderControl/SliderControl.tsx +92 -0
- package/src/components/Controls/SliderControl/index.ts +1 -0
- package/src/components/Controls/StepperControl/StepperControl.tsx +160 -0
- package/src/components/Controls/StepperControl/index.ts +1 -0
- package/src/components/Controls/StepperControl/styles.module.scss +16 -0
- package/src/components/Controls/TableControl/TableControl.tsx +162 -0
- package/src/components/Controls/TableControl/helperComponents/StepperWithAllowedValues.tsx +50 -0
- package/src/components/Controls/TableControl/helperComponents/index.ts +1 -0
- package/src/components/Controls/TableControl/helperComponents/styles.module.scss +53 -0
- package/src/components/Controls/TableControl/index.ts +1 -0
- package/src/components/Controls/TableControl/styles.module.scss +104 -0
- package/src/components/Controls/ToggleCard/ToggleCard.tsx +46 -0
- package/src/components/Controls/ToggleCard/index.ts +1 -0
- package/src/components/Controls/ToggleCard/styles.module.scss +11 -0
- package/src/components/Controls/ToggleCardsControl/ToggleCardsControl.tsx +93 -0
- package/src/components/Controls/ToggleCardsControl/index.ts +1 -0
- package/src/components/Controls/ToggleCardsControl/styles.module.scss +40 -0
- package/src/components/Controls/ToggleControl/ToggleControl.tsx +59 -0
- package/src/components/Controls/ToggleControl/components/SwitchRow.tsx +98 -0
- package/src/components/Controls/ToggleControl/components/index.ts +1 -0
- package/src/components/Controls/ToggleControl/components/styles.module.scss +110 -0
- package/src/components/Controls/ToggleControl/index.ts +1 -0
- package/src/components/Controls/ToggleObjectControl/ToggleObjectControl.tsx +111 -0
- package/src/components/Controls/ToggleObjectControl/index.ts +1 -0
- package/src/components/Controls/ToggleObjectControl/styles.module.scss +13 -0
- package/src/components/Controls/constants.ts +16 -0
- package/src/components/Controls/index.tsx +26 -0
- package/src/components/Controls/types.ts +181 -0
- package/src/components/Controls/utils.ts +49 -0
- package/src/components/Disclaimer/Disclaimer.tsx +33 -0
- package/src/components/Disclaimer/index.ts +1 -0
- package/src/components/Disclaimer/styles.module.scss +14 -0
- package/src/components/HeaderContainer/index.tsx +32 -0
- package/src/components/HeaderContainer/styles.module.scss +24 -0
- package/src/components/PriceSummary/PriceSummary.tsx +158 -0
- package/src/components/PriceSummary/components/PricePeriodSelect/PricePeriodSelect.tsx +81 -0
- package/src/components/PriceSummary/components/PricePeriodSelect/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductCard/ProductCard.tsx +85 -0
- package/src/components/PriceSummary/components/ProductCard/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductCard/styles.module.scss +7 -0
- package/src/components/PriceSummary/components/ProductListActions/ProductListActions.tsx +118 -0
- package/src/components/PriceSummary/components/ProductListActions/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductListActions/styles.module.scss +38 -0
- package/src/components/PriceSummary/components/index.ts +3 -0
- package/src/components/PriceSummary/hooks.ts +36 -0
- package/src/components/PriceSummary/index.ts +1 -0
- package/src/components/PriceSummary/styles.module.scss +110 -0
- package/src/components/PriceSummary/utils/getTotalPrice.ts +19 -0
- package/src/components/PriceSummary/utils/index.ts +2 -0
- package/src/components/PriceSummary/utils/transformToProductCardData.ts +36 -0
- package/src/components/ProductHeadline/ProductPageHeadline.tsx +134 -0
- package/src/components/ProductHeadline/components/PriceCount.tsx +93 -0
- package/src/components/ProductHeadline/components/index.ts +1 -0
- package/src/components/ProductHeadline/components/styles.module.scss +52 -0
- package/src/components/ProductHeadline/index.ts +1 -0
- package/src/components/ProductHeadline/styles.module.scss +32 -0
- package/src/components/ProductPage/ProductPage.tsx +105 -0
- package/src/components/ProductPage/index.ts +1 -0
- package/src/components/ProductPage/styles.module.scss +13 -0
- package/src/components/Welcome/Welcome.tsx +138 -0
- package/src/components/Welcome/index.ts +1 -0
- package/src/components/Welcome/styles.module.scss +155 -0
- package/src/components/index.ts +3 -0
- package/src/config/config.tsx +27 -0
- package/src/config/index.ts +2 -0
- package/src/config/platforms/advanced/catalog.ts +82 -0
- package/src/config/platforms/advanced/constants.ts +23 -0
- package/src/config/platforms/advanced/index.ts +5 -0
- package/src/config/platforms/advanced/platform.tsx +13 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudBackup.ts +76 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudContainerEngine.tsx +260 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudServer.tsx +526 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataAsYouUse.ts +159 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataLakeInsight.ts +134 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataWarehouseService.ts +94 -0
- package/src/config/platforms/advanced/product-config/AdvancedDcsMemcached.ts +69 -0
- package/src/config/platforms/advanced/product-config/AdvancedDcsRedis.ts +220 -0
- package/src/config/platforms/advanced/product-config/AdvancedDmsKafka.tsx +186 -0
- package/src/config/platforms/advanced/product-config/AdvancedDmsRabbitMq.ts +202 -0
- package/src/config/platforms/advanced/product-config/AdvancedDocumentDatabase.tsx +323 -0
- package/src/config/platforms/advanced/product-config/AdvancedElasticLoadBalance.tsx +252 -0
- package/src/config/platforms/advanced/product-config/AdvancedElasticSearch.ts +365 -0
- package/src/config/platforms/advanced/product-config/AdvancedFunctionGraph.tsx +65 -0
- package/src/config/platforms/advanced/product-config/AdvancedMapReduce.tsx +394 -0
- package/src/config/platforms/advanced/product-config/AdvancedMySqlDataBase.ts +417 -0
- package/src/config/platforms/advanced/product-config/AdvancedNetwork.ts +146 -0
- package/src/config/platforms/advanced/product-config/AdvancedObjectStorage.ts +232 -0
- package/src/config/platforms/advanced/product-config/AdvancedPostgreSqlDatabase.ts +402 -0
- package/src/config/platforms/advanced/product-config/AdvancedScalableFile.tsx +161 -0
- package/src/config/platforms/advanced/product-config/AdvancedSqlDatabase.ts +380 -0
- package/src/config/platforms/advanced/product-config/index.ts +21 -0
- package/src/config/platforms/advanced/products.ts +267 -0
- package/src/config/platforms/evolution/catalog.tsx +107 -0
- package/src/config/platforms/evolution/constants.ts +80 -0
- package/src/config/platforms/evolution/index.ts +5 -0
- package/src/config/platforms/evolution/platform.tsx +13 -0
- package/src/config/platforms/evolution/product-config/EvolutionArenadataDb.ts +151 -0
- package/src/config/platforms/evolution/product-config/EvolutionArtifactRegistry.ts +57 -0
- package/src/config/platforms/evolution/product-config/EvolutionBareMetal.tsx +172 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServer.tsx +407 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServerFreeTier.tsx +185 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServerGpu.tsx +301 -0
- package/src/config/platforms/evolution/product-config/EvolutionContainerApps.ts +84 -0
- package/src/config/platforms/evolution/product-config/EvolutionContainerAppsFreeTier.ts +29 -0
- package/src/config/platforms/evolution/product-config/EvolutionKubernetes.ts +388 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedMetastore.ts +38 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedRedis.ts +161 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedSpark.ts +360 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedTrino.ts +53 -0
- package/src/config/platforms/evolution/product-config/EvolutionMlInference.tsx +703 -0
- package/src/config/platforms/evolution/product-config/EvolutionPostgreSql.ts +217 -0
- package/src/config/platforms/evolution/product-config/EvolutionPublicIp.ts +39 -0
- package/src/config/platforms/evolution/product-config/EvolutionSnatGateway.ts +22 -0
- package/src/config/platforms/evolution/product-config/EvolutionStorageS3.ts +223 -0
- package/src/config/platforms/evolution/product-config/EvolutionStorageS3FreeTier.ts +97 -0
- package/src/config/platforms/evolution/product-config/index.ts +17 -0
- package/src/config/platforms/evolution/products.ts +260 -0
- package/src/config/platforms/index.ts +3 -0
- package/src/config/platforms/vmware/catalog.ts +19 -0
- package/src/config/platforms/vmware/constants.ts +6 -0
- package/src/config/platforms/vmware/index.ts +5 -0
- package/src/config/platforms/vmware/platform.tsx +13 -0
- package/src/config/platforms/vmware/product-config/VmWareCloudBackup.ts +56 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualDataCenter.ts +309 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualMachinesBackup.ts +58 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualWorkspaces.tsx +210 -0
- package/src/config/platforms/vmware/product-config/index.ts +4 -0
- package/src/config/platforms/vmware/products.ts +63 -0
- package/src/config/styles.module.scss +9 -0
- package/src/config/utils/disk.ts +94 -0
- package/src/config/utils/diskPostgreSqlMySQL.ts +94 -0
- package/src/config/utils/eip.ts +104 -0
- package/src/config/utils/index.ts +52 -0
- package/src/config/utils/obs.ts +100 -0
- package/src/constants.ts +56 -0
- package/src/contexts/CalculatorContext.tsx +193 -0
- package/src/contexts/ProductContext.ts +25 -0
- package/src/contexts/index.ts +2 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useAdaptive.ts +20 -0
- package/src/hooks/useCatalogCardClick.ts +37 -0
- package/src/hooks/useProductClick.ts +14 -0
- package/src/hooks/useProductDelete.ts +46 -0
- package/src/index.ts +6 -0
- package/src/services/constants.ts +5 -0
- package/src/services/getFetcherFn.ts +57 -0
- package/src/services/getInitPrice.ts +64 -0
- package/src/services/getOnDownloadFileClick.ts +37 -0
- package/src/services/getOnShareClick.ts +56 -0
- package/src/services/index.ts +4 -0
- package/src/types/CalculatorType.ts +16 -0
- package/src/types/CatalogConfig.ts +13 -0
- package/src/types/Category.ts +14 -0
- package/src/types/FetcherFn.ts +26 -0
- package/src/types/FormValues.ts +4 -0
- package/src/types/Platform.ts +24 -0
- package/src/types/Price.ts +18 -0
- package/src/types/Product.ts +39 -0
- package/src/types/ProductState.ts +11 -0
- package/src/types/State.ts +7 -0
- package/src/types/index.ts +10 -0
- package/src/utils/filterNonEmptyArrays.ts +13 -0
- package/src/utils/formatNumber.ts +5 -0
- package/src/utils/getPrice.ts +38 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/parseKeyToDataTest.ts +14 -0
- package/src/utils/value.ts +11 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { FilterSVG } from '@cloud-ru/uikit-product-icons';
|
|
5
|
+
import { MobileDroplist } from '@cloud-ru/uikit-product-mobile-dropdown';
|
|
6
|
+
import { AdaptiveFieldSelect } from '@cloud-ru/uikit-product-mobile-fields';
|
|
7
|
+
import { MobileModalCustom } from '@cloud-ru/uikit-product-mobile-modal';
|
|
8
|
+
import { LAYOUT_TYPE, LayoutType } from '@cloud-ru/uikit-product-utils';
|
|
9
|
+
import { ButtonFilled } from '@snack-uikit/button';
|
|
10
|
+
import { Card } from '@snack-uikit/card';
|
|
11
|
+
import { Divider } from '@snack-uikit/divider';
|
|
12
|
+
import { List } from '@snack-uikit/list';
|
|
13
|
+
import { ModalCustom } from '@snack-uikit/modal';
|
|
14
|
+
import { Tag } from '@snack-uikit/tag';
|
|
15
|
+
import { Tooltip } from '@snack-uikit/tooltip';
|
|
16
|
+
|
|
17
|
+
import { useCalculatorContext } from '../../contexts';
|
|
18
|
+
import { useCatalogCardClick } from '../../hooks';
|
|
19
|
+
import { CatalogConfig, PlatformType } from '../../types';
|
|
20
|
+
import { parseKeyToDataTest } from '../../utils';
|
|
21
|
+
import { PrivateCardHeader } from './components';
|
|
22
|
+
import styles from './styles.module.scss';
|
|
23
|
+
|
|
24
|
+
const bannerText = {
|
|
25
|
+
public: 'Доступна всем',
|
|
26
|
+
request: 'Для всех, по заявке',
|
|
27
|
+
legal: 'Только для юрлиц',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type CatalogProps = {
|
|
31
|
+
layoutType?: LayoutType;
|
|
32
|
+
config: CatalogConfig;
|
|
33
|
+
open: boolean;
|
|
34
|
+
setOpen(open: boolean): void;
|
|
35
|
+
onCardClick?(productId: string): void;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function Catalog() {
|
|
39
|
+
const {
|
|
40
|
+
selectedPlatform,
|
|
41
|
+
setSelectedPlatform,
|
|
42
|
+
setSelectedCategory,
|
|
43
|
+
selectedCategory,
|
|
44
|
+
|
|
45
|
+
products,
|
|
46
|
+
layoutType = LAYOUT_TYPE.Desktop,
|
|
47
|
+
config,
|
|
48
|
+
catalogOpen,
|
|
49
|
+
setCatalogOpen,
|
|
50
|
+
|
|
51
|
+
actions: { onPlatformSelect },
|
|
52
|
+
} = useCalculatorContext();
|
|
53
|
+
|
|
54
|
+
const handleCatalogCardClick = useCatalogCardClick();
|
|
55
|
+
|
|
56
|
+
const handlePlatformChange = (platformId: PlatformType) => {
|
|
57
|
+
onPlatformSelect?.(platformId);
|
|
58
|
+
setSelectedPlatform(platformId);
|
|
59
|
+
setSelectedCategory(config.catalog[platformId][0].id);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const categoryOptions = config.catalog[selectedPlatform].map(({ id, dataTestId, label }) => ({
|
|
63
|
+
id,
|
|
64
|
+
content: {
|
|
65
|
+
option: label,
|
|
66
|
+
},
|
|
67
|
+
'data-test-id': dataTestId,
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
const [openMobileCategory, setOpenMobileCategory] = useState<boolean>(false);
|
|
71
|
+
|
|
72
|
+
const isMobile = layoutType !== LAYOUT_TYPE.Desktop && layoutType !== LAYOUT_TYPE.DesktopSmall;
|
|
73
|
+
const AdaptiveModal = isMobile ? MobileModalCustom : ModalCustom;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<AdaptiveModal
|
|
77
|
+
open={catalogOpen}
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
size='l'
|
|
81
|
+
onClose={() => {
|
|
82
|
+
setCatalogOpen?.(false);
|
|
83
|
+
}}
|
|
84
|
+
className={cn({ [styles.modal]: !isMobile })}
|
|
85
|
+
data-test-id={parseKeyToDataTest('catalog')}
|
|
86
|
+
>
|
|
87
|
+
<AdaptiveModal.Header title='Каталог продуктов' />
|
|
88
|
+
<AdaptiveModal.Body
|
|
89
|
+
content={
|
|
90
|
+
<div className={styles.wrapper} data-mobile={isMobile || undefined}>
|
|
91
|
+
<div className={styles.sidebar}>
|
|
92
|
+
<AdaptiveFieldSelect
|
|
93
|
+
layoutType={layoutType}
|
|
94
|
+
value={selectedPlatform}
|
|
95
|
+
onChange={handlePlatformChange}
|
|
96
|
+
size='m'
|
|
97
|
+
label='Облачная платформа'
|
|
98
|
+
widthStrategy='eq'
|
|
99
|
+
searchable={false}
|
|
100
|
+
showClearButton={false}
|
|
101
|
+
options={config.platforms.map(({ icon, description, id, label, dataTestId, access }) => ({
|
|
102
|
+
value: id,
|
|
103
|
+
beforeContent: icon,
|
|
104
|
+
truncate: {
|
|
105
|
+
option: 2,
|
|
106
|
+
description: 3,
|
|
107
|
+
variant: 'end',
|
|
108
|
+
},
|
|
109
|
+
'data-test-id': dataTestId,
|
|
110
|
+
option: label,
|
|
111
|
+
description: (
|
|
112
|
+
<div className={styles.description}>
|
|
113
|
+
<span>{description} </span>
|
|
114
|
+
<div>
|
|
115
|
+
<Tag label={bannerText[access]} appearance='green' />
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
) as unknown as string,
|
|
119
|
+
}))}
|
|
120
|
+
/>
|
|
121
|
+
{!isMobile && (
|
|
122
|
+
<div className={styles.categoriesWrapper}>
|
|
123
|
+
<Divider orientation='vertical' />
|
|
124
|
+
<List
|
|
125
|
+
size='m'
|
|
126
|
+
items={categoryOptions}
|
|
127
|
+
selection={{
|
|
128
|
+
value: selectedCategory,
|
|
129
|
+
onChange: value => value && setSelectedCategory(value),
|
|
130
|
+
mode: 'single',
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div className={styles.content}>
|
|
138
|
+
<div className={styles.contentHeadline} data-test-id={parseKeyToDataTest('catalog', 'category-title')}>
|
|
139
|
+
{config.catalog[selectedPlatform].find(item => item.id === selectedCategory)?.label}
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<div className={styles.contentCards}>
|
|
143
|
+
{config.catalog[selectedPlatform].find(item => item.id === selectedCategory)?.banner || null}
|
|
144
|
+
|
|
145
|
+
{config.catalog[selectedPlatform]
|
|
146
|
+
.find(item => item.id === selectedCategory)
|
|
147
|
+
?.visibleProducts.map(productId => config.products[productId])
|
|
148
|
+
.filter(Boolean)
|
|
149
|
+
.map(product => {
|
|
150
|
+
const disabled = product.freeTier && Object.keys(products).includes(product.id);
|
|
151
|
+
return (
|
|
152
|
+
<Card
|
|
153
|
+
key={product.id}
|
|
154
|
+
className={styles.card}
|
|
155
|
+
size={isMobile ? 's' : 'm'}
|
|
156
|
+
outline
|
|
157
|
+
disabled={disabled}
|
|
158
|
+
onClick={disabled ? undefined : () => handleCatalogCardClick?.(product.id)}
|
|
159
|
+
promoBadge={disabled ? { text: 'Добавлен', appearance: 'green' } : undefined}
|
|
160
|
+
header={
|
|
161
|
+
<Tooltip
|
|
162
|
+
open={disabled ? undefined : false}
|
|
163
|
+
tip={
|
|
164
|
+
'Free tier продукты можно добавить только один раз. Чтобы посмотреть конфигурацию продукта, кликните на его карточку в расчете'
|
|
165
|
+
}
|
|
166
|
+
>
|
|
167
|
+
<PrivateCardHeader
|
|
168
|
+
icon={product?.icon}
|
|
169
|
+
title={product?.label}
|
|
170
|
+
metadata={product?.caption}
|
|
171
|
+
description={
|
|
172
|
+
product?.freeTier ? (
|
|
173
|
+
<div className={styles.tag} data-test-id={parseKeyToDataTest('catalog', 'card-tag')}>
|
|
174
|
+
<Tag label='Бесплатная конфигурация' appearance='green' />
|
|
175
|
+
</div>
|
|
176
|
+
) : null
|
|
177
|
+
}
|
|
178
|
+
/>
|
|
179
|
+
</Tooltip>
|
|
180
|
+
}
|
|
181
|
+
data-test-id={parseKeyToDataTest('catalog', 'card')}
|
|
182
|
+
/>
|
|
183
|
+
);
|
|
184
|
+
})}
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
}
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
{isMobile && (
|
|
192
|
+
<AdaptiveModal.Footer
|
|
193
|
+
actions={
|
|
194
|
+
<MobileDroplist
|
|
195
|
+
open={openMobileCategory}
|
|
196
|
+
onOpenChange={setOpenMobileCategory}
|
|
197
|
+
items={categoryOptions}
|
|
198
|
+
selection={{
|
|
199
|
+
value: selectedCategory,
|
|
200
|
+
onChange: value => {
|
|
201
|
+
setSelectedCategory(value);
|
|
202
|
+
setOpenMobileCategory(false);
|
|
203
|
+
},
|
|
204
|
+
mode: 'single',
|
|
205
|
+
}}
|
|
206
|
+
label='Категории'
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
size='l'
|
|
210
|
+
>
|
|
211
|
+
<div className={styles.categoriesWrapper}>
|
|
212
|
+
<ButtonFilled
|
|
213
|
+
size='m'
|
|
214
|
+
appearance='neutral'
|
|
215
|
+
icon={<FilterSVG />}
|
|
216
|
+
label={`Категории: ${config.catalog[selectedPlatform].find(item => item.id === selectedCategory)?.label}`}
|
|
217
|
+
/>
|
|
218
|
+
</div>
|
|
219
|
+
</MobileDroplist>
|
|
220
|
+
}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
</AdaptiveModal>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { IconPredefined, IconPredefinedProps } from '@snack-uikit/icon-predefined';
|
|
5
|
+
import { Typography } from '@snack-uikit/typography';
|
|
6
|
+
import { excludeSupportProps, WithSupportProps } from '@snack-uikit/utils';
|
|
7
|
+
|
|
8
|
+
import { parseKeyToDataTest } from '../../../utils';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
export type ProductCardHeaderProps = WithSupportProps<{
|
|
12
|
+
/** Заголовок */
|
|
13
|
+
title: string;
|
|
14
|
+
/** Подзаголовок */
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
/** Метаинформация */
|
|
17
|
+
metadata?: string;
|
|
18
|
+
icon?: IconPredefinedProps['icon'];
|
|
19
|
+
/** CSS-класс для элемента с контентом */
|
|
20
|
+
className?: string;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
23
|
+
export function PrivateCardHeader({
|
|
24
|
+
title,
|
|
25
|
+
description,
|
|
26
|
+
metadata,
|
|
27
|
+
icon,
|
|
28
|
+
className,
|
|
29
|
+
|
|
30
|
+
...rest
|
|
31
|
+
}: ProductCardHeaderProps) {
|
|
32
|
+
return (
|
|
33
|
+
<div className={cn(styles.titleLayout, className)} {...excludeSupportProps(rest)}>
|
|
34
|
+
{icon && <IconPredefined icon={icon} size='s' decor={false} appearance='neutral' shape='square' />}
|
|
35
|
+
|
|
36
|
+
<div className={styles.contentLayout}>
|
|
37
|
+
<Typography
|
|
38
|
+
family='sans'
|
|
39
|
+
size='s'
|
|
40
|
+
purpose='title'
|
|
41
|
+
className={styles.title}
|
|
42
|
+
data-test-id={parseKeyToDataTest('catalog-card', 'title')}
|
|
43
|
+
>
|
|
44
|
+
{title}
|
|
45
|
+
</Typography>
|
|
46
|
+
|
|
47
|
+
{metadata && <Typography.SansBodyS className={styles.metadata}>{metadata}</Typography.SansBodyS>}
|
|
48
|
+
|
|
49
|
+
{description && (
|
|
50
|
+
<Typography
|
|
51
|
+
family='sans'
|
|
52
|
+
size='m'
|
|
53
|
+
purpose='body'
|
|
54
|
+
className={styles.description}
|
|
55
|
+
data-test-id={parseKeyToDataTest('catalog-card', 'desc')}
|
|
56
|
+
>
|
|
57
|
+
{description}
|
|
58
|
+
</Typography>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PrivateCardHeader';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as stv;
|
|
2
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-card' as st-card;
|
|
3
|
+
|
|
4
|
+
$sizes: 's', 'm', 'l';
|
|
5
|
+
|
|
6
|
+
.titleLayout {
|
|
7
|
+
@include stv.composite-var(st-card.$card, 'content', 's', 'header');
|
|
8
|
+
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.contentLayout {
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
display: block;
|
|
18
|
+
max-width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.title {
|
|
22
|
+
display: block;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
color: stv.$sys-neutral-text-main;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.metadata {
|
|
28
|
+
max-width: 100%;
|
|
29
|
+
color: stv.$sys-neutral-text-light;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.description {
|
|
33
|
+
max-width: 100%;
|
|
34
|
+
color: stv.$sys-neutral-text-support;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Catalog';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as stv;
|
|
2
|
+
|
|
3
|
+
.calculator {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.content {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: stv.$dimension-2m;
|
|
11
|
+
min-height: 400px;
|
|
12
|
+
padding-bottom: stv.$dimension-3m;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.contentHeadline {
|
|
16
|
+
@include stv.composite-var(stv.$sans-title-l);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.contentCards {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
gap: stv.$dimension-2m;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.categoriesWrapper {
|
|
26
|
+
display: grid;
|
|
27
|
+
grid-template-columns: auto 1fr;
|
|
28
|
+
margin-top: stv.$dimension-2m;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.selectCard {
|
|
32
|
+
display: flex;
|
|
33
|
+
padding: stv.$dimension-3m;
|
|
34
|
+
border: solid 1px stv.$sys-neutral-decor-default;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.card {
|
|
38
|
+
width: 280px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.modal {
|
|
42
|
+
/* stylelint-disable-next-line declaration-no-important */
|
|
43
|
+
width: 1298px !important;
|
|
44
|
+
|
|
45
|
+
max-width: calc(100dvw - 2 * stv.$dimension-3m);
|
|
46
|
+
|
|
47
|
+
color: stv.$sys-neutral-text-main;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sidebar {
|
|
51
|
+
padding-bottom: stv.$dimension-3m;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.wrapper {
|
|
55
|
+
position: relative;
|
|
56
|
+
min-height: 100%;
|
|
57
|
+
|
|
58
|
+
/* stylelint-disable-next-line declaration-property-value-allowed-list */
|
|
59
|
+
z-index: 0;
|
|
60
|
+
display: grid;
|
|
61
|
+
grid-template-columns: 256px 1fr;
|
|
62
|
+
|
|
63
|
+
gap: stv.$dimension-4m;
|
|
64
|
+
|
|
65
|
+
&[data-mobile] {
|
|
66
|
+
grid-template-columns: 1fr;
|
|
67
|
+
gap: stv.$dimension-1m;
|
|
68
|
+
min-height: inherit;
|
|
69
|
+
|
|
70
|
+
.card {
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: inherit;
|
|
73
|
+
}
|
|
74
|
+
.content {
|
|
75
|
+
min-height: inherit;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sidebar {
|
|
79
|
+
position: sticky;
|
|
80
|
+
top: 0;
|
|
81
|
+
left: 0;
|
|
82
|
+
background-color: stv.$sys-neutral-background1-level;
|
|
83
|
+
padding: stv.$dimension-3m 0 stv.$dimension-1m;
|
|
84
|
+
transform: translateY(calc(0px - stv.$dimension-3m));
|
|
85
|
+
|
|
86
|
+
/* stylelint-disable-next-line declaration-property-value-allowed-list */
|
|
87
|
+
z-index: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.contentCards {
|
|
91
|
+
margin: 0 stv.$dimension-050m;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.description {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
gap: stv.$dimension-050m;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.tag {
|
|
103
|
+
margin-top: stv.$dimension-050m;
|
|
104
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Alert, AlertProps } from '@snack-uikit/alert';
|
|
4
|
+
|
|
5
|
+
import { FormValues } from '../../../types';
|
|
6
|
+
import { parseKeyToDataTest } from '../../../utils';
|
|
7
|
+
import { CONTROL } from '../constants';
|
|
8
|
+
import { BaseControl, WithVisible } from '../types';
|
|
9
|
+
|
|
10
|
+
export type AlertControl = Pick<
|
|
11
|
+
BaseControl<AlertProps>,
|
|
12
|
+
'uiProps' | 'accessorKey' | 'watchedControls' | 'onChangePeriod' | 'canChangeWholePricePeriod'
|
|
13
|
+
> & {
|
|
14
|
+
type: typeof CONTROL.Alert;
|
|
15
|
+
relateFn?(watchedValues: FormValues):
|
|
16
|
+
| {
|
|
17
|
+
uiProps?: Partial<WithVisible<AlertProps>>;
|
|
18
|
+
}
|
|
19
|
+
| undefined;
|
|
20
|
+
onChangeFn?: never;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type AlertControlUiProps = AlertControl & { watchedValues?: FormValues };
|
|
24
|
+
|
|
25
|
+
export function AlertControlUi({ uiProps, relateFn, watchedValues, accessorKey }: AlertControlUiProps) {
|
|
26
|
+
const { uiProps: relatedUiProps } = useMemo(() => relateFn?.(watchedValues ?? {}) ?? {}, [relateFn, watchedValues]);
|
|
27
|
+
const dataTestAttribute = parseKeyToDataTest('alert', accessorKey);
|
|
28
|
+
const visible = relatedUiProps?.visible ?? uiProps?.visible ?? true;
|
|
29
|
+
|
|
30
|
+
if (!visible) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Alert
|
|
36
|
+
description={''}
|
|
37
|
+
appearance='info'
|
|
38
|
+
outline
|
|
39
|
+
{...uiProps}
|
|
40
|
+
{...relatedUiProps}
|
|
41
|
+
data-test-id={dataTestAttribute}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AlertControl';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PlusSVG, TrashSVG } from '@cloud-ru/uikit-product-icons';
|
|
2
|
+
import { ButtonFunction } from '@snack-uikit/button';
|
|
3
|
+
|
|
4
|
+
import { ProductContext, useProductContext } from '../../../contexts';
|
|
5
|
+
import { useAdaptive } from '../../../hooks';
|
|
6
|
+
import { AnyType } from '../../../types';
|
|
7
|
+
import { getValue, parseKeyToDataTest, setValue } from '../../../utils';
|
|
8
|
+
import { CONTROL } from '../constants';
|
|
9
|
+
import { ObjectControl, ObjectControlUi } from '../ObjectControl';
|
|
10
|
+
import { getDefaultValues } from '../utils';
|
|
11
|
+
import styles from './styles.module.scss';
|
|
12
|
+
|
|
13
|
+
export type ArrayControl = {
|
|
14
|
+
type: typeof CONTROL.Array;
|
|
15
|
+
/** Минимальное кол-во элементов массива */
|
|
16
|
+
min?: number;
|
|
17
|
+
/** Максимальное кол-во элементов массива */
|
|
18
|
+
max: number;
|
|
19
|
+
/**
|
|
20
|
+
* Поле (полный путь), куда будет сохраняться значение
|
|
21
|
+
*
|
|
22
|
+
* @example 'esc.cpu'
|
|
23
|
+
*/
|
|
24
|
+
accessorKey: string;
|
|
25
|
+
/** Текст кнопки добавления нового элемента */
|
|
26
|
+
addText: string;
|
|
27
|
+
/** Дефолтное значение */
|
|
28
|
+
defaultValue: AnyType[];
|
|
29
|
+
|
|
30
|
+
invertTrashOffset?: boolean;
|
|
31
|
+
|
|
32
|
+
onChangeFn?: never;
|
|
33
|
+
relateFn?: never;
|
|
34
|
+
} & Omit<ObjectControl, 'type'>;
|
|
35
|
+
|
|
36
|
+
type ArrayControlUiProps = ArrayControl;
|
|
37
|
+
|
|
38
|
+
export function ArrayControlUi({
|
|
39
|
+
accessorKey,
|
|
40
|
+
ui,
|
|
41
|
+
controls,
|
|
42
|
+
max,
|
|
43
|
+
addText,
|
|
44
|
+
min = 0,
|
|
45
|
+
invertTrashOffset,
|
|
46
|
+
}: ArrayControlUiProps) {
|
|
47
|
+
const { value: valueProp, onChange: onChangeProp } = useProductContext();
|
|
48
|
+
const { isMobile } = useAdaptive();
|
|
49
|
+
|
|
50
|
+
const value: AnyType[] = getValue(valueProp, accessorKey);
|
|
51
|
+
|
|
52
|
+
const onChange = (newValue: AnyType) => {
|
|
53
|
+
setValue(valueProp, accessorKey, newValue);
|
|
54
|
+
|
|
55
|
+
onChangeProp(valueProp);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className={styles.container}>
|
|
60
|
+
{value?.map((_, idx) => (
|
|
61
|
+
<ProductContext.Provider
|
|
62
|
+
key={idx}
|
|
63
|
+
value={{
|
|
64
|
+
value: { ...getValue(value, `[${idx}]`) },
|
|
65
|
+
onChange: newValue => {
|
|
66
|
+
setValue(value, `[${idx}]`, newValue);
|
|
67
|
+
onChange(value);
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<div key={idx} className={styles.row}>
|
|
72
|
+
<div className={styles.wrap} data-mobile={isMobile || undefined}>
|
|
73
|
+
<ObjectControlUi ui={ui} controls={controls} type={CONTROL.Object} />
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
{(value ?? []).length > min && (
|
|
77
|
+
<ButtonFunction
|
|
78
|
+
icon={<TrashSVG />}
|
|
79
|
+
className={invertTrashOffset ? styles.trashInvert : styles.trash}
|
|
80
|
+
size='m'
|
|
81
|
+
onClick={() => {
|
|
82
|
+
value?.splice(idx, 1);
|
|
83
|
+
onChange(value);
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
</ProductContext.Provider>
|
|
89
|
+
))}
|
|
90
|
+
|
|
91
|
+
{(value ?? []).length < max && (
|
|
92
|
+
<ButtonFunction
|
|
93
|
+
icon={<PlusSVG />}
|
|
94
|
+
size='m'
|
|
95
|
+
iconPosition='before'
|
|
96
|
+
label={addText}
|
|
97
|
+
onClick={() => {
|
|
98
|
+
onChange((value ?? []).concat([getDefaultValues(controls)]));
|
|
99
|
+
}}
|
|
100
|
+
data-test-id={parseKeyToDataTest('button')}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ArrayControl';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as stv;
|
|
2
|
+
|
|
3
|
+
.row {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: 1fr auto;
|
|
6
|
+
|
|
7
|
+
gap: stv.$dimension-1m;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
|
|
10
|
+
.trash {
|
|
11
|
+
margin-top: stv.$dimension-3m;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.trashInvert {
|
|
15
|
+
margin-top: calc(0px - stv.$dimension-1m);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.container {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: stv.$dimension-3m;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.wrap {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: stv.$dimension-3m;
|
|
29
|
+
|
|
30
|
+
&[data-mobile] {
|
|
31
|
+
gap: stv.$dimension-2m;
|
|
32
|
+
}
|
|
33
|
+
}
|