@cloud-ru/uikit-product-widget 0.9.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 (146) hide show
  1. package/CHANGELOG.md +998 -0
  2. package/LICENSE +201 -0
  3. package/README.md +8 -0
  4. package/dist/cjs/components/ProductsWidget/ProductsWidget.d.ts +10 -0
  5. package/dist/cjs/components/ProductsWidget/ProductsWidget.js +36 -0
  6. package/dist/cjs/components/ProductsWidget/constants.d.ts +4 -0
  7. package/dist/cjs/components/ProductsWidget/constants.js +7 -0
  8. package/dist/cjs/components/ProductsWidget/index.d.ts +1 -0
  9. package/dist/cjs/components/ProductsWidget/index.js +17 -0
  10. package/dist/cjs/components/ProductsWidget/styles.module.css +45 -0
  11. package/dist/cjs/components/ProductsWidget/utils/getLoadingCards.d.ts +6 -0
  12. package/dist/cjs/components/ProductsWidget/utils/getLoadingCards.js +17 -0
  13. package/dist/cjs/components/ProductsWidget/utils/getProductColumns.d.ts +8 -0
  14. package/dist/cjs/components/ProductsWidget/utils/getProductColumns.js +19 -0
  15. package/dist/cjs/components/SolutionsWidget/SolutionsWidget.d.ts +8 -0
  16. package/dist/cjs/components/SolutionsWidget/SolutionsWidget.js +30 -0
  17. package/dist/cjs/components/SolutionsWidget/index.d.ts +1 -0
  18. package/dist/cjs/components/SolutionsWidget/index.js +17 -0
  19. package/dist/cjs/components/SolutionsWidget/styles.module.css +28 -0
  20. package/dist/cjs/components/Widget/Widget.d.ts +2 -0
  21. package/dist/cjs/components/Widget/Widget.js +101 -0
  22. package/dist/cjs/components/Widget/index.d.ts +2 -0
  23. package/dist/cjs/components/Widget/index.js +18 -0
  24. package/dist/cjs/components/Widget/styles.module.css +56 -0
  25. package/dist/cjs/components/Widget/types.d.ts +27 -0
  26. package/dist/cjs/components/Widget/types.js +2 -0
  27. package/dist/cjs/components/index.d.ts +3 -0
  28. package/dist/cjs/components/index.js +19 -0
  29. package/dist/cjs/helperComponents/Actions/ActionView.d.ts +10 -0
  30. package/dist/cjs/helperComponents/Actions/ActionView.js +49 -0
  31. package/dist/cjs/helperComponents/Actions/DesktopActions.d.ts +2 -0
  32. package/dist/cjs/helperComponents/Actions/DesktopActions.js +19 -0
  33. package/dist/cjs/helperComponents/Actions/MobileActions.d.ts +2 -0
  34. package/dist/cjs/helperComponents/Actions/MobileActions.js +70 -0
  35. package/dist/cjs/helperComponents/Actions/constants.d.ts +9 -0
  36. package/dist/cjs/helperComponents/Actions/constants.js +12 -0
  37. package/dist/cjs/helperComponents/Actions/helpers.d.ts +2 -0
  38. package/dist/cjs/helperComponents/Actions/helpers.js +6 -0
  39. package/dist/cjs/helperComponents/Actions/index.d.ts +3 -0
  40. package/dist/cjs/helperComponents/Actions/index.js +19 -0
  41. package/dist/cjs/helperComponents/Actions/styles.module.css +35 -0
  42. package/dist/cjs/helperComponents/Actions/types.d.ts +30 -0
  43. package/dist/cjs/helperComponents/Actions/types.js +2 -0
  44. package/dist/cjs/helperComponents/ButtonDropdown/ButtonDropdown.d.ts +8 -0
  45. package/dist/cjs/helperComponents/ButtonDropdown/ButtonDropdown.js +13 -0
  46. package/dist/cjs/helperComponents/ButtonDropdown/index.d.ts +1 -0
  47. package/dist/cjs/helperComponents/ButtonDropdown/index.js +17 -0
  48. package/dist/cjs/helperComponents/ButtonDroplist/ButtonDroplist.d.ts +12 -0
  49. package/dist/cjs/helperComponents/ButtonDroplist/ButtonDroplist.js +21 -0
  50. package/dist/cjs/helperComponents/ButtonDroplist/index.d.ts +1 -0
  51. package/dist/cjs/helperComponents/ButtonDroplist/index.js +17 -0
  52. package/dist/cjs/helperComponents/ButtonKebab/ButtonKebab.d.ts +8 -0
  53. package/dist/cjs/helperComponents/ButtonKebab/ButtonKebab.js +15 -0
  54. package/dist/cjs/helperComponents/ButtonKebab/index.d.ts +1 -0
  55. package/dist/cjs/helperComponents/ButtonKebab/index.js +17 -0
  56. package/dist/cjs/helperComponents/index.d.ts +1 -0
  57. package/dist/cjs/helperComponents/index.js +17 -0
  58. package/dist/cjs/index.d.ts +1 -0
  59. package/dist/cjs/index.js +17 -0
  60. package/dist/esm/components/ProductsWidget/ProductsWidget.d.ts +10 -0
  61. package/dist/esm/components/ProductsWidget/ProductsWidget.js +30 -0
  62. package/dist/esm/components/ProductsWidget/constants.d.ts +4 -0
  63. package/dist/esm/components/ProductsWidget/constants.js +4 -0
  64. package/dist/esm/components/ProductsWidget/index.d.ts +1 -0
  65. package/dist/esm/components/ProductsWidget/index.js +1 -0
  66. package/dist/esm/components/ProductsWidget/styles.module.css +45 -0
  67. package/dist/esm/components/ProductsWidget/utils/getLoadingCards.d.ts +6 -0
  68. package/dist/esm/components/ProductsWidget/utils/getLoadingCards.js +14 -0
  69. package/dist/esm/components/ProductsWidget/utils/getProductColumns.d.ts +8 -0
  70. package/dist/esm/components/ProductsWidget/utils/getProductColumns.js +16 -0
  71. package/dist/esm/components/SolutionsWidget/SolutionsWidget.d.ts +8 -0
  72. package/dist/esm/components/SolutionsWidget/SolutionsWidget.js +24 -0
  73. package/dist/esm/components/SolutionsWidget/index.d.ts +1 -0
  74. package/dist/esm/components/SolutionsWidget/index.js +1 -0
  75. package/dist/esm/components/SolutionsWidget/styles.module.css +28 -0
  76. package/dist/esm/components/Widget/Widget.d.ts +2 -0
  77. package/dist/esm/components/Widget/Widget.js +95 -0
  78. package/dist/esm/components/Widget/index.d.ts +2 -0
  79. package/dist/esm/components/Widget/index.js +2 -0
  80. package/dist/esm/components/Widget/styles.module.css +56 -0
  81. package/dist/esm/components/Widget/types.d.ts +27 -0
  82. package/dist/esm/components/Widget/types.js +1 -0
  83. package/dist/esm/components/index.d.ts +3 -0
  84. package/dist/esm/components/index.js +3 -0
  85. package/dist/esm/helperComponents/Actions/ActionView.d.ts +10 -0
  86. package/dist/esm/helperComponents/Actions/ActionView.js +46 -0
  87. package/dist/esm/helperComponents/Actions/DesktopActions.d.ts +2 -0
  88. package/dist/esm/helperComponents/Actions/DesktopActions.js +13 -0
  89. package/dist/esm/helperComponents/Actions/MobileActions.d.ts +2 -0
  90. package/dist/esm/helperComponents/Actions/MobileActions.js +64 -0
  91. package/dist/esm/helperComponents/Actions/constants.d.ts +9 -0
  92. package/dist/esm/helperComponents/Actions/constants.js +9 -0
  93. package/dist/esm/helperComponents/Actions/helpers.d.ts +2 -0
  94. package/dist/esm/helperComponents/Actions/helpers.js +3 -0
  95. package/dist/esm/helperComponents/Actions/index.d.ts +3 -0
  96. package/dist/esm/helperComponents/Actions/index.js +3 -0
  97. package/dist/esm/helperComponents/Actions/styles.module.css +35 -0
  98. package/dist/esm/helperComponents/Actions/types.d.ts +30 -0
  99. package/dist/esm/helperComponents/Actions/types.js +1 -0
  100. package/dist/esm/helperComponents/ButtonDropdown/ButtonDropdown.d.ts +8 -0
  101. package/dist/esm/helperComponents/ButtonDropdown/ButtonDropdown.js +10 -0
  102. package/dist/esm/helperComponents/ButtonDropdown/index.d.ts +1 -0
  103. package/dist/esm/helperComponents/ButtonDropdown/index.js +1 -0
  104. package/dist/esm/helperComponents/ButtonDroplist/ButtonDroplist.d.ts +12 -0
  105. package/dist/esm/helperComponents/ButtonDroplist/ButtonDroplist.js +18 -0
  106. package/dist/esm/helperComponents/ButtonDroplist/index.d.ts +1 -0
  107. package/dist/esm/helperComponents/ButtonDroplist/index.js +1 -0
  108. package/dist/esm/helperComponents/ButtonKebab/ButtonKebab.d.ts +8 -0
  109. package/dist/esm/helperComponents/ButtonKebab/ButtonKebab.js +12 -0
  110. package/dist/esm/helperComponents/ButtonKebab/index.d.ts +1 -0
  111. package/dist/esm/helperComponents/ButtonKebab/index.js +1 -0
  112. package/dist/esm/helperComponents/index.d.ts +1 -0
  113. package/dist/esm/helperComponents/index.js +1 -0
  114. package/dist/esm/index.d.ts +1 -0
  115. package/dist/esm/index.js +1 -0
  116. package/package.json +58 -0
  117. package/src/components/ProductsWidget/ProductsWidget.tsx +66 -0
  118. package/src/components/ProductsWidget/constants.ts +7 -0
  119. package/src/components/ProductsWidget/index.ts +1 -0
  120. package/src/components/ProductsWidget/styles.module.scss +40 -0
  121. package/src/components/ProductsWidget/utils/getLoadingCards.tsx +23 -0
  122. package/src/components/ProductsWidget/utils/getProductColumns.tsx +30 -0
  123. package/src/components/SolutionsWidget/SolutionsWidget.tsx +43 -0
  124. package/src/components/SolutionsWidget/index.ts +1 -0
  125. package/src/components/SolutionsWidget/styles.module.scss +31 -0
  126. package/src/components/Widget/Widget.tsx +173 -0
  127. package/src/components/Widget/index.ts +2 -0
  128. package/src/components/Widget/styles.module.scss +60 -0
  129. package/src/components/Widget/types.ts +39 -0
  130. package/src/components/index.ts +3 -0
  131. package/src/helperComponents/Actions/ActionView.tsx +67 -0
  132. package/src/helperComponents/Actions/DesktopActions.tsx +25 -0
  133. package/src/helperComponents/Actions/MobileActions.tsx +111 -0
  134. package/src/helperComponents/Actions/constants.ts +9 -0
  135. package/src/helperComponents/Actions/helpers.ts +5 -0
  136. package/src/helperComponents/Actions/index.ts +3 -0
  137. package/src/helperComponents/Actions/styles.module.scss +42 -0
  138. package/src/helperComponents/Actions/types.ts +33 -0
  139. package/src/helperComponents/ButtonDropdown/ButtonDropdown.tsx +22 -0
  140. package/src/helperComponents/ButtonDropdown/index.ts +1 -0
  141. package/src/helperComponents/ButtonDroplist/ButtonDroplist.tsx +46 -0
  142. package/src/helperComponents/ButtonDroplist/index.ts +1 -0
  143. package/src/helperComponents/ButtonKebab/ButtonKebab.tsx +31 -0
  144. package/src/helperComponents/ButtonKebab/index.ts +1 -0
  145. package/src/helperComponents/index.ts +1 -0
  146. package/src/index.ts +1 -0
@@ -0,0 +1,35 @@
1
+ .desktopActionsWrapper{
2
+ display:flex;
3
+ flex-direction:row-reverse;
4
+ align-items:center;
5
+ flex-shrink:0;
6
+ gap:var(--dimension-1m, 8px);
7
+ height:100%;
8
+ }
9
+
10
+ .mobileActionsWrapper{
11
+ display:flex;
12
+ gap:8px;
13
+ flex-shrink:0;
14
+ width:100%;
15
+ justify-content:stretch;
16
+ overflow-y:auto;
17
+ flex-direction:row-reverse;
18
+ -ms-overflow-style:none;
19
+ scrollbar-width:none;
20
+ }
21
+ .mobileActionsWrapper::-webkit-scrollbar{
22
+ display:none;
23
+ }
24
+
25
+ .button{
26
+ white-space:nowrap;
27
+ }
28
+ .button[data-full-width]:not([data-variant=icon-only]){
29
+ flex-shrink:0;
30
+ width:auto;
31
+ }
32
+ .button[data-variant=icon-only]{
33
+ flex-grow:0;
34
+ flex-shrink:0;
35
+ }
@@ -0,0 +1,30 @@
1
+ import { TooltipProps } from '@sbercloud/uikit-product-mobile-tooltip';
2
+ import { ButtonFilledProps, ButtonFunctionProps, ButtonOutlineProps, ButtonSimpleProps, ButtonTonalProps } from '@snack-uikit/button';
3
+ import { ButtonDroplistProps } from '../ButtonDroplist';
4
+ import { ButtonKebabProps } from '../ButtonKebab';
5
+ import { BUTTON_TYPE } from './constants';
6
+ type ButtonKebabPropsWithoutLayout = Omit<ButtonKebabProps, 'layoutType'>;
7
+ type ButtonDroplistWithoutLayout = Omit<ButtonDroplistProps, 'layoutType'>;
8
+ export type Action = {
9
+ tooltip?: TooltipProps;
10
+ hidden?: boolean;
11
+ } & (({
12
+ variant?: typeof BUTTON_TYPE.Filled;
13
+ } & ButtonFilledProps) | ({
14
+ variant: typeof BUTTON_TYPE.Outline;
15
+ } & ButtonOutlineProps) | ({
16
+ variant: typeof BUTTON_TYPE.Tonal;
17
+ } & ButtonTonalProps) | ({
18
+ variant: typeof BUTTON_TYPE.Function;
19
+ } & ButtonFunctionProps) | ({
20
+ variant: typeof BUTTON_TYPE.Simple;
21
+ } & ButtonSimpleProps) | ({
22
+ variant: typeof BUTTON_TYPE.Kebab;
23
+ } & ButtonKebabPropsWithoutLayout) | ({
24
+ variant: typeof BUTTON_TYPE.Droplist;
25
+ } & ButtonDroplistWithoutLayout));
26
+ export type ActionsProps = {
27
+ items: Action[];
28
+ maxVisibleItems?: number;
29
+ };
30
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { AdaptiveDropdownProps } from '@sbercloud/uikit-product-mobile-dropdown';
2
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
3
+ import { ButtonFunctionProps } from '@snack-uikit/button';
4
+ export type ButtonDropdownProps = WithLayoutType<{
5
+ button: Omit<ButtonFunctionProps, 'icon' | 'iconPosition' | 'appearance'>;
6
+ dropdown: Omit<AdaptiveDropdownProps, 'children' | 'layoutType' | 'placement'>;
7
+ }>;
8
+ export declare function ButtonDropdown({ layoutType, button, dropdown }: ButtonDropdownProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChevronDownSVG, ChevronUpSVG } from '@sbercloud/uikit-product-icons';
3
+ import { AdaptiveDropdown } from '@sbercloud/uikit-product-mobile-dropdown';
4
+ import { ButtonFunction } from '@snack-uikit/button';
5
+ import { useValueControl } from '@snack-uikit/utils';
6
+ export function ButtonDropdown({ layoutType, button, dropdown }) {
7
+ const [open, onOpenChange] = useValueControl({ onChange: dropdown.onOpenChange, value: dropdown.open });
8
+ const Icon = open ? ChevronUpSVG : ChevronDownSVG;
9
+ return (_jsx(AdaptiveDropdown, Object.assign({}, dropdown, { open: open, onOpenChange: onOpenChange, layoutType: layoutType, children: _jsx(ButtonFunction, Object.assign({}, button, { icon: _jsx(Icon, {}), iconPosition: 'after', appearance: 'neutral' })) })));
10
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonDropdown';
@@ -0,0 +1 @@
1
+ export * from './ButtonDropdown';
@@ -0,0 +1,12 @@
1
+ import { AdaptiveDroplistProps } from '@sbercloud/uikit-product-mobile-dropdown';
2
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
3
+ import { ButtonFilledProps, ButtonFunctionProps } from '@snack-uikit/button';
4
+ export type ButtonDroplistProps = WithLayoutType<{
5
+ button: (Omit<ButtonFilledProps, 'appearance'> & {
6
+ buttonType?: 'filled';
7
+ }) | (Omit<ButtonFunctionProps, 'icon' | 'iconPosition' | 'appearance'> & {
8
+ buttonType?: 'function';
9
+ });
10
+ list: Pick<AdaptiveDroplistProps, 'items' | 'closeDroplistOnItemClick' | 'className' | 'open' | 'onOpenChange'>;
11
+ }>;
12
+ export declare function ButtonDroplist({ layoutType, button, list }: ButtonDroplistProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { ChevronDownSVG, ChevronUpSVG } from '@sbercloud/uikit-product-icons';
4
+ import { AdaptiveDroplist } from '@sbercloud/uikit-product-mobile-dropdown';
5
+ import { ButtonFilled, ButtonFunction } from '@snack-uikit/button';
6
+ import { useValueControl } from '@snack-uikit/utils';
7
+ export function ButtonDroplist({ layoutType, button, list }) {
8
+ var _a;
9
+ const [open, onOpenChange] = useValueControl({ onChange: list.onOpenChange, value: list.open });
10
+ const Icon = open ? ChevronUpSVG : ChevronDownSVG;
11
+ const buttonType = (_a = button.buttonType) !== null && _a !== void 0 ? _a : 'function';
12
+ const Button = buttonType === 'filled' ? ButtonFilled : ButtonFunction;
13
+ const buttonProps = useMemo(() => buttonType === 'filled' ? button : Object.assign(Object.assign({}, button), { appearance: 'neutral', icon: _jsx(Icon, {}), iconPosition: 'after' }), [buttonType, button, Icon]);
14
+ return (_jsx(AdaptiveDroplist, Object.assign({}, list, { open: open, onOpenChange: onOpenChange, layoutType: layoutType, selection: {
15
+ mode: 'single',
16
+ value: 'null',
17
+ }, size: 's', children: _jsx(Button, Object.assign({}, buttonProps)) })));
18
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonDroplist';
@@ -0,0 +1 @@
1
+ export * from './ButtonDroplist';
@@ -0,0 +1,8 @@
1
+ import { AdaptiveDroplistProps } from '@sbercloud/uikit-product-mobile-dropdown';
2
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
3
+ import { ButtonOutlineProps } from '@snack-uikit/button';
4
+ export type ButtonKebabProps = WithLayoutType<{
5
+ button?: Omit<ButtonOutlineProps, 'label' | 'icon'>;
6
+ list: Pick<AdaptiveDroplistProps, 'items' | 'closeDroplistOnItemClick' | 'open' | 'onOpenChange' | 'className'>;
7
+ }>;
8
+ export declare function ButtonKebab({ layoutType, button, list }: ButtonKebabProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { KebabSVG } from '@sbercloud/uikit-product-icons';
3
+ import { AdaptiveDroplist } from '@sbercloud/uikit-product-mobile-dropdown';
4
+ import { ButtonOutline } from '@snack-uikit/button';
5
+ import { useValueControl } from '@snack-uikit/utils';
6
+ export function ButtonKebab({ layoutType, button, list }) {
7
+ const [open, onOpenChange] = useValueControl({ onChange: list.onOpenChange, value: list.open });
8
+ return (_jsx(AdaptiveDroplist, Object.assign({}, list, { open: open, onOpenChange: onOpenChange, layoutType: layoutType, selection: {
9
+ mode: 'single',
10
+ value: 'null',
11
+ }, placement: 'bottom-end', size: 's', children: _jsx(ButtonOutline, Object.assign({}, button, { icon: _jsx(KebabSVG, {}), appearance: 'neutral' })) })));
12
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonKebab';
@@ -0,0 +1 @@
1
+ export * from './ButtonKebab';
@@ -0,0 +1 @@
1
+ export * from './Actions';
@@ -0,0 +1 @@
1
+ export * from './Actions';
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1 @@
1
+ export * from './components';
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@cloud-ru/uikit-product-widget",
3
+ "title": "Widget",
4
+ "version": "0.9.4",
5
+ "sideEffects": [
6
+ "*.css",
7
+ "*.woff",
8
+ "*.woff2"
9
+ ],
10
+ "description": "",
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/widget",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://gitverse.ru/cloud-ru-tech/uikit-product.git",
27
+ "directory": "packages/widget"
28
+ },
29
+ "author": {
30
+ "name": "Akhremenko Grigorii",
31
+ "url": "https://github.com/AGrigorii"
32
+ },
33
+ "license": "Apache-2.0",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {},
38
+ "dependencies": {
39
+ "@cloud-ru/uikit-product-card-predefined": "0.8.12",
40
+ "@cloud-ru/uikit-product-icons": "15.1.1",
41
+ "@cloud-ru/uikit-product-mobile-carousel": "0.1.12",
42
+ "@cloud-ru/uikit-product-mobile-dropdown": "0.9.21",
43
+ "@cloud-ru/uikit-product-mobile-tooltip": "0.4.65",
44
+ "@cloud-ru/uikit-product-title-clickable": "0.0.48",
45
+ "@cloud-ru/uikit-product-utils": "7.0.0",
46
+ "@snack-uikit/button": "0.19.16",
47
+ "@snack-uikit/info-block": "0.6.33",
48
+ "@snack-uikit/link": "0.15.9",
49
+ "@snack-uikit/skeleton": "0.6.2",
50
+ "@snack-uikit/typography": "0.8.4",
51
+ "@snack-uikit/utils": "3.7.0",
52
+ "classnames": "2.5.1"
53
+ },
54
+ "peerDependencies": {
55
+ "@cloud-ru/uikit-product-locale": "*"
56
+ },
57
+ "gitHead": "e8bd79bc92b26a8f52611972eec98a867536ccd3"
58
+ }
@@ -0,0 +1,66 @@
1
+ import { ReactNode, useMemo } from 'react';
2
+
3
+ import { useLocale } from '@cloud-ru/uikit-product-locale';
4
+ import { AdaptiveCarousel, CarouselProps } from '@cloud-ru/uikit-product-mobile-carousel';
5
+ import { extractSupportProps, WithLayoutType, WithSupportProps } from '@cloud-ru/uikit-product-utils';
6
+ import { Typography } from '@snack-uikit/typography';
7
+
8
+ import { COLUMN_SIZE, MOBILE_COLUMN_SIZE, MOBILE_ROW_SIZE, ROW_SIZE } from './constants';
9
+ import styles from './styles.module.scss';
10
+ import { getLoadingCards } from './utils/getLoadingCards';
11
+ import { getProductColumns } from './utils/getProductColumns';
12
+
13
+ export type ProductsWidgetProps = WithLayoutType<
14
+ Pick<CarouselProps, 'arrows' | 'pagination'> &
15
+ WithSupportProps<{
16
+ loading?: boolean;
17
+ cards: ReactNode[];
18
+ columnSize?: number;
19
+ rowSize?: number;
20
+ }>
21
+ >;
22
+
23
+ export function ProductsWidget({
24
+ layoutType,
25
+ cards = [],
26
+ loading = false,
27
+ columnSize: columnSizeProp = COLUMN_SIZE,
28
+ rowSize: rowSizeProp = ROW_SIZE,
29
+ arrows = true,
30
+ pagination = true,
31
+ ...rest
32
+ }: ProductsWidgetProps) {
33
+ const { t } = useLocale('Widget');
34
+ const isMobile = layoutType === 'mobile';
35
+ const columnSize = isMobile ? MOBILE_COLUMN_SIZE : columnSizeProp;
36
+ const rowSize = isMobile ? MOBILE_ROW_SIZE : rowSizeProp;
37
+
38
+ const productsCards = useMemo(
39
+ () => (loading ? getLoadingCards({ columnSize, rowSize }) : getProductColumns({ cards, columnSize, rowSize })),
40
+ [columnSize, loading, cards, rowSize],
41
+ );
42
+
43
+ return (
44
+ <div className={styles.wrapper} {...extractSupportProps(rest)}>
45
+ <div className={styles.headerWrapper}>
46
+ <Typography.SansTitleL tag='h5'>{t('Products.title')}</Typography.SansTitleL>
47
+ </div>
48
+
49
+ <AdaptiveCarousel
50
+ layoutType={layoutType}
51
+ gap='8px'
52
+ infiniteScroll={!isMobile}
53
+ swipe={false}
54
+ showItems={rowSize}
55
+ arrows={arrows}
56
+ pagination={pagination}
57
+ >
58
+ {productsCards.map((d, index) => (
59
+ <div className={styles.column} key={index}>
60
+ {d}
61
+ </div>
62
+ ))}
63
+ </AdaptiveCarousel>
64
+ </div>
65
+ );
66
+ }
@@ -0,0 +1,7 @@
1
+ export const ROW_SIZE = 4;
2
+
3
+ export const COLUMN_SIZE = 3;
4
+
5
+ export const MOBILE_ROW_SIZE = 1.1;
6
+
7
+ export const MOBILE_COLUMN_SIZE = 4;
@@ -0,0 +1 @@
1
+ export * from './ProductsWidget';
@@ -0,0 +1,40 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables';
2
+
3
+ .wrapper {
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: 16px;
7
+
8
+ grid-column: span 12;
9
+ }
10
+
11
+ .column {
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: styles-theme-variables.$dimension-1m;
15
+ }
16
+
17
+ .headerWrapper {
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: space-between;
21
+ gap: styles-theme-variables.$dimension-050m;
22
+ }
23
+
24
+ .arrowWrapper {
25
+ display: flex;
26
+ align-items: center;
27
+ }
28
+
29
+ .pageNumber {
30
+ @include styles-theme-variables.composite-var(styles-theme-variables.$sans-label-l);
31
+
32
+ color: styles-theme-variables.$sys-neutral-text-main;
33
+ }
34
+
35
+ .pageTotal {
36
+ @include styles-theme-variables.composite-var(styles-theme-variables.$sans-body-m);
37
+
38
+ margin-right: styles-theme-variables.$dimension-050m;
39
+ color: styles-theme-variables.$sys-neutral-text-support;
40
+ }
@@ -0,0 +1,23 @@
1
+ import { Skeleton } from '@snack-uikit/skeleton';
2
+
3
+ import { COLUMN_SIZE, ROW_SIZE } from '../constants';
4
+
5
+ type GetLoadingCardsParams = {
6
+ columnSize?: number;
7
+ rowSize?: number;
8
+ };
9
+
10
+ export function getLoadingCards({ columnSize = COLUMN_SIZE, rowSize = ROW_SIZE }: GetLoadingCardsParams) {
11
+ const result = [];
12
+
13
+ for (let i = 0; i < rowSize; i++) {
14
+ const columnSkeletons = [];
15
+ for (let j = 0; j < columnSize; j++) {
16
+ columnSkeletons.push(<Skeleton loading borderRadius={8} height={48} />);
17
+ }
18
+
19
+ result.push(columnSkeletons);
20
+ }
21
+
22
+ return result;
23
+ }
@@ -0,0 +1,30 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type GetProductColumnsParams = {
4
+ cards: ReactNode[];
5
+ columnSize: number;
6
+ rowSize: number;
7
+ };
8
+
9
+ export function getProductColumns({ cards, columnSize }: GetProductColumnsParams) {
10
+ const result = [];
11
+
12
+ for (let i = 0; i < cards.length; i += columnSize) {
13
+ const innerCards = [];
14
+
15
+ for (let j = 0; j < columnSize; j++) {
16
+ const index = i + j;
17
+ if (index >= cards.length) {
18
+ break;
19
+ }
20
+
21
+ const card = cards[index];
22
+
23
+ innerCards.push(card);
24
+ }
25
+
26
+ result.push(innerCards);
27
+ }
28
+
29
+ return result;
30
+ }
@@ -0,0 +1,43 @@
1
+ import { CardSuggest, CardSuggestProps } from '@cloud-ru/uikit-product-card-predefined';
2
+ import { useLocale } from '@cloud-ru/uikit-product-locale';
3
+ import { extractSupportProps, WithLayoutType, WithSupportProps } from '@cloud-ru/uikit-product-utils';
4
+ import { Link, LinkProps } from '@snack-uikit/link';
5
+ import { Typography } from '@snack-uikit/typography';
6
+
7
+ import styles from './styles.module.scss';
8
+
9
+ export type SolutionsWidgetProps = WithLayoutType<
10
+ WithSupportProps<{
11
+ moreLink?: Pick<LinkProps, 'onClick' | 'href'>;
12
+ cards: Pick<CardSuggestProps, 'description' | 'title' | 'onClick'>[];
13
+ }>
14
+ >;
15
+
16
+ export function SolutionsWidget({ layoutType, moreLink, cards, ...rest }: SolutionsWidgetProps) {
17
+ const { t } = useLocale('Widget');
18
+ const isMobile = layoutType === 'mobile';
19
+
20
+ return (
21
+ <div className={styles.wrapper} {...extractSupportProps(rest)}>
22
+ <div className={styles.header}>
23
+ <Typography.SansTitleL tag='h5'>{t('Solutions.title')}</Typography.SansTitleL>
24
+
25
+ {moreLink && (
26
+ <Link
27
+ text={t('Solutions.link')}
28
+ size='m'
29
+ appearance='neutral'
30
+ onClick={moreLink?.onClick}
31
+ href={moreLink?.href}
32
+ />
33
+ )}
34
+ </div>
35
+
36
+ <div className={styles.cards} data-mobile={isMobile || undefined}>
37
+ {cards.map(({ description, title, onClick }) => (
38
+ <CardSuggest className={styles.card} key={title} description={description} title={title} onClick={onClick} />
39
+ ))}
40
+ </div>
41
+ </div>
42
+ );
43
+ }
@@ -0,0 +1 @@
1
+ export * from './SolutionsWidget';
@@ -0,0 +1,31 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables';
2
+
3
+ .wrapper {
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: styles-theme-variables.$dimension-2m;
7
+ grid-column: span 12;
8
+ }
9
+
10
+ .header {
11
+ display: flex;
12
+ flex-direction: row;
13
+ justify-content: space-between;
14
+ align-items: center;
15
+ }
16
+
17
+ .cards {
18
+ display: grid;
19
+ grid-template-columns: repeat(4, 1fr);
20
+ gap: styles-theme-variables.$dimension-1m;
21
+
22
+ &[data-mobile] {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 10px;
26
+ }
27
+ }
28
+
29
+ .card {
30
+ flex-grow: 0;
31
+ }
@@ -0,0 +1,173 @@
1
+ import cn from 'classnames';
2
+ import { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
3
+
4
+ import { CrossSVG } from '@cloud-ru/uikit-product-icons';
5
+ import { useLocale } from '@cloud-ru/uikit-product-locale';
6
+ import { AdaptiveDroplistProps, MobileDroplistProps } from '@cloud-ru/uikit-product-mobile-dropdown';
7
+ import { TitleClickable } from '@cloud-ru/uikit-product-title-clickable';
8
+ import { InfoBlock } from '@snack-uikit/info-block';
9
+ import { Skeleton } from '@snack-uikit/skeleton';
10
+ import { extractSupportProps } from '@snack-uikit/utils';
11
+
12
+ import { ActionView } from '../../helperComponents/Actions/ActionView';
13
+ import { BUTTON_TYPE } from '../../helperComponents/Actions/constants';
14
+ import { DesktopActions } from '../../helperComponents/Actions/DesktopActions';
15
+ import { MobileActions } from '../../helperComponents/Actions/MobileActions';
16
+ import { Action } from '../../helperComponents/Actions/types';
17
+ import { ButtonKebab } from '../../helperComponents/ButtonKebab';
18
+ import styles from './styles.module.scss';
19
+ import { WidgetProps } from './types';
20
+
21
+ export function Widget({
22
+ header,
23
+ children,
24
+ actions = [],
25
+ wide = false,
26
+ state = 'default',
27
+ loadingState,
28
+ errorState,
29
+ className,
30
+ layoutType,
31
+ ...rest
32
+ }: WidgetProps) {
33
+ const { t } = useLocale('Widget');
34
+ const renderContent = (): ReactNode => {
35
+ switch (state) {
36
+ case 'loading': {
37
+ if (loadingState?.loadingContent) {
38
+ return loadingState.loadingContent;
39
+ }
40
+
41
+ if (loadingState?.showSkeleton) {
42
+ return (
43
+ <div className={styles.skeletonContent}>
44
+ <Skeleton loading width='100%' height={80} borderRadius={8} />
45
+ </div>
46
+ );
47
+ }
48
+
49
+ return null;
50
+ }
51
+
52
+ case 'error': {
53
+ return (
54
+ <InfoBlock
55
+ size='m'
56
+ icon={errorState?.errorIcon ?? { icon: CrossSVG, appearance: 'neutral', decor: true }}
57
+ title={errorState?.errorTitle || t('dataErrorTitle')}
58
+ description={errorState?.errorDescription || t('dataErrorDescription')}
59
+ />
60
+ );
61
+ }
62
+
63
+ case 'default':
64
+ default: {
65
+ return children;
66
+ }
67
+ }
68
+ };
69
+
70
+ const renderActionsSkeleton = () => (
71
+ <div className={cn(styles.actionsWrapper, { [styles.actionsWide]: wide })}>
72
+ <div className={styles.skeletonActions}>
73
+ {wide ? (
74
+ <>
75
+ <Skeleton loading width={96} height={32} borderRadius={8} />
76
+ <Skeleton loading width={32} height={32} borderRadius={8} />
77
+ </>
78
+ ) : (
79
+ <>
80
+ <div style={{ flex: 1, minWidth: 0 }}>
81
+ <Skeleton loading width={'100%'} height={32} borderRadius={8} />
82
+ </div>
83
+ <Skeleton loading width={32} height={32} borderRadius={8} />
84
+ </>
85
+ )}
86
+ </div>
87
+ </div>
88
+ );
89
+
90
+ const getPrimaryAction = (items: Action[]): Action | undefined => {
91
+ const index = items.findIndex(a => a.variant !== BUTTON_TYPE.Droplist && a.variant !== BUTTON_TYPE.Kebab);
92
+ return index >= 0 ? items[index] : undefined;
93
+ };
94
+
95
+ const buildKebabItems = (items: Action[]): NonNullable<MobileDroplistProps['items']> =>
96
+ items.reduce<NonNullable<MobileDroplistProps['items']>>(
97
+ (acc, action) => {
98
+ if (action.variant === BUTTON_TYPE.Droplist || action.variant === BUTTON_TYPE.Kebab) {
99
+ acc.push({
100
+ type: 'group',
101
+ label: action.variant === BUTTON_TYPE.Droplist ? action.button?.label : undefined,
102
+ items: action.list.items,
103
+ divider: acc.length > 0,
104
+ });
105
+ } else {
106
+ acc.push({
107
+ content: { option: action.label ?? '' },
108
+ beforeContent: action.icon,
109
+ onClick: (event: ReactMouseEvent<HTMLElement>) => {
110
+ action.onClick?.(event as never);
111
+ },
112
+ });
113
+ }
114
+ return acc;
115
+ },
116
+ [] as NonNullable<MobileDroplistProps['items']>,
117
+ );
118
+
119
+ const renderActions = () => {
120
+ if (state === 'loading') {
121
+ return renderActionsSkeleton();
122
+ }
123
+
124
+ if (!actions.length) return null;
125
+
126
+ if (wide) {
127
+ const isMobile = layoutType === 'mobile';
128
+ return (
129
+ <div className={cn(styles.actionsWrapper, { [styles.actionsWide]: wide })}>
130
+ {isMobile ? <MobileActions items={actions} /> : <DesktopActions items={actions} />}
131
+ </div>
132
+ );
133
+ }
134
+
135
+ const primaryAction = getPrimaryAction(actions);
136
+ const kebabItemsMobile = buildKebabItems(actions);
137
+
138
+ return (
139
+ <div className={cn(styles.actionsWrapper)}>
140
+ {primaryAction && (
141
+ <ActionView {...primaryAction} layoutType={layoutType} commonProps={{ size: 's', fullWidth: true }} />
142
+ )}
143
+ <ButtonKebab
144
+ layoutType={layoutType}
145
+ list={{
146
+ items: kebabItemsMobile as unknown as AdaptiveDroplistProps['items'],
147
+ closeDroplistOnItemClick: true,
148
+ }}
149
+ />
150
+ </div>
151
+ );
152
+ };
153
+
154
+ return (
155
+ <div className={cn(styles.widget, className)} {...extractSupportProps(rest)}>
156
+ <div className={styles.widgetHeader}>
157
+ {state === 'loading' ? (
158
+ <div className={styles.skeletonHeader}>
159
+ <Skeleton loading width={wide ? 120 : '100%'} height={32} borderRadius={8} />
160
+ </div>
161
+ ) : (
162
+ <TitleClickable {...header} className={cn(styles.titleClickable, header.className)} />
163
+ )}
164
+
165
+ {wide && renderActions()}
166
+ </div>
167
+
168
+ <div className={styles.widgetContent}>{renderContent()}</div>
169
+
170
+ {!wide && renderActions()}
171
+ </div>
172
+ );
173
+ }