@cloud-ru/uikit-product-price-summary 0.5.3 → 0.5.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.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/components/ContentBlock/ContentBlock.d.ts +7 -0
- package/dist/cjs/components/ContentBlock/ContentBlock.js +23 -0
- package/dist/cjs/components/ContentBlock/index.d.ts +1 -0
- package/dist/cjs/components/ContentBlock/index.js +17 -0
- package/dist/cjs/components/ContentBlock/styles.module.css +12 -0
- package/dist/cjs/components/PriceSummary/PriceSummary.d.ts +17 -0
- package/dist/cjs/components/PriceSummary/PriceSummary.js +33 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/DiscountBlock.d.ts +6 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/DiscountBlock.js +17 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/styles.module.css +16 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.d.ts +6 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.js +16 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/DiscountPercentCell/styles.module.css +5 -0
- package/dist/cjs/components/PriceSummary/components/Divider/Divider.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/Divider/Divider.js +11 -0
- package/dist/cjs/components/PriceSummary/components/Divider/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/Divider/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/Divider/styles.module.css +6 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/HeaderBlock.d.ts +6 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/HeaderBlock.js +16 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/styles.module.css +14 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.d.ts +7 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.js +18 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/styles.module.css +18 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts +6 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/styles.module.css +16 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.d.ts +7 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.js +24 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemBlock/styles.module.css +33 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts +6 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js +16 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/styles.module.css +14 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.d.ts +8 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.js +23 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/styles.module.css +15 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.d.ts +24 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.js +46 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/styles.module.css +51 -0
- package/dist/cjs/components/PriceSummary/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/index.js +17 -0
- package/dist/cjs/components/PriceSummary/styles.module.css +12 -0
- package/dist/cjs/components/PriceSummarySmall/PriceSummarySmall.d.ts +12 -0
- package/dist/cjs/components/PriceSummarySmall/PriceSummarySmall.js +32 -0
- package/dist/cjs/components/PriceSummarySmall/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummarySmall/index.js +17 -0
- package/dist/cjs/components/PriceSummarySmall/styles.module.css +23 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/helpers/formatters.d.ts +2 -0
- package/dist/cjs/helpers/formatters.js +14 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/helpers/index.js +17 -0
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.js +18 -0
- package/dist/cjs/hooks/usePeriodFormat.d.ts +2 -0
- package/dist/cjs/hooks/usePeriodFormat.js +24 -0
- package/dist/cjs/hooks/usePriceTotalValueFormatter.d.ts +2 -0
- package/dist/cjs/hooks/usePriceTotalValueFormatter.js +10 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/types/index.d.ts +41 -0
- package/dist/cjs/types/index.js +11 -0
- package/dist/esm/components/ContentBlock/ContentBlock.d.ts +7 -0
- package/dist/esm/components/ContentBlock/ContentBlock.js +17 -0
- package/dist/esm/components/ContentBlock/index.d.ts +1 -0
- package/dist/esm/components/ContentBlock/index.js +1 -0
- package/dist/esm/components/ContentBlock/styles.module.css +12 -0
- package/dist/esm/components/PriceSummary/PriceSummary.d.ts +17 -0
- package/dist/esm/components/PriceSummary/PriceSummary.js +27 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/DiscountBlock.d.ts +6 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/DiscountBlock.js +11 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/styles.module.css +16 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.d.ts +6 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.js +10 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/DiscountPercentCell/styles.module.css +5 -0
- package/dist/esm/components/PriceSummary/components/Divider/Divider.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/Divider/Divider.js +5 -0
- package/dist/esm/components/PriceSummary/components/Divider/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/Divider/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/Divider/styles.module.css +6 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/HeaderBlock.d.ts +6 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/HeaderBlock.js +10 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/styles.module.css +14 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.d.ts +7 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.js +12 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/styles.module.css +18 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts +6 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js +11 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/styles.module.css +16 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.d.ts +7 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.js +18 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemBlock/styles.module.css +33 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts +6 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js +10 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/styles.module.css +14 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.d.ts +8 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.js +17 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/styles.module.css +15 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.d.ts +24 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.js +39 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/styles.module.css +51 -0
- package/dist/esm/components/PriceSummary/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/index.js +1 -0
- package/dist/esm/components/PriceSummary/styles.module.css +12 -0
- package/dist/esm/components/PriceSummarySmall/PriceSummarySmall.d.ts +12 -0
- package/dist/esm/components/PriceSummarySmall/PriceSummarySmall.js +26 -0
- package/dist/esm/components/PriceSummarySmall/index.d.ts +1 -0
- package/dist/esm/components/PriceSummarySmall/index.js +1 -0
- package/dist/esm/components/PriceSummarySmall/styles.module.css +23 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/helpers/formatters.d.ts +2 -0
- package/dist/esm/helpers/formatters.js +10 -0
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.js +1 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/usePeriodFormat.d.ts +2 -0
- package/dist/esm/hooks/usePeriodFormat.js +21 -0
- package/dist/esm/hooks/usePriceTotalValueFormatter.d.ts +2 -0
- package/dist/esm/hooks/usePriceTotalValueFormatter.js +7 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/types/index.d.ts +41 -0
- package/dist/esm/types/index.js +8 -0
- package/package.json +7 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RepeatSVG } from '@sbercloud/uikit-product-icons';
|
|
3
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
4
|
+
import { ButtonFunction } from '@snack-uikit/button';
|
|
5
|
+
import { Sun } from '@snack-uikit/loaders';
|
|
6
|
+
import { Typography } from '@snack-uikit/typography';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function ContentBlock({ loading, dataError, onRetry, children }) {
|
|
9
|
+
const { t } = useLocale('PriceSummary');
|
|
10
|
+
if (loading) {
|
|
11
|
+
return (_jsx("div", { className: styles.loadingBlock, children: _jsx(Sun, {}) }));
|
|
12
|
+
}
|
|
13
|
+
if (dataError) {
|
|
14
|
+
return (_jsxs("div", { className: styles.dataErrorBlock, children: [onRetry && _jsx(ButtonFunction, { icon: _jsx(RepeatSVG, {}), onClick: onRetry }), _jsx(Typography.SansBodyS, { children: t('dataError') })] }));
|
|
15
|
+
}
|
|
16
|
+
return children;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContentBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContentBlock';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WithLayoutType, WithSupportProps } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { LinkProps } from '@snack-uikit/link';
|
|
3
|
+
import { DiscountDetails, InvoiceDetails } from '../../types';
|
|
4
|
+
import { ContentBlockProps } from '../ContentBlock';
|
|
5
|
+
import { HeaderBlockProps } from './components/HeaderBlock';
|
|
6
|
+
import { TotalValueBlockProps } from './components/TotalValueBlock';
|
|
7
|
+
export type PriceSummaryProps = WithLayoutType<WithSupportProps<TotalValueBlockProps & HeaderBlockProps & ContentBlockProps & {
|
|
8
|
+
discount?: DiscountDetails;
|
|
9
|
+
invoice?: InvoiceDetails[];
|
|
10
|
+
invoiceExpandedDefault?: boolean;
|
|
11
|
+
docsLink?: {
|
|
12
|
+
href?: LinkProps['href'];
|
|
13
|
+
text?: LinkProps['text'];
|
|
14
|
+
};
|
|
15
|
+
className?: string;
|
|
16
|
+
}>>;
|
|
17
|
+
export declare function PriceSummary({ value, totalSumType, hint, period, onPeriodChanged, periodOptions, promoBadge, loading, dataError, onRetry, discount, invoice, invoiceExpandedDefault, docsLink, className, layoutType, hintAppearance, showHintTooltip, hintTooltipText, hintLink, showHintLink, ...rest }: PriceSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import cn from 'classnames';
|
|
14
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
15
|
+
import { extractSupportProps } from '@sbercloud/uikit-product-utils';
|
|
16
|
+
import { Link } from '@snack-uikit/link';
|
|
17
|
+
import { ContentBlock } from '../ContentBlock';
|
|
18
|
+
import { DiscountBlock } from './components/DiscountBlock';
|
|
19
|
+
import { HeaderBlock } from './components/HeaderBlock';
|
|
20
|
+
import { InvoiceBlock } from './components/InvoiceBlock';
|
|
21
|
+
import { TotalValueBlock } from './components/TotalValueBlock';
|
|
22
|
+
import styles from './styles.module.css';
|
|
23
|
+
export function PriceSummary(_a) {
|
|
24
|
+
var { value, totalSumType, hint, period, onPeriodChanged, periodOptions, promoBadge, loading, dataError, onRetry, discount, invoice, invoiceExpandedDefault = true, docsLink, className, layoutType, hintAppearance, showHintTooltip = false, hintTooltipText, hintLink, showHintLink } = _a, rest = __rest(_a, ["value", "totalSumType", "hint", "period", "onPeriodChanged", "periodOptions", "promoBadge", "loading", "dataError", "onRetry", "discount", "invoice", "invoiceExpandedDefault", "docsLink", "className", "layoutType", "hintAppearance", "showHintTooltip", "hintTooltipText", "hintLink", "showHintLink"]);
|
|
25
|
+
const { t } = useLocale('PriceSummary');
|
|
26
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.priceSummary, className) }, extractSupportProps(rest), { children: [_jsx(HeaderBlock, { period: period, onPeriodChanged: onPeriodChanged, periodOptions: periodOptions, promoBadge: promoBadge, layoutType: layoutType }), _jsxs(ContentBlock, { loading: loading, dataError: dataError, onRetry: onRetry, children: [discount && _jsx(DiscountBlock, { value: discount, layoutType: layoutType }), _jsx(TotalValueBlock, { value: value, totalSumType: totalSumType, hint: hint, hintAppearance: hintAppearance, showHintTooltip: showHintTooltip, hintTooltipText: hintTooltipText, hintLink: hintLink, showHintLink: showHintLink }), (invoice === null || invoice === void 0 ? void 0 : invoice.length) && (_jsx(InvoiceBlock, { invoice: invoice, invoiceExpandedDefault: invoiceExpandedDefault, layoutType: layoutType })), (docsLink === null || docsLink === void 0 ? void 0 : docsLink.href) && (_jsx(Link, { size: 'm', textMode: 'default', text: docsLink.text || t('docsLink'), href: docsLink.href, target: '_blank' }))] })] })));
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { DiscountDetails } from '../../../../types';
|
|
3
|
+
export type DiscountBlockProps = WithLayoutType<{
|
|
4
|
+
value: DiscountDetails;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function DiscountBlock({ value, layoutType }: DiscountBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
4
|
+
import { Typography } from '@snack-uikit/typography';
|
|
5
|
+
import { formatCurrency } from '../../../../helpers';
|
|
6
|
+
import { DiscountPercentCell } from '../DiscountPercentCell';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function DiscountBlock({ value, layoutType }) {
|
|
9
|
+
const { t } = useLocale('PriceSummary');
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.discountGrid, children: [_jsx(Typography.SansBodyS, { tag: 'div', children: t('basePrice') }), _jsx(Typography.SansLabelM, { tag: 'div', className: styles.priceCell, children: formatCurrency(value.price) })] }), _jsx("div", { className: styles.discountGrid, children: value.discounts.map((discount, index) => (_jsxs(Fragment, { children: [_jsx(DiscountPercentCell, { discount: discount, layoutType: layoutType }), _jsx(Typography.SansLabelM, { tag: 'div', className: styles.discountCell, children: formatCurrency(-Math.abs(discount.value)) })] }, index))) })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountBlock';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.discountGrid{
|
|
2
|
+
display:grid;
|
|
3
|
+
grid-template-columns:1fr 1fr;
|
|
4
|
+
-moz-column-gap:var(--dimension-1m, 8px);
|
|
5
|
+
column-gap:var(--dimension-1m, 8px);
|
|
6
|
+
color:var(--sys-neutral-text-support, #6d707f);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.priceCell{
|
|
10
|
+
justify-self:end;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.discountCell{
|
|
14
|
+
justify-self:end;
|
|
15
|
+
color:var(--sys-red-text-support, #ae514c);
|
|
16
|
+
}
|
package/dist/esm/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { DiscountItem } from '../../../../types';
|
|
3
|
+
export type DiscountPercentCellProps = WithLayoutType<{
|
|
4
|
+
discount: DiscountItem;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function DiscountPercentCell({ discount, layoutType }: DiscountPercentCellProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { formatNumber } from '@cloud-ru/ft-formatters';
|
|
3
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
4
|
+
import { AdaptiveQuestionTooltip } from '@sbercloud/uikit-product-mobile-tooltip';
|
|
5
|
+
import { Typography } from '@snack-uikit/typography';
|
|
6
|
+
import styles from './styles.module.css';
|
|
7
|
+
export function DiscountPercentCell({ discount, layoutType }) {
|
|
8
|
+
const { t } = useLocale('PriceSummary');
|
|
9
|
+
return (_jsx("div", { className: styles.percentCell, children: discount.percent && (_jsxs(_Fragment, { children: [_jsxs(Typography.SansBodyS, { children: [t('discount'), " ", formatNumber(-Math.abs(discount.percent)), "%"] }), discount.tooltip && (_jsx(AdaptiveQuestionTooltip, { layoutType: layoutType, tip: discount.tooltip, trigger: layoutType === 'mobile' ? 'click' : 'hover' }))] })) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountPercentCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountPercentCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Divider(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Divider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Divider';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PromoTagProps } from '@snack-uikit/promo-tag';
|
|
2
|
+
import { PeriodDropdownProps } from '../PeriodDropdown';
|
|
3
|
+
export type HeaderBlockProps = PeriodDropdownProps & {
|
|
4
|
+
promoBadge?: Pick<PromoTagProps, 'text' | 'appearance'> | string;
|
|
5
|
+
};
|
|
6
|
+
export declare function HeaderBlock({ period, onPeriodChanged, periodOptions, promoBadge, layoutType }: HeaderBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
3
|
+
import { PromoTag } from '@snack-uikit/promo-tag';
|
|
4
|
+
import { Typography } from '@snack-uikit/typography';
|
|
5
|
+
import { PeriodDropdown } from '../PeriodDropdown';
|
|
6
|
+
import styles from './styles.module.css';
|
|
7
|
+
export function HeaderBlock({ period, onPeriodChanged, periodOptions, promoBadge, layoutType }) {
|
|
8
|
+
const { t } = useLocale('PriceSummary');
|
|
9
|
+
return (_jsxs(_Fragment, { children: [promoBadge && (_jsx("div", { className: styles.promoBadge, children: _jsx(PromoTag, Object.assign({}, (typeof promoBadge === 'string' ? { text: promoBadge } : promoBadge))) })), _jsxs("div", { className: styles.headline, children: [_jsx(PeriodDropdown, { period: period, onPeriodChanged: onPeriodChanged, periodOptions: periodOptions, layoutType: layoutType }), _jsx(Typography.SansBodyM, { className: styles.vat, children: t('vat') })] })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeaderBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeaderBlock';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { InvoiceDetails } from '../../../../types';
|
|
3
|
+
export type InvoiceBlockProps = WithLayoutType<{
|
|
4
|
+
invoice: InvoiceDetails[];
|
|
5
|
+
invoiceExpandedDefault?: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function InvoiceBlock({ invoice, invoiceExpandedDefault, layoutType }: InvoiceBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
4
|
+
import { AccordionSecondary } from '@snack-uikit/accordion';
|
|
5
|
+
import { Typography } from '@snack-uikit/typography';
|
|
6
|
+
import { InvoiceDetailsBlock } from '../InvoiceDetailsBlock';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function InvoiceBlock({ invoice, invoiceExpandedDefault, layoutType }) {
|
|
9
|
+
const { t } = useLocale('PriceSummary');
|
|
10
|
+
const invoiceBlockId = useId();
|
|
11
|
+
return (_jsx(AccordionSecondary, { expandedDefault: invoiceExpandedDefault ? invoiceBlockId : undefined, className: styles.accordion, children: _jsx(AccordionSecondary.CollapseBlock, { id: invoiceBlockId, header: _jsx(Typography.SansBodyM, { className: styles.accordionHeaderTitle, children: t('orderDetails') }), children: _jsx("div", { className: styles.accordionContent, children: invoice.map((invoice, index) => (_jsx(InvoiceDetailsBlock, { invoice: invoice, layoutType: layoutType }, index))) }) }) }));
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceBlock';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.accordion{
|
|
2
|
+
--space-accordion-collapse-block-secondary-horizontal-padding:0;
|
|
3
|
+
--space-accordion-collapse-block-secondary-vertical-padding:var(--dimension-1m, 8px);
|
|
4
|
+
--space-accordion-collapse-block-secondary-gap:var(--dimension-1m, 8px);
|
|
5
|
+
--border-width-accordion-collapse-block-secondary:0;
|
|
6
|
+
--accordion-header-padding-vertical:0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.accordionHeaderTitle{
|
|
10
|
+
color:var(--sys-neutral-text-support, #6d707f);
|
|
11
|
+
padding:2px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.accordionContent{
|
|
15
|
+
display:flex;
|
|
16
|
+
flex-direction:column;
|
|
17
|
+
gap:var(--dimension-1m, 8px);
|
|
18
|
+
}
|
package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { InvoiceDetails } from '../../../../types';
|
|
3
|
+
export type InvoiceDetailsBlockProps = WithLayoutType<{
|
|
4
|
+
invoice: InvoiceDetails;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function InvoiceDetailsBlock({ invoice, layoutType }: InvoiceDetailsBlockProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
3
|
+
import { Typography } from '@snack-uikit/typography';
|
|
4
|
+
import { formatCurrency, formatQuantity } from '../../../../helpers';
|
|
5
|
+
import { Divider } from '../Divider';
|
|
6
|
+
import { InvoiceItemBlock } from '../InvoiceItemBlock';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function InvoiceDetailsBlock({ invoice, layoutType }) {
|
|
9
|
+
const { t } = useLocale('PriceSummary');
|
|
10
|
+
return (_jsxs("div", { className: styles.main, children: [invoice.title && (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.header, children: [_jsx(Typography.SansLabelM, { children: invoice.title }), invoice.quantity && _jsx(Typography.SansLabelM, { children: formatQuantity(invoice.quantity) })] }), _jsx(Divider, {})] })), invoice.items.map((item, index) => (_jsx(InvoiceItemBlock, { item: item, index: index, layoutType: layoutType }, index))), invoice.price !== undefined && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsx("div", { className: styles.footer, children: _jsxs(Typography.SansLabelM, { children: [t('price'), ": ", formatCurrency(invoice.price)] }) })] }))] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceDetailsBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceDetailsBlock';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.main{
|
|
2
|
+
border-radius:var(--dimension-050m, 4px);
|
|
3
|
+
padding:var(--dimension-050m, 4px) var(--dimension-1m, 8px);
|
|
4
|
+
border:1px dashed var(--sys-neutral-decor-default, #dde0ea);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.header{
|
|
8
|
+
display:flex;
|
|
9
|
+
justify-content:space-between;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.footer{
|
|
13
|
+
display:flex;
|
|
14
|
+
align-items:center;
|
|
15
|
+
justify-content:flex-end;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { InvoiceItem } from '../../../../types';
|
|
3
|
+
export type InvoiceItemBlockProps = WithLayoutType<{
|
|
4
|
+
item: InvoiceItem;
|
|
5
|
+
index: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function InvoiceItemBlock({ item, index, layoutType }: InvoiceItemBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from '@snack-uikit/typography';
|
|
3
|
+
import { formatCurrency } from '../../../../helpers';
|
|
4
|
+
import { DiscountPercentCell } from '../DiscountPercentCell';
|
|
5
|
+
import { Divider } from '../Divider';
|
|
6
|
+
import { InvoiceItemLabelCell } from '../InvoiceItemLabelCell';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function InvoiceItemBlock({ item, index, layoutType }) {
|
|
9
|
+
const isEven = (index + 1) % 2 === 0;
|
|
10
|
+
const isSecondary = item.primary === undefined ? isEven : !item.primary;
|
|
11
|
+
const getPriceItem = () => {
|
|
12
|
+
if (item.hidePrice === false) {
|
|
13
|
+
return item.price !== undefined ? formatCurrency(item.price) : 'n/a';
|
|
14
|
+
}
|
|
15
|
+
return item.price !== undefined ? formatCurrency(item.price) : undefined;
|
|
16
|
+
};
|
|
17
|
+
return (_jsxs(_Fragment, { children: [item.topDivider && _jsx(Divider, {}), _jsxs("div", { className: styles.itemGrid, "data-discount": Boolean(item.discount), children: ['label' in item && item.label !== undefined && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.labelCell, "data-secondary": isSecondary, children: _jsx(InvoiceItemLabelCell, { item: item, layoutType: layoutType }) }), _jsx(Typography.SansBodyS, { tag: 'div', className: styles.priceCell, "data-secondary": isSecondary, children: getPriceItem() })] })), item.discount && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.percentCell, "data-secondary": isSecondary, children: _jsx(DiscountPercentCell, { discount: item.discount, layoutType: layoutType }) }), _jsx(Typography.SansBodyS, { tag: 'div', className: styles.discountCell, "data-secondary": isSecondary, children: formatCurrency(-Math.abs(item.discount.value)) })] }))] }), item.bottomDivider && _jsx(Divider, {})] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemBlock';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.itemGrid{
|
|
2
|
+
display:grid;
|
|
3
|
+
grid-template-columns:1fr auto;
|
|
4
|
+
-moz-column-gap:var(--dimension-1m, 8px);
|
|
5
|
+
column-gap:var(--dimension-1m, 8px);
|
|
6
|
+
}
|
|
7
|
+
.itemGrid[data-discount=true]{
|
|
8
|
+
margin-bottom:var(--dimension-050m, 4px);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.labelCell{
|
|
12
|
+
display:flex;
|
|
13
|
+
overflow:hidden;
|
|
14
|
+
gap:var(--dimension-050m, 4px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.priceCell{
|
|
18
|
+
justify-self:end;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.labelCell[data-secondary=true],
|
|
22
|
+
.priceCell[data-secondary=true],
|
|
23
|
+
.percentCell[data-secondary=true]{
|
|
24
|
+
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.discountCell{
|
|
28
|
+
justify-self:end;
|
|
29
|
+
color:var(--sys-red-accent-default, #cb3f3e);
|
|
30
|
+
}
|
|
31
|
+
.discountCell[data-secondary=true]{
|
|
32
|
+
color:var(--sys-red-text-disabled, #ee9285);
|
|
33
|
+
}
|
package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { InvoiceItem } from '../../../../types';
|
|
3
|
+
export type InvoiceItemLabelCellProps = WithLayoutType<{
|
|
4
|
+
item: InvoiceItem;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function InvoiceItemLabelCell({ item, layoutType }: InvoiceItemLabelCellProps): false | import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { AdaptiveQuestionTooltip } from '@sbercloud/uikit-product-mobile-tooltip';
|
|
3
|
+
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
4
|
+
import { Typography } from '@snack-uikit/typography';
|
|
5
|
+
import { formatQuantity } from '../../../../helpers';
|
|
6
|
+
import styles from './styles.module.css';
|
|
7
|
+
export function InvoiceItemLabelCell({ item, layoutType }) {
|
|
8
|
+
return ('label' in item &&
|
|
9
|
+
item.label !== undefined && (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.labelCell, children: [_jsx(Typography.SansBodyS, { className: styles.label, children: item.labelMaxLines ? _jsx(TruncateString, { text: item.label, maxLines: item.labelMaxLines }) : item.label }), item.labelTooltip && (_jsx(AdaptiveQuestionTooltip, { layoutType: layoutType, tip: item.labelTooltip, trigger: layoutType === 'mobile' ? 'click' : 'hover' }))] }), item.quantity && (_jsx(Typography.SansBodyS, { className: styles.quantity, children: formatQuantity(item.quantity) }))] })));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemLabelCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemLabelCell';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WithLayoutType } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { PricePeriod } from '../../../../types';
|
|
3
|
+
export type PeriodDropdownProps = WithLayoutType<{
|
|
4
|
+
period: PricePeriod;
|
|
5
|
+
periodOptions: PricePeriod[];
|
|
6
|
+
onPeriodChanged?: (period: PricePeriod) => void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function PeriodDropdown({ period, onPeriodChanged, periodOptions, layoutType }: PeriodDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonDropdown } from '@sbercloud/uikit-product-button-predefined';
|
|
3
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
4
|
+
import { Typography } from '@snack-uikit/typography';
|
|
5
|
+
import { usePeriodFormat } from '../../../../hooks';
|
|
6
|
+
import styles from './styles.module.css';
|
|
7
|
+
export function PeriodDropdown({ period, onPeriodChanged = () => { }, periodOptions, layoutType }) {
|
|
8
|
+
const { t } = useLocale('PriceSummary');
|
|
9
|
+
const formatPeriod = usePeriodFormat();
|
|
10
|
+
const actions = periodOptions
|
|
11
|
+
.filter(item => item !== period)
|
|
12
|
+
.map(item => ({
|
|
13
|
+
content: { option: formatPeriod(item) },
|
|
14
|
+
onClick: () => onPeriodChanged(item),
|
|
15
|
+
}));
|
|
16
|
+
return (_jsxs("div", { className: styles.period, "data-single": actions.length === 0 ? true : undefined, children: [_jsx(Typography.SansBodyM, { children: t('total') }), actions.length === 0 && (_jsx("div", { className: styles.single, children: _jsx(Typography.SansBodyM, { children: formatPeriod(period) }) })), actions.length > 0 && (_jsx(ButtonDropdown, { size: 's', label: formatPeriod(period), items: actions, closeDroplistOnItemClick: true, layoutType: layoutType }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PeriodDropdown';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PeriodDropdown';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.period{
|
|
2
|
+
display:flex;
|
|
3
|
+
align-items:center;
|
|
4
|
+
gap:var(--dimension-1m, 8px);
|
|
5
|
+
}
|
|
6
|
+
.period[data-single]{
|
|
7
|
+
gap:var(--dimension-050m, 4px);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.single{
|
|
11
|
+
min-height:var(--size-button-s, 32px);
|
|
12
|
+
display:flex;
|
|
13
|
+
align-items:center;
|
|
14
|
+
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
3
|
+
import { TotalSumType } from '../../../../types';
|
|
4
|
+
export declare const APPEARANCE_STATE: {
|
|
5
|
+
readonly Default: "default";
|
|
6
|
+
readonly UserError: "userError";
|
|
7
|
+
readonly SystemError: "systemError";
|
|
8
|
+
readonly Warning: "warning";
|
|
9
|
+
};
|
|
10
|
+
export type AppearanceState = ValueOf<typeof APPEARANCE_STATE>;
|
|
11
|
+
export type TotalValueBlockProps = {
|
|
12
|
+
value?: number;
|
|
13
|
+
totalSumType?: TotalSumType;
|
|
14
|
+
hint?: string;
|
|
15
|
+
hintAppearance?: AppearanceState;
|
|
16
|
+
showHintTooltip?: boolean;
|
|
17
|
+
hintTooltipText?: ReactNode;
|
|
18
|
+
hintLink?: {
|
|
19
|
+
href?: string;
|
|
20
|
+
text: string;
|
|
21
|
+
};
|
|
22
|
+
showHintLink?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function TotalValueBlock({ value, totalSumType, hint, hintAppearance, showHintTooltip, hintTooltipText, hintLink, showHintLink, }: TotalValueBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InfoFilledSVG } from '@sbercloud/uikit-product-icons';
|
|
3
|
+
import { useLocale } from '@sbercloud/uikit-product-locale';
|
|
4
|
+
import { AlarmFilledSVG, CrossFilledSVG, QuestionSVG } from '@snack-uikit/icons';
|
|
5
|
+
import { Link } from '@snack-uikit/link';
|
|
6
|
+
import { Tooltip } from '@snack-uikit/tooltip';
|
|
7
|
+
import { Typography } from '@snack-uikit/typography';
|
|
8
|
+
import { formatCurrency } from '../../../../helpers';
|
|
9
|
+
import styles from './styles.module.css';
|
|
10
|
+
export const APPEARANCE_STATE = {
|
|
11
|
+
Default: 'default',
|
|
12
|
+
UserError: 'userError',
|
|
13
|
+
SystemError: 'systemError',
|
|
14
|
+
Warning: 'warning',
|
|
15
|
+
};
|
|
16
|
+
function getAppearanceIcon(appearance) {
|
|
17
|
+
let Component;
|
|
18
|
+
switch (appearance) {
|
|
19
|
+
case APPEARANCE_STATE.Warning:
|
|
20
|
+
Component = AlarmFilledSVG;
|
|
21
|
+
break;
|
|
22
|
+
case APPEARANCE_STATE.UserError:
|
|
23
|
+
Component = CrossFilledSVG;
|
|
24
|
+
break;
|
|
25
|
+
case APPEARANCE_STATE.SystemError:
|
|
26
|
+
Component = QuestionSVG;
|
|
27
|
+
break;
|
|
28
|
+
case APPEARANCE_STATE.Default:
|
|
29
|
+
default:
|
|
30
|
+
Component = InfoFilledSVG;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return _jsx(Component, { size: 16, "data-appearance": appearance, className: styles.hintIcon });
|
|
34
|
+
}
|
|
35
|
+
export function TotalValueBlock({ value, totalSumType = 'equal', hint, hintAppearance = APPEARANCE_STATE.Default, showHintTooltip, hintTooltipText, hintLink, showHintLink, }) {
|
|
36
|
+
const { t } = useLocale('PriceSummary');
|
|
37
|
+
const totalSumPrefix = totalSumType === 'from' ? `${t('totalSumFromPrefix')} ` : '';
|
|
38
|
+
return (_jsxs("div", { className: styles.content, "data-appearance": hintAppearance, children: [_jsx(Typography.LightHeadlineS, { children: value !== undefined ? `${totalSumPrefix}${formatCurrency(Number(value))}` : 'N/A' }), _jsx(Tooltip, { open: showHintTooltip && hintTooltipText ? undefined : false, tip: hintTooltipText, placement: 'left-start', children: hint && (_jsxs("div", { className: styles.hint, "data-appearance": hintAppearance, children: [getAppearanceIcon(hintAppearance), _jsx(Typography.SansBodyS, { children: hint })] })) }), showHintLink && (_jsx(Link, { textMode: 'accent', appearance: 'neutral', size: 's', href: hintLink === null || hintLink === void 0 ? void 0 : hintLink.href, text: hintLink === null || hintLink === void 0 ? void 0 : hintLink.text, className: styles.link }))] }));
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TotalValueBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TotalValueBlock';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.content{
|
|
2
|
+
display:flex;
|
|
3
|
+
flex-direction:column;
|
|
4
|
+
text-align:start;
|
|
5
|
+
}
|
|
6
|
+
.content[data-appearance=userError]{
|
|
7
|
+
color:var(--sys-red-text-main, #7a2d2d);
|
|
8
|
+
}
|
|
9
|
+
.content[data-appearance=warning]{
|
|
10
|
+
color:var(--sys-yellow-text-main, #815f19);
|
|
11
|
+
}
|
|
12
|
+
.content[data-appearance=systemError]{
|
|
13
|
+
color:var(--sys-neutral-text-disabled, #aaaebd);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.hint{
|
|
17
|
+
display:flex;
|
|
18
|
+
align-items:center;
|
|
19
|
+
gap:var(--dimension-025m, 2px);
|
|
20
|
+
color:var(--sys-neutral-text-light, #8b8e9b);
|
|
21
|
+
}
|
|
22
|
+
.hint[data-appearance=userError]{
|
|
23
|
+
color:var(--sys-red-text-main, #7a2d2d);
|
|
24
|
+
}
|
|
25
|
+
.hint[data-appearance=warning]{
|
|
26
|
+
color:var(--sys-yellow-text-main, #815f19);
|
|
27
|
+
}
|
|
28
|
+
.hint[data-appearance=systemError]{
|
|
29
|
+
color:var(--sys-neutral-text-disabled, #aaaebd);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.hintIcon{
|
|
33
|
+
flex-shrink:0;
|
|
34
|
+
box-sizing:content-box;
|
|
35
|
+
}
|
|
36
|
+
.hintIcon[data-appearance=default]{
|
|
37
|
+
color:var(--sys-neutral-accent-default, #787b8a);
|
|
38
|
+
}
|
|
39
|
+
.hintIcon[data-appearance=userError]{
|
|
40
|
+
color:var(--sys-red-accent-default, #cb3f3e);
|
|
41
|
+
}
|
|
42
|
+
.hintIcon[data-appearance=warning]{
|
|
43
|
+
color:var(--sys-yellow-accent-default, #e2b134);
|
|
44
|
+
}
|
|
45
|
+
.hintIcon[data-appearance=systemError]{
|
|
46
|
+
color:var(--sys-neutral-text-disabled, #aaaebd);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.link{
|
|
50
|
+
margin-left:18px;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PriceSummary';
|