@cloud-ru/ds-uikit-product-quota 2.1.7 → 2.1.8-preview-705f2ada.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.
Files changed (39) hide show
  1. package/README.md +4 -0
  2. package/dist/cjs/components/QuotaWidgetCard/QuotaWidgetCard.js +8 -0
  3. package/dist/cjs/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.js +3 -0
  4. package/dist/cjs/components/QuotaWidgetCard/styles.module.css +13 -0
  5. package/dist/cjs/locale/index.d.ts +24 -0
  6. package/dist/cjs/locale/index.js +12 -0
  7. package/dist/cjs/style.css +13 -0
  8. package/dist/cjs/types.d.ts +2 -0
  9. package/dist/cjs/utils/binaryQuota.d.ts +5 -0
  10. package/dist/cjs/utils/binaryQuota.js +18 -0
  11. package/dist/cjs/utils/checkIsExceeded.js +2 -1
  12. package/dist/cjs/utils/getPercent.js +4 -0
  13. package/dist/cjs/utils/index.d.ts +1 -0
  14. package/dist/cjs/utils/index.js +1 -0
  15. package/dist/esm/components/QuotaWidgetCard/QuotaWidgetCard.js +9 -1
  16. package/dist/esm/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.js +3 -0
  17. package/dist/esm/components/QuotaWidgetCard/styles.module.css +13 -0
  18. package/dist/esm/locale/index.d.ts +24 -0
  19. package/dist/esm/locale/index.js +12 -0
  20. package/dist/esm/style.css +13 -0
  21. package/dist/esm/types.d.ts +2 -0
  22. package/dist/esm/utils/binaryQuota.d.ts +5 -0
  23. package/dist/esm/utils/binaryQuota.js +14 -0
  24. package/dist/esm/utils/checkIsExceeded.js +2 -1
  25. package/dist/esm/utils/getPercent.js +4 -0
  26. package/dist/esm/utils/index.d.ts +1 -0
  27. package/dist/esm/utils/index.js +1 -0
  28. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  29. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  30. package/package.json +18 -18
  31. package/src/components/QuotaWidgetCard/QuotaWidgetCard.tsx +26 -1
  32. package/src/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.tsx +10 -0
  33. package/src/components/QuotaWidgetCard/styles.module.scss +10 -0
  34. package/src/locale/index.ts +12 -0
  35. package/src/types.ts +2 -0
  36. package/src/utils/binaryQuota.ts +17 -0
  37. package/src/utils/checkIsExceeded.ts +3 -1
  38. package/src/utils/getPercent.ts +5 -0
  39. package/src/utils/index.ts +1 -0
package/README.md CHANGED
@@ -190,6 +190,7 @@ export function QuotaWidgetError() {
190
190
 
191
191
  | Prop | Type | Default | Description |
192
192
  |------|------|---------|-------------|
193
+ | `isBinary` | `boolean \| undefined` | — | Бинарная квота: limit 1/0/-1 отображается как статус |
193
194
  | `limit` | `number` | — | Лимит квоты |
194
195
  | `name` | `string` | — | Название квоты |
195
196
  | `remains` | `number` | — | Остаток квоты |
@@ -224,6 +225,7 @@ export function QuotaWidgetError() {
224
225
 
225
226
  | Prop | Type | Default | Description |
226
227
  |------|------|---------|-------------|
228
+ | `isBinary` | `boolean \| undefined` | — | Бинарная квота: limit 1/0/-1 отображается как статус |
227
229
  | `limit` | `number` | — | Лимит квоты |
228
230
  | `name` | `string` | — | Название квоты |
229
231
  | `remains` | `number` | — | Остаток квоты |
@@ -327,6 +329,7 @@ export function QuotaWidgetMiniExpanded() {
327
329
 
328
330
  | Prop | Type | Default | Description |
329
331
  |------|------|---------|-------------|
332
+ | `isBinary` | `boolean \| undefined` | — | Бинарная квота: limit 1/0/-1 отображается как статус |
330
333
  | `limit` | `number` | — | Лимит квоты |
331
334
  | `name` | `string` | — | Название квоты |
332
335
  | `remains` | `number` | — | Остаток квоты |
@@ -445,6 +448,7 @@ export function QuotaCardNoData() {
445
448
 
446
449
  | Prop | Type | Default | Description |
447
450
  |------|------|---------|-------------|
451
+ | `isBinary` | `boolean \| undefined` | — | Бинарная квота: limit 1/0/-1 отображается как статус |
448
452
  | `limit` | `number` | — | Лимит квоты |
449
453
  | `name` | `string` | — | Название квоты |
450
454
  | `remains` | `number` | — | Остаток квоты |
@@ -40,6 +40,14 @@ function QuotaWidgetCard({ quota, noData = false, loading = false, onRefresh, ..
40
40
  if (loading) {
41
41
  return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.card, "data-loading": true, ...props, children: [(0, jsx_runtime_1.jsx)(skeleton_1.SkeletonText, { loading: true, lines: 1, variant: 'body', size: 'm', width: '50%' }), (0, jsx_runtime_1.jsx)(skeleton_1.SkeletonText, { loading: true, lines: 1, variant: 'body', size: 'm' }), (0, jsx_runtime_1.jsx)(skeleton_1.SkeletonText, { loading: true, lines: 1, variant: 'body', size: 'l' })] }));
42
42
  }
43
+ if (quota.isBinary) {
44
+ const status = (0, utils_1.getBinaryQuotaStatus)(quota.limit);
45
+ const content = ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.card, "data-binary": true, ...props, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 'm', className: styles_module_scss_1.default.title, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 2, text: quota.name }) }), (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.binaryStatus, "data-status": status, children: t(`binaryStatus.${status}`) })] }));
46
+ if (status !== 'denied') {
47
+ return content;
48
+ }
49
+ return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { triggerClassName: styles_module_scss_1.default.tooltip, hoverDelayOpen: 500, tip: (0, jsx_runtime_1.jsx)(QuotaTooltip_1.QuotaTooltip, { quota: quota }), children: content }));
50
+ }
43
51
  const percent = (0, utils_1.getPercent)(quota);
44
52
  const rows = [
45
53
  {
@@ -13,6 +13,9 @@ const utils_1 = require("../../../../utils");
13
13
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
14
14
  function QuotaTooltip({ quota }) {
15
15
  const { t } = locale_1.quotaLocale.useTranslations();
16
+ if (quota.isBinary) {
17
+ return ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.content, "data-test-id": constants_1.TEST_IDS.quotaWidgetCard.tooltip, children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: 'body', size: 's', children: t('tooltipBinaryHint') }) }));
18
+ }
16
19
  const rows = [
17
20
  { label: t('tooltipAvailable'), value: quota.limit },
18
21
  { label: t('tooltipUsed'), value: quota.usage },
@@ -101,4 +101,17 @@
101
101
  letter-spacing:var(--sn-thin-label-l-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
102
102
  paragraph-spacing:var(--sn-thin-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
103
103
  color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
104
+ }
105
+
106
+ .binaryStatus{
107
+ font-family:var(--sn-thin-label-m-fontFamily, var(--sn-brand-font-fontFamily-thin-label, SB Sans Text));
108
+ font-weight:var(--sn-thin-label-m-fontWeight, var(--sn-theme-typography-fontWeight-thin-label-m, var(--sn-brand-font-fontWeight-light-thin-label-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
109
+ line-height:var(--sn-thin-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-platform-comfort-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-20, 20px))));
110
+ font-size:var(--sn-thin-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-platform-comfort-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-14, 14px))));
111
+ letter-spacing:var(--sn-thin-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
112
+ paragraph-spacing:var(--sn-thin-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
113
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
114
+ }
115
+ .binaryStatus[data-status=allowed]{
116
+ color:var(--sn-theme-color-green-text, var(--sn-brand-palette-green-40, #438b4b));
104
117
  }
@@ -19,6 +19,12 @@ declare const QUOTA_MESSAGES: {
19
19
  };
20
20
  readonly errorText: "Failed to load data";
21
21
  readonly errorButton: "Refresh";
22
+ readonly binaryStatus: {
23
+ readonly allowed: "Can be used";
24
+ readonly denied: "Cannot be used";
25
+ readonly unset: "Not set";
26
+ };
27
+ readonly tooltipBinaryHint: "To change the quota, contact the quota or organization administrator";
22
28
  };
23
29
  readonly 'ru-RU': {
24
30
  readonly quotas: "Квоты";
@@ -40,6 +46,12 @@ declare const QUOTA_MESSAGES: {
40
46
  };
41
47
  readonly errorText: "Не удалось загрузить данные";
42
48
  readonly errorButton: "Обновить";
49
+ readonly binaryStatus: {
50
+ readonly allowed: "Можно использовать";
51
+ readonly denied: "Нельзя использовать";
52
+ readonly unset: "Не установлено";
53
+ };
54
+ readonly tooltipBinaryHint: "Чтобы изменить квоту, обратитесь к администратору квот или организации";
43
55
  };
44
56
  };
45
57
  export type QuotaMessages = (typeof QUOTA_MESSAGES)['en-GB'];
@@ -65,6 +77,12 @@ export declare const quotaLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
65
77
  };
66
78
  readonly errorText: "Failed to load data";
67
79
  readonly errorButton: "Refresh";
80
+ readonly binaryStatus: {
81
+ readonly allowed: "Can be used";
82
+ readonly denied: "Cannot be used";
83
+ readonly unset: "Not set";
84
+ };
85
+ readonly tooltipBinaryHint: "To change the quota, contact the quota or organization administrator";
68
86
  };
69
87
  readonly 'ru-RU': {
70
88
  readonly quotas: "Квоты";
@@ -86,6 +104,12 @@ export declare const quotaLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
86
104
  };
87
105
  readonly errorText: "Не удалось загрузить данные";
88
106
  readonly errorButton: "Обновить";
107
+ readonly binaryStatus: {
108
+ readonly allowed: "Можно использовать";
109
+ readonly denied: "Нельзя использовать";
110
+ readonly unset: "Не установлено";
111
+ };
112
+ readonly tooltipBinaryHint: "Чтобы изменить квоту, обратитесь к администратору квот или организации";
89
113
  };
90
114
  }, "@cloud-ru/ds-uikit-product-quota">;
91
115
  export {};
@@ -23,6 +23,12 @@ const QUOTA_MESSAGES = (0, locale_1.defineMessages)({
23
23
  },
24
24
  errorText: 'Failed to load data',
25
25
  errorButton: 'Refresh',
26
+ binaryStatus: {
27
+ allowed: 'Can be used',
28
+ denied: 'Cannot be used',
29
+ unset: 'Not set',
30
+ },
31
+ tooltipBinaryHint: 'To change the quota, contact the quota or organization administrator',
26
32
  },
27
33
  'ru-RU': {
28
34
  quotas: 'Квоты',
@@ -44,6 +50,12 @@ const QUOTA_MESSAGES = (0, locale_1.defineMessages)({
44
50
  },
45
51
  errorText: 'Не удалось загрузить данные',
46
52
  errorButton: 'Обновить',
53
+ binaryStatus: {
54
+ allowed: 'Можно использовать',
55
+ denied: 'Нельзя использовать',
56
+ unset: 'Не установлено',
57
+ },
58
+ tooltipBinaryHint: 'Чтобы изменить квоту, обратитесь к администратору квот или организации',
47
59
  },
48
60
  });
49
61
  /** locale компонента Quota: `quotaLocale.useTranslations()` в коде, `quotaLocale.extend(...)` в сервисе. */
@@ -222,6 +222,19 @@
222
222
  paragraph-spacing:var(--sn-thin-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
223
223
  color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
224
224
  }
225
+
226
+ .binaryStatus{
227
+ font-family:var(--sn-thin-label-m-fontFamily, var(--sn-brand-font-fontFamily-thin-label, SB Sans Text));
228
+ font-weight:var(--sn-thin-label-m-fontWeight, var(--sn-theme-typography-fontWeight-thin-label-m, var(--sn-brand-font-fontWeight-light-thin-label-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
229
+ line-height:var(--sn-thin-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-platform-comfort-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-20, 20px))));
230
+ font-size:var(--sn-thin-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-platform-comfort-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-14, 14px))));
231
+ letter-spacing:var(--sn-thin-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
232
+ paragraph-spacing:var(--sn-thin-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
233
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
234
+ }
235
+ .binaryStatus[data-status=allowed]{
236
+ color:var(--sn-theme-color-green-text, var(--sn-brand-palette-green-40, #438b4b));
237
+ }
225
238
  .collapse{
226
239
  width:304px;
227
240
  }
@@ -9,6 +9,8 @@ export type QuotaItem = {
9
9
  remains: number;
10
10
  /** Единица измерения квоты */
11
11
  unitDisplayName: string;
12
+ /** Бинарная квота: limit 1/0/-1 отображается как статус */
13
+ isBinary?: boolean;
12
14
  };
13
15
  export type QuotaWidgetPropsBase = {
14
16
  /** Список квот для отображения */
@@ -0,0 +1,5 @@
1
+ export declare const BINARY_QUOTA_ALLOWED = 1;
2
+ export declare const BINARY_QUOTA_DENIED = 0;
3
+ export declare const BINARY_QUOTA_UNSET = -1;
4
+ export type BinaryQuotaStatus = 'allowed' | 'denied' | 'unset';
5
+ export declare function getBinaryQuotaStatus(limit: number): BinaryQuotaStatus;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BINARY_QUOTA_UNSET = exports.BINARY_QUOTA_DENIED = exports.BINARY_QUOTA_ALLOWED = void 0;
4
+ exports.getBinaryQuotaStatus = getBinaryQuotaStatus;
5
+ exports.BINARY_QUOTA_ALLOWED = 1;
6
+ exports.BINARY_QUOTA_DENIED = 0;
7
+ exports.BINARY_QUOTA_UNSET = -1;
8
+ function getBinaryQuotaStatus(limit) {
9
+ switch (limit) {
10
+ case exports.BINARY_QUOTA_ALLOWED:
11
+ return 'allowed';
12
+ case exports.BINARY_QUOTA_DENIED:
13
+ return 'denied';
14
+ case exports.BINARY_QUOTA_UNSET:
15
+ default:
16
+ return 'unset';
17
+ }
18
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkIsExceeded = void 0;
4
- const checkIsExceeded = (quota) => quota.remains <= 0;
4
+ const binaryQuota_1 = require("./binaryQuota");
5
+ const checkIsExceeded = (quota) => quota.isBinary ? quota.limit === binaryQuota_1.BINARY_QUOTA_DENIED : quota.remains <= 0;
5
6
  exports.checkIsExceeded = checkIsExceeded;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPercent = getPercent;
4
+ const binaryQuota_1 = require("./binaryQuota");
4
5
  function getPercent(quota) {
6
+ if (quota.isBinary) {
7
+ return quota.limit === binaryQuota_1.BINARY_QUOTA_DENIED ? 100 : 0;
8
+ }
5
9
  if (quota.limit === 0) {
6
10
  return 100;
7
11
  }
@@ -1,3 +1,4 @@
1
+ export * from './binaryQuota';
1
2
  export * from './checkIsExceeded';
2
3
  export * from './formatNumber';
3
4
  export * from './getPercent';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./binaryQuota"), exports);
17
18
  __exportStar(require("./checkIsExceeded"), exports);
18
19
  __exportStar(require("./formatNumber"), exports);
19
20
  __exportStar(require("./getPercent"), exports);
@@ -8,7 +8,7 @@ import { Tooltip } from '@cloud-ru/ds-tooltip';
8
8
  import { TruncateString } from '@cloud-ru/ds-truncate-string';
9
9
  import { Typography } from '@cloud-ru/ds-typography';
10
10
  import { quotaLocale } from '../../locale/index.js';
11
- import { checkIsExceeded, formatNumber, getPercent } from '../../utils/index.js';
11
+ import { checkIsExceeded, formatNumber, getBinaryQuotaStatus, getPercent } from '../../utils/index.js';
12
12
  import { QuotaTooltip } from './components/QuotaTooltip/index.js';
13
13
  import styles from './styles.module.css';
14
14
  const QUOTA_USAGE_PROGRESS = {
@@ -34,6 +34,14 @@ export function QuotaWidgetCard({ quota, noData = false, loading = false, onRefr
34
34
  if (loading) {
35
35
  return (_jsxs("div", { className: styles.card, "data-loading": true, ...props, children: [_jsx(SkeletonText, { loading: true, lines: 1, variant: 'body', size: 'm', width: '50%' }), _jsx(SkeletonText, { loading: true, lines: 1, variant: 'body', size: 'm' }), _jsx(SkeletonText, { loading: true, lines: 1, variant: 'body', size: 'l' })] }));
36
36
  }
37
+ if (quota.isBinary) {
38
+ const status = getBinaryQuotaStatus(quota.limit);
39
+ const content = (_jsxs("div", { className: styles.card, "data-binary": true, ...props, children: [_jsx(Typography, { variant: 'body', size: 'm', className: styles.title, children: _jsx(TruncateString, { maxLines: 2, text: quota.name }) }), _jsx("span", { className: styles.binaryStatus, "data-status": status, children: t(`binaryStatus.${status}`) })] }));
40
+ if (status !== 'denied') {
41
+ return content;
42
+ }
43
+ return (_jsx(Tooltip, { triggerClassName: styles.tooltip, hoverDelayOpen: 500, tip: _jsx(QuotaTooltip, { quota: quota }), children: content }));
44
+ }
37
45
  const percent = getPercent(quota);
38
46
  const rows = [
39
47
  {
@@ -7,6 +7,9 @@ import { checkIsExceeded, formatNumber } from '../../../../utils/index.js';
7
7
  import styles from './styles.module.css';
8
8
  export function QuotaTooltip({ quota }) {
9
9
  const { t } = quotaLocale.useTranslations();
10
+ if (quota.isBinary) {
11
+ return (_jsx("div", { className: styles.content, "data-test-id": TEST_IDS.quotaWidgetCard.tooltip, children: _jsx(Typography, { variant: 'body', size: 's', children: t('tooltipBinaryHint') }) }));
12
+ }
10
13
  const rows = [
11
14
  { label: t('tooltipAvailable'), value: quota.limit },
12
15
  { label: t('tooltipUsed'), value: quota.usage },
@@ -101,4 +101,17 @@
101
101
  letter-spacing:var(--sn-thin-label-l-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
102
102
  paragraph-spacing:var(--sn-thin-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
103
103
  color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
104
+ }
105
+
106
+ .binaryStatus{
107
+ font-family:var(--sn-thin-label-m-fontFamily, var(--sn-brand-font-fontFamily-thin-label, SB Sans Text));
108
+ font-weight:var(--sn-thin-label-m-fontWeight, var(--sn-theme-typography-fontWeight-thin-label-m, var(--sn-brand-font-fontWeight-light-thin-label-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
109
+ line-height:var(--sn-thin-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-platform-comfort-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-20, 20px))));
110
+ font-size:var(--sn-thin-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-platform-comfort-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-14, 14px))));
111
+ letter-spacing:var(--sn-thin-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
112
+ paragraph-spacing:var(--sn-thin-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
113
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
114
+ }
115
+ .binaryStatus[data-status=allowed]{
116
+ color:var(--sn-theme-color-green-text, var(--sn-brand-palette-green-40, #438b4b));
104
117
  }
@@ -19,6 +19,12 @@ declare const QUOTA_MESSAGES: {
19
19
  };
20
20
  readonly errorText: "Failed to load data";
21
21
  readonly errorButton: "Refresh";
22
+ readonly binaryStatus: {
23
+ readonly allowed: "Can be used";
24
+ readonly denied: "Cannot be used";
25
+ readonly unset: "Not set";
26
+ };
27
+ readonly tooltipBinaryHint: "To change the quota, contact the quota or organization administrator";
22
28
  };
23
29
  readonly 'ru-RU': {
24
30
  readonly quotas: "Квоты";
@@ -40,6 +46,12 @@ declare const QUOTA_MESSAGES: {
40
46
  };
41
47
  readonly errorText: "Не удалось загрузить данные";
42
48
  readonly errorButton: "Обновить";
49
+ readonly binaryStatus: {
50
+ readonly allowed: "Можно использовать";
51
+ readonly denied: "Нельзя использовать";
52
+ readonly unset: "Не установлено";
53
+ };
54
+ readonly tooltipBinaryHint: "Чтобы изменить квоту, обратитесь к администратору квот или организации";
43
55
  };
44
56
  };
45
57
  export type QuotaMessages = (typeof QUOTA_MESSAGES)['en-GB'];
@@ -65,6 +77,12 @@ export declare const quotaLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
65
77
  };
66
78
  readonly errorText: "Failed to load data";
67
79
  readonly errorButton: "Refresh";
80
+ readonly binaryStatus: {
81
+ readonly allowed: "Can be used";
82
+ readonly denied: "Cannot be used";
83
+ readonly unset: "Not set";
84
+ };
85
+ readonly tooltipBinaryHint: "To change the quota, contact the quota or organization administrator";
68
86
  };
69
87
  readonly 'ru-RU': {
70
88
  readonly quotas: "Квоты";
@@ -86,6 +104,12 @@ export declare const quotaLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
86
104
  };
87
105
  readonly errorText: "Не удалось загрузить данные";
88
106
  readonly errorButton: "Обновить";
107
+ readonly binaryStatus: {
108
+ readonly allowed: "Можно использовать";
109
+ readonly denied: "Нельзя использовать";
110
+ readonly unset: "Не установлено";
111
+ };
112
+ readonly tooltipBinaryHint: "Чтобы изменить квоту, обратитесь к администратору квот или организации";
89
113
  };
90
114
  }, "@cloud-ru/ds-uikit-product-quota">;
91
115
  export {};
@@ -20,6 +20,12 @@ const QUOTA_MESSAGES = defineMessages({
20
20
  },
21
21
  errorText: 'Failed to load data',
22
22
  errorButton: 'Refresh',
23
+ binaryStatus: {
24
+ allowed: 'Can be used',
25
+ denied: 'Cannot be used',
26
+ unset: 'Not set',
27
+ },
28
+ tooltipBinaryHint: 'To change the quota, contact the quota or organization administrator',
23
29
  },
24
30
  'ru-RU': {
25
31
  quotas: 'Квоты',
@@ -41,6 +47,12 @@ const QUOTA_MESSAGES = defineMessages({
41
47
  },
42
48
  errorText: 'Не удалось загрузить данные',
43
49
  errorButton: 'Обновить',
50
+ binaryStatus: {
51
+ allowed: 'Можно использовать',
52
+ denied: 'Нельзя использовать',
53
+ unset: 'Не установлено',
54
+ },
55
+ tooltipBinaryHint: 'Чтобы изменить квоту, обратитесь к администратору квот или организации',
44
56
  },
45
57
  });
46
58
  /** locale компонента Quota: `quotaLocale.useTranslations()` в коде, `quotaLocale.extend(...)` в сервисе. */
@@ -222,6 +222,19 @@
222
222
  paragraph-spacing:var(--sn-thin-label-l-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
223
223
  color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
224
224
  }
225
+
226
+ .binaryStatus{
227
+ font-family:var(--sn-thin-label-m-fontFamily, var(--sn-brand-font-fontFamily-thin-label, SB Sans Text));
228
+ font-weight:var(--sn-thin-label-m-fontWeight, var(--sn-theme-typography-fontWeight-thin-label-m, var(--sn-brand-font-fontWeight-light-thin-label-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
229
+ line-height:var(--sn-thin-label-m-lineHeight, var(--sn-density-typography-roleLabel-lineHeightM, var(--sn-platform-comfort-typography-roleLabel-lineHeightM, var(--sn-primitive-font-lineHeight-20, 20px))));
230
+ font-size:var(--sn-thin-label-m-fontSize, var(--sn-density-typography-roleLabel-fontSizeM, var(--sn-platform-comfort-typography-roleLabel-fontSizeM, var(--sn-primitive-font-fontSize-14, 14px))));
231
+ letter-spacing:var(--sn-thin-label-m-letterSpacing, var(--sn-primitive-font-letterSpacing-s, 0px));
232
+ paragraph-spacing:var(--sn-thin-label-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize12, 6px));
233
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(0, 0, 0, 0.5803921569)));
234
+ }
235
+ .binaryStatus[data-status=allowed]{
236
+ color:var(--sn-theme-color-green-text, var(--sn-brand-palette-green-40, #438b4b));
237
+ }
225
238
  .collapse{
226
239
  width:304px;
227
240
  }
@@ -9,6 +9,8 @@ export type QuotaItem = {
9
9
  remains: number;
10
10
  /** Единица измерения квоты */
11
11
  unitDisplayName: string;
12
+ /** Бинарная квота: limit 1/0/-1 отображается как статус */
13
+ isBinary?: boolean;
12
14
  };
13
15
  export type QuotaWidgetPropsBase = {
14
16
  /** Список квот для отображения */
@@ -0,0 +1,5 @@
1
+ export declare const BINARY_QUOTA_ALLOWED = 1;
2
+ export declare const BINARY_QUOTA_DENIED = 0;
3
+ export declare const BINARY_QUOTA_UNSET = -1;
4
+ export type BinaryQuotaStatus = 'allowed' | 'denied' | 'unset';
5
+ export declare function getBinaryQuotaStatus(limit: number): BinaryQuotaStatus;
@@ -0,0 +1,14 @@
1
+ export const BINARY_QUOTA_ALLOWED = 1;
2
+ export const BINARY_QUOTA_DENIED = 0;
3
+ export const BINARY_QUOTA_UNSET = -1;
4
+ export function getBinaryQuotaStatus(limit) {
5
+ switch (limit) {
6
+ case BINARY_QUOTA_ALLOWED:
7
+ return 'allowed';
8
+ case BINARY_QUOTA_DENIED:
9
+ return 'denied';
10
+ case BINARY_QUOTA_UNSET:
11
+ default:
12
+ return 'unset';
13
+ }
14
+ }
@@ -1 +1,2 @@
1
- export const checkIsExceeded = (quota) => quota.remains <= 0;
1
+ import { BINARY_QUOTA_DENIED } from './binaryQuota.js';
2
+ export const checkIsExceeded = (quota) => quota.isBinary ? quota.limit === BINARY_QUOTA_DENIED : quota.remains <= 0;
@@ -1,4 +1,8 @@
1
+ import { BINARY_QUOTA_DENIED } from './binaryQuota.js';
1
2
  export function getPercent(quota) {
3
+ if (quota.isBinary) {
4
+ return quota.limit === BINARY_QUOTA_DENIED ? 100 : 0;
5
+ }
2
6
  if (quota.limit === 0) {
3
7
  return 100;
4
8
  }
@@ -1,3 +1,4 @@
1
+ export * from './binaryQuota.js';
1
2
  export * from './checkIsExceeded.js';
2
3
  export * from './formatNumber.js';
3
4
  export * from './getPercent.js';
@@ -1,3 +1,4 @@
1
+ export * from './binaryQuota.js';
1
2
  export * from './checkIsExceeded.js';
2
3
  export * from './formatNumber.js';
3
4
  export * from './getPercent.js';