@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,2 @@
1
+ export * from './types';
2
+ export * from './Widget';
@@ -0,0 +1,60 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables';
2
+
3
+ .widget {
4
+ box-sizing: border-box;
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: calc(styles-theme-variables.$dimension-1m + styles-theme-variables.$dimension-050m);
8
+ background-color: styles-theme-variables.$sys-neutral-background1-level;
9
+ border-radius: calc(styles-theme-variables.$dimension-1m + styles-theme-variables.$dimension-050m);
10
+ padding: styles-theme-variables.$dimension-2m;
11
+ }
12
+
13
+ .widgetHeader {
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ gap: styles-theme-variables.$dimension-1m;
18
+ min-width: 0;
19
+ }
20
+
21
+ .titleClickable {
22
+ flex: 1;
23
+ min-width: 0;
24
+ }
25
+
26
+ .widgetContent {
27
+ color: styles-theme-variables.$sys-neutral-text-main;
28
+ min-height: 0;
29
+ }
30
+
31
+ .actionsWrapper {
32
+ flex-shrink: 0;
33
+ display: flex;
34
+ align-items: center;
35
+ gap: styles-theme-variables.$dimension-050m;
36
+ }
37
+
38
+ .actionsWide {
39
+ justify-content: flex-end;
40
+ }
41
+
42
+ .skeletonContent {
43
+ display: flex;
44
+ flex-direction: column;
45
+ gap: styles-theme-variables.$dimension-050m;
46
+ }
47
+
48
+ .skeletonHeader {
49
+ flex: 1;
50
+ min-width: 0;
51
+ }
52
+
53
+ .skeletonActions {
54
+ display: flex;
55
+ align-items: center;
56
+ gap: styles-theme-variables.$dimension-1m;
57
+ width: 100%;
58
+ }
59
+
60
+
@@ -0,0 +1,39 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import { TitleClickableProps } from '@cloud-ru/uikit-product-title-clickable';
4
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
5
+ import type { InfoBlockProps } from '@snack-uikit/info-block';
6
+ import { WithSupportProps } from '@snack-uikit/utils';
7
+
8
+ import { Action } from '../../helperComponents/Actions/types';
9
+
10
+ export type WidgetState = 'default' | 'loading' | 'error';
11
+
12
+ export type WidgetHeaderProps = Pick<
13
+ TitleClickableProps,
14
+ 'title' | 'icon' | 'avatar' | 'href' | 'target' | 'onClick' | 'titleTag' | 'fullWidth' | 'children' | 'className'
15
+ >;
16
+
17
+ export type WidgetLoadingStateProps = {
18
+ loadingContent?: ReactNode;
19
+ showSkeleton?: boolean;
20
+ };
21
+
22
+ export type WidgetErrorStateProps = {
23
+ errorTitle?: string;
24
+ errorDescription?: string;
25
+ errorIcon?: InfoBlockProps['icon'];
26
+ };
27
+
28
+ export type WidgetProps = WithLayoutType<
29
+ WithSupportProps<{
30
+ header: WidgetHeaderProps;
31
+ children: ReactNode;
32
+ actions?: Action[];
33
+ wide?: boolean;
34
+ state?: WidgetState;
35
+ loadingState?: WidgetLoadingStateProps;
36
+ errorState?: WidgetErrorStateProps;
37
+ className?: string;
38
+ }>
39
+ >;
@@ -0,0 +1,3 @@
1
+ export * from './ProductsWidget';
2
+ export * from './SolutionsWidget';
3
+ export * from './Widget';
@@ -0,0 +1,67 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ import { AdaptiveTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
4
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
5
+ import {
6
+ ButtonFilled,
7
+ ButtonFilledProps,
8
+ ButtonFunction,
9
+ ButtonFunctionProps,
10
+ ButtonOutline,
11
+ ButtonOutlineProps,
12
+ ButtonSimple,
13
+ ButtonSimpleProps,
14
+ ButtonTonal,
15
+ ButtonTonalProps,
16
+ } from '@snack-uikit/button';
17
+
18
+ import { ButtonDroplist, ButtonDroplistProps } from '../ButtonDroplist';
19
+ import { ButtonKebab, ButtonKebabProps } from '../ButtonKebab';
20
+ import { BUTTON_TYPE } from './constants';
21
+ import { Action } from './types';
22
+
23
+ export function ActionView({
24
+ variant,
25
+ tooltip,
26
+ hidden = false,
27
+ layoutType,
28
+ commonProps,
29
+ ...buttonProps
30
+ }: WithLayoutType<Action & { commonProps: { className?: string; size?: 's' | 'm' | 'l'; fullWidth?: boolean } }>) {
31
+ if (hidden) {
32
+ return null;
33
+ }
34
+
35
+ const addTooltip = (component: ReactNode) =>
36
+ tooltip ? (
37
+ <AdaptiveTooltip layoutType={layoutType} {...tooltip}>
38
+ {component}
39
+ </AdaptiveTooltip>
40
+ ) : (
41
+ component
42
+ );
43
+
44
+ switch (variant) {
45
+ case BUTTON_TYPE.Filled:
46
+ return addTooltip(<ButtonFilled {...(buttonProps as ButtonFilledProps)} {...commonProps} />);
47
+ case BUTTON_TYPE.Outline:
48
+ return addTooltip(<ButtonOutline {...(buttonProps as ButtonOutlineProps)} {...commonProps} />);
49
+ case BUTTON_TYPE.Tonal:
50
+ return addTooltip(<ButtonTonal {...(buttonProps as ButtonTonalProps)} {...commonProps} />);
51
+ case BUTTON_TYPE.Function:
52
+ return addTooltip(<ButtonFunction {...(buttonProps as ButtonFunctionProps)} {...commonProps} />);
53
+ case BUTTON_TYPE.Simple:
54
+ return addTooltip(<ButtonSimple {...(buttonProps as ButtonSimpleProps)} {...commonProps} />);
55
+ case BUTTON_TYPE.Kebab: {
56
+ const { button, list } = buttonProps as ButtonKebabProps;
57
+ return addTooltip(<ButtonKebab button={{ ...button, ...commonProps }} list={list} layoutType={layoutType} />);
58
+ }
59
+ case BUTTON_TYPE.Droplist: {
60
+ const { button, list } = buttonProps as ButtonDroplistProps;
61
+ return addTooltip(<ButtonDroplist button={{ ...button, ...commonProps }} list={list} layoutType={layoutType} />);
62
+ }
63
+
64
+ default:
65
+ return null;
66
+ }
67
+ }
@@ -0,0 +1,25 @@
1
+ import { ActionView } from './ActionView';
2
+ import { hasVisibleActions } from './helpers';
3
+ import styles from './styles.module.scss';
4
+ import { ActionsProps } from './types';
5
+
6
+ export function DesktopActions({ items }: Pick<ActionsProps, 'items'>) {
7
+ if (!hasVisibleActions(items)) {
8
+ return null;
9
+ }
10
+
11
+ return (
12
+ <div className={styles.desktopActionsWrapper}>
13
+ {items.map((action, index) => (
14
+ <ActionView
15
+ {...action}
16
+ key={index}
17
+ layoutType='desktop'
18
+ commonProps={{
19
+ className: styles.button,
20
+ }}
21
+ />
22
+ ))}
23
+ </div>
24
+ );
25
+ }
@@ -0,0 +1,111 @@
1
+ import { useRef, useState } from 'react';
2
+
3
+ import { KebabSVG } from '@cloud-ru/uikit-product-icons';
4
+ import { MobileDroplist, MobileDroplistProps } from '@cloud-ru/uikit-product-mobile-dropdown';
5
+ import { MobileTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
6
+ import { ButtonOutline } from '@snack-uikit/button';
7
+ import { useDynamicList } from '@snack-uikit/utils';
8
+
9
+ import { ActionView } from './ActionView';
10
+ import { BUTTON_TYPE } from './constants';
11
+ import { hasVisibleActions } from './helpers';
12
+ import styles from './styles.module.scss';
13
+ import { ActionsProps } from './types';
14
+
15
+ export function MobileActions({ items }: ActionsProps) {
16
+ const containerRef = useRef<HTMLDivElement>(null);
17
+
18
+ const [isOpen, setIsOpen] = useState(false);
19
+ const { visibleItems, hiddenItems } = useDynamicList({ parentContainerRef: containerRef, items, maxVisibleItems: 2 });
20
+
21
+ if (!hasVisibleActions(items)) {
22
+ return null;
23
+ }
24
+
25
+ const hiddenItemsWithKebab = hiddenItems.concat(visibleItems.filter(item => item.variant === 'kebab'));
26
+ const visibleItemsWithoutKebab = visibleItems.filter(item => item.variant !== 'kebab');
27
+
28
+ return (
29
+ <div className={styles.mobileActionsWrapper} ref={containerRef}>
30
+ {hiddenItemsWithKebab.length > 0 && (
31
+ <MobileDroplist
32
+ open={isOpen}
33
+ onOpenChange={setIsOpen}
34
+ items={hiddenItemsWithKebab.reduce(
35
+ (acc, action) => {
36
+ switch (action.variant) {
37
+ case BUTTON_TYPE.Tonal:
38
+ case BUTTON_TYPE.Simple:
39
+ case BUTTON_TYPE.Outline:
40
+ case BUTTON_TYPE.Function:
41
+ case BUTTON_TYPE.Filled: {
42
+ acc.push({
43
+ ...action,
44
+ content: { option: action.label ?? '' },
45
+ onClick: event => {
46
+ setIsOpen(false);
47
+ action.onClick?.(event);
48
+ },
49
+ beforeContent: action?.icon,
50
+ itemWrapRender: action.tooltip
51
+ ? item => (
52
+ <MobileTooltip tip={action.tooltip?.tip ?? ''} {...action.tooltip}>
53
+ {item}
54
+ </MobileTooltip>
55
+ )
56
+ : undefined,
57
+ });
58
+ break;
59
+ }
60
+
61
+ case BUTTON_TYPE.Droplist:
62
+ case BUTTON_TYPE.Kebab: {
63
+ const needDivider = Boolean(action.variant === 'droplist' && action?.button.label) || acc.length > 0;
64
+
65
+ acc.push({
66
+ ...action,
67
+ type: 'group',
68
+ label: action.variant === 'droplist' ? action?.button.label : undefined,
69
+ divider: needDivider,
70
+ items: action.list.items.map(item => ({
71
+ ...item,
72
+ onClick: event => {
73
+ setIsOpen(false);
74
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75
+ // @ts-expect-error
76
+ item.onClick?.(event);
77
+ },
78
+ })),
79
+ });
80
+ break;
81
+ }
82
+
83
+ default: {
84
+ break;
85
+ }
86
+ }
87
+
88
+ return acc;
89
+ },
90
+ [] as MobileDroplistProps['items'],
91
+ )}
92
+ >
93
+ <ButtonOutline appearance='neutral' icon={<KebabSVG />} size='s' />
94
+ </MobileDroplist>
95
+ )}
96
+
97
+ {visibleItemsWithoutKebab.map((action, index) => (
98
+ <ActionView
99
+ {...action}
100
+ key={index}
101
+ layoutType='mobile'
102
+ commonProps={{
103
+ className: styles.button,
104
+ size: 's',
105
+ fullWidth: true,
106
+ }}
107
+ />
108
+ ))}
109
+ </div>
110
+ );
111
+ }
@@ -0,0 +1,9 @@
1
+ export const BUTTON_TYPE = {
2
+ Filled: 'filled',
3
+ Outline: 'outline',
4
+ Tonal: 'tonal',
5
+ Function: 'function',
6
+ Simple: 'simple',
7
+ Droplist: 'droplist',
8
+ Kebab: 'kebab',
9
+ } as const;
@@ -0,0 +1,5 @@
1
+ import { Action } from './types';
2
+
3
+ export function hasVisibleActions(actions: Action[]) {
4
+ return actions.some(action => !action.hidden);
5
+ }
@@ -0,0 +1,3 @@
1
+ export * from './DesktopActions';
2
+ export * from './MobileActions';
3
+ export * from './types';
@@ -0,0 +1,42 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables';
2
+
3
+ .desktopActionsWrapper {
4
+ display: flex;
5
+ flex-direction: row-reverse;
6
+ align-items: center;
7
+ flex-shrink: 0;
8
+ gap: styles-theme-variables.$dimension-1m;
9
+ height: 100%;
10
+ }
11
+
12
+ .mobileActionsWrapper {
13
+ display: flex;
14
+ gap: 8px;
15
+ flex-shrink: 0;
16
+ width: 100%;
17
+ justify-content: stretch;
18
+ overflow-y: auto;
19
+ flex-direction: row-reverse;
20
+
21
+ /* Hide scrollbar */
22
+ -ms-overflow-style: none; /* IE and Edge */
23
+ scrollbar-width: none; /* Firefox */
24
+
25
+ &::-webkit-scrollbar {
26
+ display: none; /* Chrome, Safari and Opera */
27
+ }
28
+ }
29
+
30
+ .button {
31
+ white-space: nowrap;
32
+
33
+ &[data-full-width]:not([data-variant='icon-only']) {
34
+ flex-shrink: 0;
35
+ width: auto;
36
+ }
37
+
38
+ &[data-variant='icon-only'] {
39
+ flex-grow: 0;
40
+ flex-shrink: 0;
41
+ }
42
+ }
@@ -0,0 +1,33 @@
1
+ import { TooltipProps } from '@cloud-ru/uikit-product-mobile-tooltip';
2
+ import {
3
+ ButtonFilledProps,
4
+ ButtonFunctionProps,
5
+ ButtonOutlineProps,
6
+ ButtonSimpleProps,
7
+ ButtonTonalProps,
8
+ } from '@snack-uikit/button';
9
+
10
+ import { ButtonDroplistProps } from '../ButtonDroplist';
11
+ import { ButtonKebabProps } from '../ButtonKebab';
12
+ import { BUTTON_TYPE } from './constants';
13
+
14
+ type ButtonKebabPropsWithoutLayout = Omit<ButtonKebabProps, 'layoutType'>;
15
+ type ButtonDroplistWithoutLayout = Omit<ButtonDroplistProps, 'layoutType'>;
16
+
17
+ export type Action = {
18
+ tooltip?: TooltipProps;
19
+ hidden?: boolean;
20
+ } & (
21
+ | ({ variant?: typeof BUTTON_TYPE.Filled } & ButtonFilledProps)
22
+ | ({ variant: typeof BUTTON_TYPE.Outline } & ButtonOutlineProps)
23
+ | ({ variant: typeof BUTTON_TYPE.Tonal } & ButtonTonalProps)
24
+ | ({ variant: typeof BUTTON_TYPE.Function } & ButtonFunctionProps)
25
+ | ({ variant: typeof BUTTON_TYPE.Simple } & ButtonSimpleProps)
26
+ | ({ variant: typeof BUTTON_TYPE.Kebab } & ButtonKebabPropsWithoutLayout)
27
+ | ({ variant: typeof BUTTON_TYPE.Droplist } & ButtonDroplistWithoutLayout)
28
+ );
29
+
30
+ export type ActionsProps = {
31
+ items: Action[];
32
+ maxVisibleItems?: number;
33
+ };
@@ -0,0 +1,22 @@
1
+ import { ChevronDownSVG, ChevronUpSVG } from '@cloud-ru/uikit-product-icons';
2
+ import { AdaptiveDropdown, AdaptiveDropdownProps } from '@cloud-ru/uikit-product-mobile-dropdown';
3
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
4
+ import { ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
5
+ import { useValueControl } from '@snack-uikit/utils';
6
+
7
+ export type ButtonDropdownProps = WithLayoutType<{
8
+ button: Omit<ButtonFunctionProps, 'icon' | 'iconPosition' | 'appearance'>;
9
+ dropdown: Omit<AdaptiveDropdownProps, 'children' | 'layoutType' | 'placement'>;
10
+ }>;
11
+
12
+ export function ButtonDropdown({ layoutType, button, dropdown }: ButtonDropdownProps) {
13
+ const [open, onOpenChange] = useValueControl<boolean>({ onChange: dropdown.onOpenChange, value: dropdown.open });
14
+
15
+ const Icon = open ? ChevronUpSVG : ChevronDownSVG;
16
+
17
+ return (
18
+ <AdaptiveDropdown {...dropdown} open={open} onOpenChange={onOpenChange} layoutType={layoutType}>
19
+ <ButtonFunction {...button} icon={<Icon />} iconPosition='after' appearance='neutral' />
20
+ </AdaptiveDropdown>
21
+ );
22
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonDropdown';
@@ -0,0 +1,46 @@
1
+ import { useMemo } from 'react';
2
+
3
+ import { ChevronDownSVG, ChevronUpSVG } from '@cloud-ru/uikit-product-icons';
4
+ import { AdaptiveDroplist, AdaptiveDroplistProps } from '@cloud-ru/uikit-product-mobile-dropdown';
5
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
6
+ import { ButtonFilled, ButtonFilledProps, ButtonFunction, ButtonFunctionProps } from '@snack-uikit/button';
7
+ import { useValueControl } from '@snack-uikit/utils';
8
+
9
+ export type ButtonDroplistProps = WithLayoutType<{
10
+ button:
11
+ | (Omit<ButtonFilledProps, 'appearance'> & { buttonType?: 'filled' })
12
+ | (Omit<ButtonFunctionProps, 'icon' | 'iconPosition' | 'appearance'> & { buttonType?: 'function' });
13
+ list: Pick<AdaptiveDroplistProps, 'items' | 'closeDroplistOnItemClick' | 'className' | 'open' | 'onOpenChange'>;
14
+ }>;
15
+
16
+ export function ButtonDroplist({ layoutType, button, list }: ButtonDroplistProps) {
17
+ const [open, onOpenChange] = useValueControl<boolean>({ onChange: list.onOpenChange, value: list.open });
18
+
19
+ const Icon = open ? ChevronUpSVG : ChevronDownSVG;
20
+
21
+ const buttonType = button.buttonType ?? 'function';
22
+
23
+ const Button = buttonType === 'filled' ? ButtonFilled : ButtonFunction;
24
+
25
+ const buttonProps: ButtonDroplistProps['button'] = useMemo(
26
+ () =>
27
+ buttonType === 'filled' ? button : { ...button, appearance: 'neutral', icon: <Icon />, iconPosition: 'after' },
28
+ [buttonType, button, Icon],
29
+ );
30
+
31
+ return (
32
+ <AdaptiveDroplist
33
+ {...list}
34
+ open={open}
35
+ onOpenChange={onOpenChange}
36
+ layoutType={layoutType}
37
+ selection={{
38
+ mode: 'single',
39
+ value: 'null',
40
+ }}
41
+ size='s'
42
+ >
43
+ <Button {...buttonProps} />
44
+ </AdaptiveDroplist>
45
+ );
46
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonDroplist';
@@ -0,0 +1,31 @@
1
+ import { KebabSVG } from '@cloud-ru/uikit-product-icons';
2
+ import { AdaptiveDroplist, AdaptiveDroplistProps } from '@cloud-ru/uikit-product-mobile-dropdown';
3
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
4
+ import { ButtonOutline, ButtonOutlineProps } from '@snack-uikit/button';
5
+ import { useValueControl } from '@snack-uikit/utils';
6
+
7
+ export type ButtonKebabProps = WithLayoutType<{
8
+ button?: Omit<ButtonOutlineProps, 'label' | 'icon'>;
9
+ list: Pick<AdaptiveDroplistProps, 'items' | 'closeDroplistOnItemClick' | 'open' | 'onOpenChange' | 'className'>;
10
+ }>;
11
+
12
+ export function ButtonKebab({ layoutType, button, list }: ButtonKebabProps) {
13
+ const [open, onOpenChange] = useValueControl<boolean>({ onChange: list.onOpenChange, value: list.open });
14
+
15
+ return (
16
+ <AdaptiveDroplist
17
+ {...list}
18
+ open={open}
19
+ onOpenChange={onOpenChange}
20
+ layoutType={layoutType}
21
+ selection={{
22
+ mode: 'single',
23
+ value: 'null',
24
+ }}
25
+ placement='bottom-end'
26
+ size='s'
27
+ >
28
+ <ButtonOutline {...button} icon={<KebabSVG />} appearance='neutral' />
29
+ </AdaptiveDroplist>
30
+ );
31
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonKebab';
@@ -0,0 +1 @@
1
+ export * from './Actions';
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './components';