@cloud-ru/uikit-product-mobile-layout 2.0.20 → 2.1.0

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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 2.1.0 (2026-04-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * **LK-7542:** quota widget update ([e8ee44b](https://github.com/cloud-ru-tech/uikit-product/commit/e8ee44b30a8a6309409b6af307b87a81945d883a))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 2.0.20 (2026-04-14)
7
18
 
8
19
 
@@ -14,13 +14,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.ActionView = ActionView;
15
15
  const jsx_runtime_1 = require("react/jsx-runtime");
16
16
  const uikit_product_mobile_tooltip_1 = require("@cloud-ru/uikit-product-mobile-tooltip");
17
- const uikit_product_quota_1 = require("@cloud-ru/uikit-product-quota");
18
17
  const button_1 = require("@snack-uikit/button");
19
18
  const ButtonDropdown_1 = require("../ButtonDropdown");
20
19
  const ButtonDroplist_1 = require("../ButtonDroplist");
21
20
  const ButtonKebab_1 = require("../ButtonKebab");
21
+ const ButtonQuota_1 = require("../ButtonQuota");
22
22
  const constants_1 = require("./constants");
23
23
  function ActionView(_a) {
24
+ var _b;
24
25
  var { variant, tooltip, hidden = false, layoutType, commonProps } = _a, buttonProps = __rest(_a, ["variant", "tooltip", "hidden", "layoutType", "commonProps"]);
25
26
  if (hidden) {
26
27
  return null;
@@ -50,7 +51,7 @@ function ActionView(_a) {
50
51
  return addTooltip((0, jsx_runtime_1.jsx)(ButtonDroplist_1.ButtonDroplist, { button: Object.assign(Object.assign({}, button), commonProps), list: list, layoutType: layoutType }));
51
52
  }
52
53
  case constants_1.BUTTON_TYPE.Quota: {
53
- return addTooltip((0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaDropdown, Object.assign({}, buttonProps, commonProps, { layoutType: layoutType })));
54
+ return addTooltip((0, jsx_runtime_1.jsx)(ButtonQuota_1.ButtonQuota, Object.assign({}, buttonProps, { buttonProps: (_b = buttonProps.buttonProps) !== null && _b !== void 0 ? _b : commonProps, layoutType: layoutType })));
54
55
  }
55
56
  default:
56
57
  return null;
@@ -13,7 +13,6 @@ const uikit_product_mobile_dropdown_1 = require("@cloud-ru/uikit-product-mobile-
13
13
  const uikit_product_mobile_tooltip_1 = require("@cloud-ru/uikit-product-mobile-tooltip");
14
14
  const uikit_product_quota_1 = require("@cloud-ru/uikit-product-quota");
15
15
  const button_1 = require("@snack-uikit/button");
16
- const counter_1 = require("@snack-uikit/counter");
17
16
  const utils_1 = require("@snack-uikit/utils");
18
17
  const ActionView_1 = require("./ActionView");
19
18
  const constants_1 = require("./constants");
@@ -22,8 +21,9 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
22
21
  function MobileActions({ items, maxVisibleItems }) {
23
22
  const containerRef = (0, react_2.useRef)(null);
24
23
  const [isOpen, setIsOpen] = (0, react_2.useState)(false);
24
+ const [isQuotaWidgetOpen, setIsQuotaWidgetOpen] = (0, react_2.useState)(false);
25
25
  const { visibleItems, hiddenItems } = (0, utils_1.useDynamicList)({ parentContainerRef: containerRef, items, maxVisibleItems });
26
- const { t: tQuota } = (0, uikit_product_locale_1.useLocale)('Quota');
26
+ const { t: tQuota } = (0, uikit_product_locale_1.useLocale)('MobileLayout');
27
27
  if (!(0, helpers_1.hasVisibleActions)(items)) {
28
28
  return null;
29
29
  }
@@ -45,21 +45,11 @@ function MobileActions({ items, maxVisibleItems }) {
45
45
  break;
46
46
  }
47
47
  case constants_1.BUTTON_TYPE.Quota: {
48
- const quotaExceededCount = react_2.Children.toArray(action.children).reduce((count, child) => {
49
- var _a, _b, _c, _d, _e, _f;
50
- return (0, react_2.isValidElement)(child) &&
51
- !((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.loading) &&
52
- !((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.unlimited) &&
53
- (0, uikit_product_quota_1.checkExceeded)(((_d = (_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.limit) !== null && _d !== void 0 ? _d : 0) - ((_f = (_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.created) !== null && _f !== void 0 ? _f : 0))
54
- ? count + 1
55
- : count;
56
- }, 0);
57
- const isQuotaExceededCountVisible = !action.dataError && quotaExceededCount > 0;
58
48
  acc.push(Object.assign(Object.assign({}, action), { type: 'group', divider: acc.length > 0, items: [
59
49
  Object.assign(Object.assign({}, action), { content: {
60
50
  option: tQuota('quotas'),
61
- }, afterContent: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isQuotaExceededCountVisible && ((0, jsx_runtime_1.jsx)(counter_1.Counter, { value: quotaExceededCount, appearance: 'red', size: 'm' })), (0, jsx_runtime_1.jsx)(uikit_product_icons_1.ChevronDownSVG, {})] })), itemWrapRender: item => {
62
- const content = ((0, jsx_runtime_1.jsx)(uikit_product_mobile_dropdown_1.AdaptiveDropdown, { content: (0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaDropdownContent, Object.assign({}, action)), layoutType: 'mobile', children: item }));
51
+ }, onClick: () => setIsQuotaWidgetOpen(prev => !prev), itemWrapRender: item => {
52
+ const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [item, (0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaWidgetMobile, Object.assign({}, action, { isOpen: isQuotaWidgetOpen, onClose: () => setIsQuotaWidgetOpen(false) }))] }));
63
53
  return action.tooltip ? ((0, jsx_runtime_1.jsx)(uikit_product_mobile_tooltip_1.MobileTooltip, Object.assign({}, action.tooltip, { children: content }))) : (content);
64
54
  } }),
65
55
  ] }));
@@ -1,14 +1,14 @@
1
1
  import { TooltipProps } from '@cloud-ru/uikit-product-mobile-tooltip';
2
- import { QuotaDropdownProps } from '@cloud-ru/uikit-product-quota';
3
2
  import { ButtonFilledProps, ButtonFunctionProps, ButtonOutlineProps, ButtonSimpleProps, ButtonTonalProps } from '@snack-uikit/button';
4
3
  import { ButtonDropdownProps } from '../ButtonDropdown';
5
4
  import { ButtonDroplistProps } from '../ButtonDroplist';
6
5
  import { ButtonKebabProps } from '../ButtonKebab';
6
+ import { ButtonQuotaProps } from '../ButtonQuota';
7
7
  import { BUTTON_TYPE } from './constants';
8
8
  type ButtonDropdownPropsWithoutLayout = Omit<ButtonDropdownProps, 'layoutType'>;
9
9
  type ButtonKebabPropsWithoutLayout = Omit<ButtonKebabProps, 'layoutType'>;
10
10
  type ButtonDroplistWithoutLayout = Omit<ButtonDroplistProps, 'layoutType'>;
11
- type ButtonQuotaDropdownWithoutLayout = Omit<QuotaDropdownProps, 'layoutType'>;
11
+ type ButtonQuotaDropdownWithoutLayout = Omit<ButtonQuotaProps, 'layoutType'>;
12
12
  export type Action = {
13
13
  tooltip?: TooltipProps;
14
14
  hidden?: boolean;
@@ -0,0 +1,4 @@
1
+ import { QuotaWidgetMobileProps, QuotaWidgetProps } from '@cloud-ru/uikit-product-quota';
2
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
3
+ export type ButtonQuotaProps = WithLayoutType<Omit<QuotaWidgetProps, 'buttonProps'> | Omit<QuotaWidgetMobileProps, 'isOpen' | 'onClose'>> & Pick<QuotaWidgetProps, 'buttonProps'>;
4
+ export declare function ButtonQuota({ layoutType, buttonProps, ...props }: ButtonQuotaProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ButtonQuota = ButtonQuota;
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
16
+ const react_1 = require("react");
17
+ const uikit_product_icons_1 = require("@cloud-ru/uikit-product-icons");
18
+ const uikit_product_locale_1 = require("@cloud-ru/uikit-product-locale");
19
+ const uikit_product_quota_1 = require("@cloud-ru/uikit-product-quota");
20
+ const button_1 = require("@snack-uikit/button");
21
+ function ButtonQuota(_a) {
22
+ var { layoutType, buttonProps } = _a, props = __rest(_a, ["layoutType", "buttonProps"]);
23
+ const { t } = (0, uikit_product_locale_1.useLocale)('MobileLayout');
24
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
25
+ const exhaustedCount = props.quotas.filter(item => item.remains === 0).length;
26
+ if (layoutType === 'mobile') {
27
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(button_1.ButtonFunction, Object.assign({ label: t('quotas'), icon: isOpen ? (0, jsx_runtime_1.jsx)(uikit_product_icons_1.ChevronUpSVG, {}) : (0, jsx_runtime_1.jsx)(uikit_product_icons_1.ChevronDownSVG, {}), counter: exhaustedCount > 0
28
+ ? {
29
+ value: exhaustedCount,
30
+ appearance: 'red',
31
+ }
32
+ : undefined, size: 'm' }, buttonProps, { onClick: () => setIsOpen(prev => !prev) })), (0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaWidgetMobile, Object.assign({}, props, { isOpen: isOpen, onClose: () => setIsOpen(false) }))] }));
33
+ }
34
+ return (0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaWidget, Object.assign({}, props, { buttonProps: Object.assign({ size: 'm' }, buttonProps) }));
35
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonQuota';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ButtonQuota"), exports);
@@ -11,13 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { AdaptiveTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
14
- import { QuotaDropdown } from '@cloud-ru/uikit-product-quota';
15
14
  import { ButtonFilled, ButtonFunction, ButtonOutline, ButtonSimple, ButtonTonal, } from '@snack-uikit/button';
16
15
  import { ButtonDropdown } from '../ButtonDropdown';
17
16
  import { ButtonDroplist } from '../ButtonDroplist';
18
17
  import { ButtonKebab } from '../ButtonKebab';
18
+ import { ButtonQuota } from '../ButtonQuota';
19
19
  import { BUTTON_TYPE } from './constants';
20
20
  export function ActionView(_a) {
21
+ var _b;
21
22
  var { variant, tooltip, hidden = false, layoutType, commonProps } = _a, buttonProps = __rest(_a, ["variant", "tooltip", "hidden", "layoutType", "commonProps"]);
22
23
  if (hidden) {
23
24
  return null;
@@ -47,7 +48,7 @@ export function ActionView(_a) {
47
48
  return addTooltip(_jsx(ButtonDroplist, { button: Object.assign(Object.assign({}, button), commonProps), list: list, layoutType: layoutType }));
48
49
  }
49
50
  case BUTTON_TYPE.Quota: {
50
- return addTooltip(_jsx(QuotaDropdown, Object.assign({}, buttonProps, commonProps, { layoutType: layoutType })));
51
+ return addTooltip(_jsx(ButtonQuota, Object.assign({}, buttonProps, { buttonProps: (_b = buttonProps.buttonProps) !== null && _b !== void 0 ? _b : commonProps, layoutType: layoutType })));
51
52
  }
52
53
  default:
53
54
  return null;
@@ -1,13 +1,12 @@
1
1
  import { createElement as _createElement } from "react";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Children, isValidElement, useRef, useState } from 'react';
3
+ import { useRef, useState } from 'react';
4
4
  import { ChevronDownSVG, KebabSVG } from '@cloud-ru/uikit-product-icons';
5
5
  import { useLocale } from '@cloud-ru/uikit-product-locale';
6
6
  import { AdaptiveDropdown, MobileDroplist } from '@cloud-ru/uikit-product-mobile-dropdown';
7
7
  import { MobileTooltip, WithMobileTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
8
- import { checkExceeded, QuotaDropdownContent } from '@cloud-ru/uikit-product-quota';
8
+ import { QuotaWidgetMobile } from '@cloud-ru/uikit-product-quota';
9
9
  import { ButtonOutline } from '@snack-uikit/button';
10
- import { Counter } from '@snack-uikit/counter';
11
10
  import { useDynamicList } from '@snack-uikit/utils';
12
11
  import { ActionView } from './ActionView';
13
12
  import { BUTTON_TYPE } from './constants';
@@ -16,8 +15,9 @@ import styles from './styles.module.css';
16
15
  export function MobileActions({ items, maxVisibleItems }) {
17
16
  const containerRef = useRef(null);
18
17
  const [isOpen, setIsOpen] = useState(false);
18
+ const [isQuotaWidgetOpen, setIsQuotaWidgetOpen] = useState(false);
19
19
  const { visibleItems, hiddenItems } = useDynamicList({ parentContainerRef: containerRef, items, maxVisibleItems });
20
- const { t: tQuota } = useLocale('Quota');
20
+ const { t: tQuota } = useLocale('MobileLayout');
21
21
  if (!hasVisibleActions(items)) {
22
22
  return null;
23
23
  }
@@ -39,21 +39,11 @@ export function MobileActions({ items, maxVisibleItems }) {
39
39
  break;
40
40
  }
41
41
  case BUTTON_TYPE.Quota: {
42
- const quotaExceededCount = Children.toArray(action.children).reduce((count, child) => {
43
- var _a, _b, _c, _d, _e, _f;
44
- return isValidElement(child) &&
45
- !((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.loading) &&
46
- !((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.unlimited) &&
47
- checkExceeded(((_d = (_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.limit) !== null && _d !== void 0 ? _d : 0) - ((_f = (_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.created) !== null && _f !== void 0 ? _f : 0))
48
- ? count + 1
49
- : count;
50
- }, 0);
51
- const isQuotaExceededCountVisible = !action.dataError && quotaExceededCount > 0;
52
42
  acc.push(Object.assign(Object.assign({}, action), { type: 'group', divider: acc.length > 0, items: [
53
43
  Object.assign(Object.assign({}, action), { content: {
54
44
  option: tQuota('quotas'),
55
- }, afterContent: (_jsxs(_Fragment, { children: [isQuotaExceededCountVisible && (_jsx(Counter, { value: quotaExceededCount, appearance: 'red', size: 'm' })), _jsx(ChevronDownSVG, {})] })), itemWrapRender: item => {
56
- const content = (_jsx(AdaptiveDropdown, { content: _jsx(QuotaDropdownContent, Object.assign({}, action)), layoutType: 'mobile', children: item }));
45
+ }, onClick: () => setIsQuotaWidgetOpen(prev => !prev), itemWrapRender: item => {
46
+ const content = (_jsxs(_Fragment, { children: [item, _jsx(QuotaWidgetMobile, Object.assign({}, action, { isOpen: isQuotaWidgetOpen, onClose: () => setIsQuotaWidgetOpen(false) }))] }));
57
47
  return action.tooltip ? (_jsx(MobileTooltip, Object.assign({}, action.tooltip, { children: content }))) : (content);
58
48
  } }),
59
49
  ] }));
@@ -1,14 +1,14 @@
1
1
  import { TooltipProps } from '@cloud-ru/uikit-product-mobile-tooltip';
2
- import { QuotaDropdownProps } from '@cloud-ru/uikit-product-quota';
3
2
  import { ButtonFilledProps, ButtonFunctionProps, ButtonOutlineProps, ButtonSimpleProps, ButtonTonalProps } from '@snack-uikit/button';
4
3
  import { ButtonDropdownProps } from '../ButtonDropdown';
5
4
  import { ButtonDroplistProps } from '../ButtonDroplist';
6
5
  import { ButtonKebabProps } from '../ButtonKebab';
6
+ import { ButtonQuotaProps } from '../ButtonQuota';
7
7
  import { BUTTON_TYPE } from './constants';
8
8
  type ButtonDropdownPropsWithoutLayout = Omit<ButtonDropdownProps, 'layoutType'>;
9
9
  type ButtonKebabPropsWithoutLayout = Omit<ButtonKebabProps, 'layoutType'>;
10
10
  type ButtonDroplistWithoutLayout = Omit<ButtonDroplistProps, 'layoutType'>;
11
- type ButtonQuotaDropdownWithoutLayout = Omit<QuotaDropdownProps, 'layoutType'>;
11
+ type ButtonQuotaDropdownWithoutLayout = Omit<ButtonQuotaProps, 'layoutType'>;
12
12
  export type Action = {
13
13
  tooltip?: TooltipProps;
14
14
  hidden?: boolean;
@@ -0,0 +1,4 @@
1
+ import { QuotaWidgetMobileProps, QuotaWidgetProps } from '@cloud-ru/uikit-product-quota';
2
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
3
+ export type ButtonQuotaProps = WithLayoutType<Omit<QuotaWidgetProps, 'buttonProps'> | Omit<QuotaWidgetMobileProps, 'isOpen' | 'onClose'>> & Pick<QuotaWidgetProps, 'buttonProps'>;
4
+ export declare function ButtonQuota({ layoutType, buttonProps, ...props }: ButtonQuotaProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useState } from 'react';
14
+ import { ChevronDownSVG, ChevronUpSVG } from '@cloud-ru/uikit-product-icons';
15
+ import { useLocale } from '@cloud-ru/uikit-product-locale';
16
+ import { QuotaWidget, QuotaWidgetMobile, } from '@cloud-ru/uikit-product-quota';
17
+ import { ButtonFunction } from '@snack-uikit/button';
18
+ export function ButtonQuota(_a) {
19
+ var { layoutType, buttonProps } = _a, props = __rest(_a, ["layoutType", "buttonProps"]);
20
+ const { t } = useLocale('MobileLayout');
21
+ const [isOpen, setIsOpen] = useState(false);
22
+ const exhaustedCount = props.quotas.filter(item => item.remains === 0).length;
23
+ if (layoutType === 'mobile') {
24
+ return (_jsxs(_Fragment, { children: [_jsx(ButtonFunction, Object.assign({ label: t('quotas'), icon: isOpen ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}), counter: exhaustedCount > 0
25
+ ? {
26
+ value: exhaustedCount,
27
+ appearance: 'red',
28
+ }
29
+ : undefined, size: 'm' }, buttonProps, { onClick: () => setIsOpen(prev => !prev) })), _jsx(QuotaWidgetMobile, Object.assign({}, props, { isOpen: isOpen, onClose: () => setIsOpen(false) }))] }));
30
+ }
31
+ return _jsx(QuotaWidget, Object.assign({}, props, { buttonProps: Object.assign({ size: 'm' }, buttonProps) }));
32
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonQuota';
@@ -0,0 +1 @@
1
+ export * from './ButtonQuota';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-mobile-layout",
3
3
  "title": "Mobile Layout",
4
- "version": "2.0.20",
4
+ "version": "2.1.0",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -43,11 +43,10 @@
43
43
  "@cloud-ru/uikit-product-mobile-modal": "2.1.2",
44
44
  "@cloud-ru/uikit-product-mobile-tooltip": "1.1.11",
45
45
  "@cloud-ru/uikit-product-page-layout": "2.1.5",
46
- "@cloud-ru/uikit-product-quota": "2.0.14",
46
+ "@cloud-ru/uikit-product-quota": "2.1.0",
47
47
  "@cloud-ru/uikit-product-utils": "9.1.0",
48
48
  "@snack-uikit/button": "0.19.7",
49
49
  "@snack-uikit/card": "0.20.18",
50
- "@snack-uikit/counter": "0.8.9",
51
50
  "@snack-uikit/icon-predefined": "0.7.3",
52
51
  "@snack-uikit/truncate-string": "0.7.11",
53
52
  "@snack-uikit/typography": "0.8.4",
@@ -57,5 +56,5 @@
57
56
  "peerDependencies": {
58
57
  "@cloud-ru/uikit-product-locale": "*"
59
58
  },
60
- "gitHead": "ce396a9b33a0db755d527f63e003c3a400484bbc"
59
+ "gitHead": "c029a007c08ef48f731f5620e17747f0cfc70179"
61
60
  }
@@ -1,7 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
 
3
3
  import { AdaptiveTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
4
- import { QuotaDropdown, QuotaDropdownProps } from '@cloud-ru/uikit-product-quota';
5
4
  import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
6
5
  import {
7
6
  ButtonFilled,
@@ -19,6 +18,7 @@ import {
19
18
  import { ButtonDropdown, ButtonDropdownProps } from '../ButtonDropdown';
20
19
  import { ButtonDroplist, ButtonDroplistProps } from '../ButtonDroplist';
21
20
  import { ButtonKebab, ButtonKebabProps } from '../ButtonKebab';
21
+ import { ButtonQuota, ButtonQuotaProps } from '../ButtonQuota';
22
22
  import { BUTTON_TYPE } from './constants';
23
23
  import { Action } from './types';
24
24
 
@@ -72,7 +72,11 @@ export function ActionView({
72
72
 
73
73
  case BUTTON_TYPE.Quota: {
74
74
  return addTooltip(
75
- <QuotaDropdown {...(buttonProps as QuotaDropdownProps)} {...commonProps} layoutType={layoutType} />,
75
+ <ButtonQuota
76
+ {...(buttonProps as ButtonQuotaProps)}
77
+ buttonProps={(buttonProps as ButtonQuotaProps).buttonProps ?? commonProps}
78
+ layoutType={layoutType}
79
+ />,
76
80
  );
77
81
  }
78
82
  default:
@@ -1,12 +1,11 @@
1
- import { Children, isValidElement, useRef, useState } from 'react';
1
+ import { useRef, useState } from 'react';
2
2
 
3
3
  import { ChevronDownSVG, KebabSVG } from '@cloud-ru/uikit-product-icons';
4
4
  import { useLocale } from '@cloud-ru/uikit-product-locale';
5
5
  import { AdaptiveDropdown, MobileDroplist, MobileDroplistProps } from '@cloud-ru/uikit-product-mobile-dropdown';
6
6
  import { MobileTooltip, WithMobileTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
7
- import { checkExceeded, QuotaCardProps, QuotaDropdownContent } from '@cloud-ru/uikit-product-quota';
7
+ import { QuotaWidgetMobile } from '@cloud-ru/uikit-product-quota';
8
8
  import { ButtonOutline } from '@snack-uikit/button';
9
- import { Counter } from '@snack-uikit/counter';
10
9
  import { useDynamicList } from '@snack-uikit/utils';
11
10
 
12
11
  import { ActionView } from './ActionView';
@@ -19,9 +18,10 @@ export function MobileActions({ items, maxVisibleItems }: ActionsProps) {
19
18
  const containerRef = useRef<HTMLDivElement>(null);
20
19
 
21
20
  const [isOpen, setIsOpen] = useState(false);
21
+ const [isQuotaWidgetOpen, setIsQuotaWidgetOpen] = useState(false);
22
22
  const { visibleItems, hiddenItems } = useDynamicList({ parentContainerRef: containerRef, items, maxVisibleItems });
23
23
 
24
- const { t: tQuota } = useLocale('Quota');
24
+ const { t: tQuota } = useLocale('MobileLayout');
25
25
 
26
26
  if (!hasVisibleActions(items)) {
27
27
  return null;
@@ -67,19 +67,6 @@ export function MobileActions({ items, maxVisibleItems }: ActionsProps) {
67
67
  break;
68
68
  }
69
69
  case BUTTON_TYPE.Quota: {
70
- const quotaExceededCount = Children.toArray(action.children).reduce<number>(
71
- (count, child) =>
72
- isValidElement<QuotaCardProps>(child) &&
73
- !child?.props?.loading &&
74
- !child?.props?.unlimited &&
75
- checkExceeded((child?.props?.limit ?? 0) - (child?.props?.created ?? 0))
76
- ? count + 1
77
- : count,
78
- 0,
79
- );
80
-
81
- const isQuotaExceededCountVisible = !action.dataError && quotaExceededCount > 0;
82
-
83
70
  acc.push({
84
71
  ...action,
85
72
  type: 'group',
@@ -90,20 +77,17 @@ export function MobileActions({ items, maxVisibleItems }: ActionsProps) {
90
77
  content: {
91
78
  option: tQuota('quotas'),
92
79
  },
93
- afterContent: (
94
- <>
95
- {isQuotaExceededCountVisible && (
96
- <Counter value={quotaExceededCount} appearance='red' size='m' />
97
- )}
98
- <ChevronDownSVG />
99
- </>
100
- ),
101
-
80
+ onClick: () => setIsQuotaWidgetOpen(prev => !prev),
102
81
  itemWrapRender: item => {
103
82
  const content = (
104
- <AdaptiveDropdown content={<QuotaDropdownContent {...action} />} layoutType='mobile'>
83
+ <>
105
84
  {item}
106
- </AdaptiveDropdown>
85
+ <QuotaWidgetMobile
86
+ {...action}
87
+ isOpen={isQuotaWidgetOpen}
88
+ onClose={() => setIsQuotaWidgetOpen(false)}
89
+ />
90
+ </>
107
91
  );
108
92
 
109
93
  return action.tooltip ? (
@@ -1,5 +1,4 @@
1
1
  import { TooltipProps } from '@cloud-ru/uikit-product-mobile-tooltip';
2
- import { QuotaDropdownProps } from '@cloud-ru/uikit-product-quota';
3
2
  import {
4
3
  ButtonFilledProps,
5
4
  ButtonFunctionProps,
@@ -11,12 +10,13 @@ import {
11
10
  import { ButtonDropdownProps } from '../ButtonDropdown';
12
11
  import { ButtonDroplistProps } from '../ButtonDroplist';
13
12
  import { ButtonKebabProps } from '../ButtonKebab';
13
+ import { ButtonQuotaProps } from '../ButtonQuota';
14
14
  import { BUTTON_TYPE } from './constants';
15
15
 
16
16
  type ButtonDropdownPropsWithoutLayout = Omit<ButtonDropdownProps, 'layoutType'>;
17
17
  type ButtonKebabPropsWithoutLayout = Omit<ButtonKebabProps, 'layoutType'>;
18
18
  type ButtonDroplistWithoutLayout = Omit<ButtonDroplistProps, 'layoutType'>;
19
- type ButtonQuotaDropdownWithoutLayout = Omit<QuotaDropdownProps, 'layoutType'>;
19
+ type ButtonQuotaDropdownWithoutLayout = Omit<ButtonQuotaProps, 'layoutType'>;
20
20
 
21
21
  export type Action = {
22
22
  tooltip?: TooltipProps;
@@ -0,0 +1,49 @@
1
+ import { useState } from 'react';
2
+
3
+ import { ChevronDownSVG, ChevronUpSVG } from '@cloud-ru/uikit-product-icons';
4
+ import { useLocale } from '@cloud-ru/uikit-product-locale';
5
+ import {
6
+ QuotaWidget,
7
+ QuotaWidgetMobile,
8
+ QuotaWidgetMobileProps,
9
+ QuotaWidgetProps,
10
+ } from '@cloud-ru/uikit-product-quota';
11
+ import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
12
+ import { ButtonFunction } from '@snack-uikit/button';
13
+
14
+ export type ButtonQuotaProps = WithLayoutType<
15
+ Omit<QuotaWidgetProps, 'buttonProps'> | Omit<QuotaWidgetMobileProps, 'isOpen' | 'onClose'>
16
+ > &
17
+ Pick<QuotaWidgetProps, 'buttonProps'>;
18
+
19
+ export function ButtonQuota({ layoutType, buttonProps, ...props }: ButtonQuotaProps) {
20
+ const { t } = useLocale('MobileLayout');
21
+ const [isOpen, setIsOpen] = useState(false);
22
+
23
+ const exhaustedCount = props.quotas.filter(item => item.remains === 0).length;
24
+
25
+ if (layoutType === 'mobile') {
26
+ return (
27
+ <>
28
+ <ButtonFunction
29
+ label={t('quotas')}
30
+ icon={isOpen ? <ChevronUpSVG /> : <ChevronDownSVG />}
31
+ counter={
32
+ exhaustedCount > 0
33
+ ? {
34
+ value: exhaustedCount,
35
+ appearance: 'red',
36
+ }
37
+ : undefined
38
+ }
39
+ size='m'
40
+ {...buttonProps}
41
+ onClick={() => setIsOpen(prev => !prev)}
42
+ />
43
+ <QuotaWidgetMobile {...(props as QuotaWidgetMobileProps)} isOpen={isOpen} onClose={() => setIsOpen(false)} />
44
+ </>
45
+ );
46
+ }
47
+
48
+ return <QuotaWidget {...(props as QuotaWidgetProps)} buttonProps={{ size: 'm', ...buttonProps }} />;
49
+ }
@@ -0,0 +1 @@
1
+ export * from './ButtonQuota';