@cloud-ru/ds-uikit-product-load-status 1.0.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 (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +155 -0
  4. package/dist/cjs/components/LoadStatus/LoadStatus.d.ts +41 -0
  5. package/dist/cjs/components/LoadStatus/LoadStatus.js +24 -0
  6. package/dist/cjs/components/LoadStatus/index.d.ts +1 -0
  7. package/dist/cjs/components/LoadStatus/index.js +17 -0
  8. package/dist/cjs/components/LoadStatus/styles.module.css +63 -0
  9. package/dist/cjs/components/index.d.ts +3 -0
  10. package/dist/cjs/components/index.js +19 -0
  11. package/dist/cjs/components/types.d.ts +16 -0
  12. package/dist/cjs/components/types.js +2 -0
  13. package/dist/cjs/components/utils/getProgressBarColor.d.ts +3 -0
  14. package/dist/cjs/components/utils/getProgressBarColor.js +24 -0
  15. package/dist/cjs/components/utils/index.d.ts +1 -0
  16. package/dist/cjs/components/utils/index.js +17 -0
  17. package/dist/cjs/constants.d.ts +30 -0
  18. package/dist/cjs/constants.js +25 -0
  19. package/dist/cjs/index.d.ts +4 -0
  20. package/dist/cjs/index.js +10 -0
  21. package/dist/cjs/package.json +3 -0
  22. package/dist/cjs/style.css +63 -0
  23. package/dist/esm/components/LoadStatus/LoadStatus.d.ts +41 -0
  24. package/dist/esm/components/LoadStatus/LoadStatus.js +18 -0
  25. package/dist/esm/components/LoadStatus/index.d.ts +1 -0
  26. package/dist/esm/components/LoadStatus/index.js +1 -0
  27. package/dist/esm/components/LoadStatus/styles.module.css +63 -0
  28. package/dist/esm/components/index.d.ts +3 -0
  29. package/dist/esm/components/index.js +3 -0
  30. package/dist/esm/components/types.d.ts +16 -0
  31. package/dist/esm/components/types.js +1 -0
  32. package/dist/esm/components/utils/getProgressBarColor.d.ts +3 -0
  33. package/dist/esm/components/utils/getProgressBarColor.js +20 -0
  34. package/dist/esm/components/utils/index.d.ts +1 -0
  35. package/dist/esm/components/utils/index.js +1 -0
  36. package/dist/esm/constants.d.ts +30 -0
  37. package/dist/esm/constants.js +22 -0
  38. package/dist/esm/index.d.ts +4 -0
  39. package/dist/esm/index.js +2 -0
  40. package/dist/esm/style.css +63 -0
  41. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  42. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  43. package/package.json +45 -0
  44. package/src/components/LoadStatus/LoadStatus.tsx +94 -0
  45. package/src/components/LoadStatus/index.ts +1 -0
  46. package/src/components/LoadStatus/styles.module.scss +53 -0
  47. package/src/components/index.ts +3 -0
  48. package/src/components/types.ts +20 -0
  49. package/src/components/utils/getProgressBarColor.ts +28 -0
  50. package/src/components/utils/index.ts +1 -0
  51. package/src/constants.ts +27 -0
  52. package/src/index.ts +4 -0
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEST_IDS = exports.SYMBOL_BY_TYPE = exports.DEFAULT_APPEARANCE_BY_PROGRESS = exports.PROGRESS_LIMIT_CONDITION = void 0;
4
+ exports.PROGRESS_LIMIT_CONDITION = {
5
+ Eq: 'eq',
6
+ Gt: 'gt',
7
+ Gte: 'gte',
8
+ Lt: 'lt',
9
+ Lte: 'lte',
10
+ };
11
+ exports.DEFAULT_APPEARANCE_BY_PROGRESS = [
12
+ { appearance: 'green', condition: exports.PROGRESS_LIMIT_CONDITION.Lte, limit: 70 },
13
+ { appearance: 'yellow', condition: exports.PROGRESS_LIMIT_CONDITION.Lte, limit: 90 },
14
+ { appearance: 'red', condition: exports.PROGRESS_LIMIT_CONDITION.Lte, limit: 100 },
15
+ ];
16
+ exports.SYMBOL_BY_TYPE = {
17
+ none: '',
18
+ percent: '%',
19
+ };
20
+ exports.TEST_IDS = {
21
+ root: 'load-status',
22
+ header: 'load-status__header',
23
+ hint: 'load-status__hint',
24
+ errorIcon: 'load-status__error-icon',
25
+ };
@@ -0,0 +1,4 @@
1
+ export { LoadStatus } from './components/LoadStatus';
2
+ export type { LoadStatusProps } from './components/LoadStatus';
3
+ export type { LoadValueType, ProgressLimitCondition, ProgressLimitList } from './components/types';
4
+ export { DEFAULT_APPEARANCE_BY_PROGRESS, PROGRESS_LIMIT_CONDITION, SYMBOL_BY_TYPE, TEST_IDS } from './constants';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEST_IDS = exports.SYMBOL_BY_TYPE = exports.PROGRESS_LIMIT_CONDITION = exports.DEFAULT_APPEARANCE_BY_PROGRESS = exports.LoadStatus = void 0;
4
+ var LoadStatus_1 = require("./components/LoadStatus");
5
+ Object.defineProperty(exports, "LoadStatus", { enumerable: true, get: function () { return LoadStatus_1.LoadStatus; } });
6
+ var constants_1 = require("./constants");
7
+ Object.defineProperty(exports, "DEFAULT_APPEARANCE_BY_PROGRESS", { enumerable: true, get: function () { return constants_1.DEFAULT_APPEARANCE_BY_PROGRESS; } });
8
+ Object.defineProperty(exports, "PROGRESS_LIMIT_CONDITION", { enumerable: true, get: function () { return constants_1.PROGRESS_LIMIT_CONDITION; } });
9
+ Object.defineProperty(exports, "SYMBOL_BY_TYPE", { enumerable: true, get: function () { return constants_1.SYMBOL_BY_TYPE; } });
10
+ Object.defineProperty(exports, "TEST_IDS", { enumerable: true, get: function () { return constants_1.TEST_IDS; } });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,63 @@
1
+ .loadStatus{
2
+ display:flex;
3
+ flex-direction:column;
4
+ gap:var(--sn-primitive-dimension-4, 4px);
5
+ width:100%;
6
+ }
7
+
8
+ .header{
9
+ display:flex;
10
+ gap:var(--sn-primitive-dimension-4, 4px);
11
+ align-items:flex-start;
12
+ justify-content:space-between;
13
+ }
14
+
15
+ .labelRow{
16
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
17
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
18
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
19
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
20
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
21
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
22
+ margin:0;
23
+ color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
24
+ }
25
+
26
+ .labelValue{
27
+ margin-left:var(--sn-primitive-dimension-4, 4px);
28
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
29
+ }
30
+
31
+ .valueSymbol{
32
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
33
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
34
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
35
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
36
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
37
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
38
+ flex-shrink:0;
39
+ margin:0;
40
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
41
+ }
42
+
43
+ .hintWrapper{
44
+ display:flex;
45
+ gap:var(--sn-primitive-dimension-2, 2px);
46
+ align-items:center;
47
+ }
48
+
49
+ .errorIcon{
50
+ flex-shrink:0;
51
+ color:var(--sn-theme-color-red-accent, var(--sn-primitive-color-red-55, #d52e33));
52
+ }
53
+
54
+ .hint{
55
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
56
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
57
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
58
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
59
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
60
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
61
+ margin:0;
62
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
63
+ }
@@ -0,0 +1,41 @@
1
+ import { ProgressBarProps } from '@cloud-ru/ds-progress-bar';
2
+ import { WithSupportProps } from '@cloud-ru/ds-utils';
3
+ import { LoadValueType, ProgressLimitList } from '../types.js';
4
+ export type LoadStatusProps = WithSupportProps<{
5
+ /** Заголовок строки загрузки */
6
+ label?: string;
7
+ /** Дополнительный текст в заголовке (рядом с label) */
8
+ value?: string;
9
+ /** Подсказка под полосой прогресса */
10
+ hint?: string;
11
+ /** Формат значения в заголовке: без процента (`none`) или с процентом (`percent`) */
12
+ valueType?: LoadValueType;
13
+ /** Правила смены цвета полосы в зависимости от `progress`; при `showError` игнорируются */
14
+ appearanceByProgress?: ProgressLimitList;
15
+ /** Ошибка: полоса `red` */
16
+ showError?: boolean;
17
+ /** Иконка в hint; показывается при `hint` и вместе с `showError` */
18
+ showErrorIcon?: boolean;
19
+ /** CSS-класс корневого элемента */
20
+ className?: string;
21
+ } & Pick<ProgressBarProps, 'progress' | 'size'>>;
22
+ export declare const LoadStatus: import("react").ForwardRefExoticComponent<{
23
+ 'data-test-id'?: string;
24
+ } & import("react").AriaAttributes & {
25
+ /** Заголовок строки загрузки */
26
+ label?: string;
27
+ /** Дополнительный текст в заголовке (рядом с label) */
28
+ value?: string;
29
+ /** Подсказка под полосой прогресса */
30
+ hint?: string;
31
+ /** Формат значения в заголовке: без процента (`none`) или с процентом (`percent`) */
32
+ valueType?: LoadValueType;
33
+ /** Правила смены цвета полосы в зависимости от `progress`; при `showError` игнорируются */
34
+ appearanceByProgress?: ProgressLimitList;
35
+ /** Ошибка: полоса `red` */
36
+ showError?: boolean;
37
+ /** Иконка в hint; показывается при `hint` и вместе с `showError` */
38
+ showErrorIcon?: boolean;
39
+ /** CSS-класс корневого элемента */
40
+ className?: string;
41
+ } & Pick<ProgressBarProps, "progress" | "size"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { NotifierCriticalFilledSVG } from '@cloud-ru/ds-icons/interface/system';
3
+ import { APPEARANCE, PROGRESS_BAR_SIZE, ProgressBar } from '@cloud-ru/ds-progress-bar';
4
+ import { SIZE, Typography, VARIANT, WEIGHT } from '@cloud-ru/ds-typography';
5
+ import { extractSupportProps } from '@cloud-ru/ds-utils';
6
+ import cn from 'classnames';
7
+ import { forwardRef } from 'react';
8
+ import { DEFAULT_APPEARANCE_BY_PROGRESS, SYMBOL_BY_TYPE, TEST_IDS } from '../../constants.js';
9
+ import { getProgressBarColor } from '../utils/index.js';
10
+ import styles from './styles.module.css';
11
+ export const LoadStatus = forwardRef(function LoadStatus({ label, value, hint, valueType = 'none', progress, size = PROGRESS_BAR_SIZE.S, appearanceByProgress = DEFAULT_APPEARANCE_BY_PROGRESS, showError, showErrorIcon, className, ...props }, ref) {
12
+ const progressAppearance = showError ? APPEARANCE.Red : getProgressBarColor(progress, appearanceByProgress);
13
+ const isShowHeader = Boolean(label || value || valueType !== 'none');
14
+ const resolvedValueType = valueType;
15
+ const symbol = SYMBOL_BY_TYPE[resolvedValueType];
16
+ const progressSymbolValue = !symbol ? progress : `${progress}${symbol}`;
17
+ return (_jsxs("div", { className: cn(styles.loadStatus, className), ref: ref, "data-test-id": TEST_IDS.root, ...extractSupportProps(props), children: [isShowHeader && (_jsxs("div", { className: styles.header, "data-test-id": TEST_IDS.header, children: [_jsxs(Typography, { className: styles.labelRow, variant: VARIANT.body, size: SIZE.m, weight: WEIGHT.regular, children: [label, value && _jsx("span", { className: styles.labelValue, children: value })] }), symbol && (_jsx(Typography, { className: styles.valueSymbol, variant: VARIANT.body, size: SIZE.m, weight: WEIGHT.regular, children: progressSymbolValue }))] })), _jsx(ProgressBar, { progress: progress, size: size, appearance: progressAppearance }), hint && (_jsxs("div", { className: styles.hintWrapper, "data-test-id": TEST_IDS.hint, children: [showErrorIcon && (_jsx(NotifierCriticalFilledSVG, { className: styles.errorIcon, size: 16, "data-test-id": TEST_IDS.errorIcon })), _jsx(Typography, { className: styles.hint, variant: VARIANT.body, size: SIZE.m, weight: WEIGHT.regular, children: hint })] }))] }));
18
+ });
@@ -0,0 +1 @@
1
+ export * from './LoadStatus.js';
@@ -0,0 +1 @@
1
+ export * from './LoadStatus.js';
@@ -0,0 +1,63 @@
1
+ .loadStatus{
2
+ display:flex;
3
+ flex-direction:column;
4
+ gap:var(--sn-primitive-dimension-4, 4px);
5
+ width:100%;
6
+ }
7
+
8
+ .header{
9
+ display:flex;
10
+ gap:var(--sn-primitive-dimension-4, 4px);
11
+ align-items:flex-start;
12
+ justify-content:space-between;
13
+ }
14
+
15
+ .labelRow{
16
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
17
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
18
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
19
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
20
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
21
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
22
+ margin:0;
23
+ color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
24
+ }
25
+
26
+ .labelValue{
27
+ margin-left:var(--sn-primitive-dimension-4, 4px);
28
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
29
+ }
30
+
31
+ .valueSymbol{
32
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
33
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
34
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
35
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
36
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
37
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
38
+ flex-shrink:0;
39
+ margin:0;
40
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
41
+ }
42
+
43
+ .hintWrapper{
44
+ display:flex;
45
+ gap:var(--sn-primitive-dimension-2, 2px);
46
+ align-items:center;
47
+ }
48
+
49
+ .errorIcon{
50
+ flex-shrink:0;
51
+ color:var(--sn-theme-color-red-accent, var(--sn-primitive-color-red-55, #d52e33));
52
+ }
53
+
54
+ .hint{
55
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
56
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
57
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
58
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
59
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
60
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
61
+ margin:0;
62
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
63
+ }
@@ -0,0 +1,3 @@
1
+ export * from './LoadStatus/index.js';
2
+ export * from './types.js';
3
+ export * from './utils/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './LoadStatus/index.js';
2
+ export * from './types.js';
3
+ export * from './utils/index.js';
@@ -0,0 +1,16 @@
1
+ import { Appearance } from '@cloud-ru/ds-progress-bar';
2
+ import { ValueOf } from '@cloud-ru/ds-utils';
3
+ import { PROGRESS_LIMIT_CONDITION } from '../constants.js';
4
+ export type LoadValueType = 'none' | 'percent';
5
+ export type ProgressLimitCondition = ValueOf<typeof PROGRESS_LIMIT_CONDITION>;
6
+ /** Порог смены цвета полосы прогресса */
7
+ type ProgressLimit = {
8
+ /** Условие сравнения `progress` с `limit` */
9
+ condition: ProgressLimitCondition;
10
+ /** Пороговое значение progress (обычно 0–100) */
11
+ limit: number;
12
+ /** Цвет полосы при выполнении условия */
13
+ appearance: Appearance;
14
+ };
15
+ export type ProgressLimitList = ProgressLimit[];
16
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Appearance } from '@cloud-ru/ds-progress-bar';
2
+ import { ProgressLimitList } from '../types.js';
3
+ export declare const getProgressBarColor: (progress: number, limits: ProgressLimitList) => Appearance;
@@ -0,0 +1,20 @@
1
+ import { APPEARANCE } from '@cloud-ru/ds-progress-bar';
2
+ import { PROGRESS_LIMIT_CONDITION } from '../../constants.js';
3
+ const PROGRESS_LIMIT_MATCHERS = {
4
+ [PROGRESS_LIMIT_CONDITION.Eq]: (progress, limit) => progress === limit,
5
+ [PROGRESS_LIMIT_CONDITION.Gt]: (progress, limit) => progress > limit,
6
+ [PROGRESS_LIMIT_CONDITION.Gte]: (progress, limit) => progress >= limit,
7
+ [PROGRESS_LIMIT_CONDITION.Lt]: (progress, limit) => progress < limit,
8
+ [PROGRESS_LIMIT_CONDITION.Lte]: (progress, limit) => progress <= limit,
9
+ };
10
+ export const getProgressBarColor = (progress, limits) => {
11
+ for (const limit of limits) {
12
+ if (!(limit.condition in PROGRESS_LIMIT_MATCHERS)) {
13
+ return APPEARANCE.Neutral;
14
+ }
15
+ if (PROGRESS_LIMIT_MATCHERS[limit.condition](progress, limit.limit)) {
16
+ return limit.appearance;
17
+ }
18
+ }
19
+ return APPEARANCE.Neutral;
20
+ };
@@ -0,0 +1 @@
1
+ export * from './getProgressBarColor.js';
@@ -0,0 +1 @@
1
+ export * from './getProgressBarColor.js';
@@ -0,0 +1,30 @@
1
+ export declare const PROGRESS_LIMIT_CONDITION: {
2
+ readonly Eq: "eq";
3
+ readonly Gt: "gt";
4
+ readonly Gte: "gte";
5
+ readonly Lt: "lt";
6
+ readonly Lte: "lte";
7
+ };
8
+ export declare const DEFAULT_APPEARANCE_BY_PROGRESS: ({
9
+ appearance: "green";
10
+ condition: "lte";
11
+ limit: number;
12
+ } | {
13
+ appearance: "yellow";
14
+ condition: "lte";
15
+ limit: number;
16
+ } | {
17
+ appearance: "red";
18
+ condition: "lte";
19
+ limit: number;
20
+ })[];
21
+ export declare const SYMBOL_BY_TYPE: {
22
+ readonly none: "";
23
+ readonly percent: "%";
24
+ };
25
+ export declare const TEST_IDS: {
26
+ readonly root: "load-status";
27
+ readonly header: "load-status__header";
28
+ readonly hint: "load-status__hint";
29
+ readonly errorIcon: "load-status__error-icon";
30
+ };
@@ -0,0 +1,22 @@
1
+ export const PROGRESS_LIMIT_CONDITION = {
2
+ Eq: 'eq',
3
+ Gt: 'gt',
4
+ Gte: 'gte',
5
+ Lt: 'lt',
6
+ Lte: 'lte',
7
+ };
8
+ export const DEFAULT_APPEARANCE_BY_PROGRESS = [
9
+ { appearance: 'green', condition: PROGRESS_LIMIT_CONDITION.Lte, limit: 70 },
10
+ { appearance: 'yellow', condition: PROGRESS_LIMIT_CONDITION.Lte, limit: 90 },
11
+ { appearance: 'red', condition: PROGRESS_LIMIT_CONDITION.Lte, limit: 100 },
12
+ ];
13
+ export const SYMBOL_BY_TYPE = {
14
+ none: '',
15
+ percent: '%',
16
+ };
17
+ export const TEST_IDS = {
18
+ root: 'load-status',
19
+ header: 'load-status__header',
20
+ hint: 'load-status__hint',
21
+ errorIcon: 'load-status__error-icon',
22
+ };
@@ -0,0 +1,4 @@
1
+ export { LoadStatus } from './components/LoadStatus/index.js';
2
+ export type { LoadStatusProps } from './components/LoadStatus/index.js';
3
+ export type { LoadValueType, ProgressLimitCondition, ProgressLimitList } from './components/types.js';
4
+ export { DEFAULT_APPEARANCE_BY_PROGRESS, PROGRESS_LIMIT_CONDITION, SYMBOL_BY_TYPE, TEST_IDS } from './constants.js';
@@ -0,0 +1,2 @@
1
+ export { LoadStatus } from './components/LoadStatus/index.js';
2
+ export { DEFAULT_APPEARANCE_BY_PROGRESS, PROGRESS_LIMIT_CONDITION, SYMBOL_BY_TYPE, TEST_IDS } from './constants.js';
@@ -0,0 +1,63 @@
1
+ .loadStatus{
2
+ display:flex;
3
+ flex-direction:column;
4
+ gap:var(--sn-primitive-dimension-4, 4px);
5
+ width:100%;
6
+ }
7
+
8
+ .header{
9
+ display:flex;
10
+ gap:var(--sn-primitive-dimension-4, 4px);
11
+ align-items:flex-start;
12
+ justify-content:space-between;
13
+ }
14
+
15
+ .labelRow{
16
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
17
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
18
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
19
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
20
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
21
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
22
+ margin:0;
23
+ color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
24
+ }
25
+
26
+ .labelValue{
27
+ margin-left:var(--sn-primitive-dimension-4, 4px);
28
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
29
+ }
30
+
31
+ .valueSymbol{
32
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
33
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
34
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
35
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
36
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
37
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
38
+ flex-shrink:0;
39
+ margin:0;
40
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
41
+ }
42
+
43
+ .hintWrapper{
44
+ display:flex;
45
+ gap:var(--sn-primitive-dimension-2, 2px);
46
+ align-items:center;
47
+ }
48
+
49
+ .errorIcon{
50
+ flex-shrink:0;
51
+ color:var(--sn-theme-color-red-accent, var(--sn-primitive-color-red-55, #d52e33));
52
+ }
53
+
54
+ .hint{
55
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
56
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
57
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
58
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
59
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
60
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
61
+ margin:0;
62
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
63
+ }