@cloud-ru/ds-uikit-product-price-summary 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.
- package/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +408 -0
- package/dist/cjs/components/ContentBlock/ContentBlock.d.ts +7 -0
- package/dist/cjs/components/ContentBlock/ContentBlock.js +24 -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 +22 -0
- package/dist/cjs/components/PriceSummary/PriceSummary.js +23 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.js +16 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/index.d.ts +1 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/index.js +17 -0
- package/dist/cjs/components/PriceSummary/components/CoveredByGrantLabel/styles.module.css +6 -0
- package/dist/cjs/components/PriceSummary/components/DiscountBlock/DiscountBlock.d.ts +5 -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 +5 -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 +8 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/HeaderBlock.js +17 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/constants.d.ts +4 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/constants.js +7 -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/HeaderBlock/types.d.ts +3 -0
- package/dist/cjs/components/PriceSummary/components/HeaderBlock/types.js +2 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.d.ts +6 -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 +13 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js +23 -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 +27 -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 +36 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts +5 -0
- package/dist/cjs/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js +19 -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 +7 -0
- package/dist/cjs/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.js +26 -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 +17 -0
- package/dist/cjs/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.js +22 -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 +227 -0
- package/dist/cjs/components/PriceSummarySmall/PriceSummarySmall.d.ts +18 -0
- package/dist/cjs/components/PriceSummarySmall/PriceSummarySmall.js +23 -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 +242 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/constants.d.ts +34 -0
- package/dist/cjs/constants.js +37 -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 +1 -0
- package/dist/cjs/hooks/index.js +17 -0
- package/dist/cjs/hooks/usePeriodFormat.d.ts +5 -0
- package/dist/cjs/hooks/usePeriodFormat.js +21 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/locale/index.d.ts +107 -0
- package/dist/cjs/locale/index.js +58 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +673 -0
- package/dist/cjs/types.d.ts +79 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/getAppearanceIcon.d.ts +2 -0
- package/dist/cjs/utils/getAppearanceIcon.js +25 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +17 -0
- package/dist/esm/components/ContentBlock/ContentBlock.d.ts +7 -0
- package/dist/esm/components/ContentBlock/ContentBlock.js +18 -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 +22 -0
- package/dist/esm/components/PriceSummary/PriceSummary.js +17 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.js +10 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/index.d.ts +1 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/index.js +1 -0
- package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/styles.module.css +6 -0
- package/dist/esm/components/PriceSummary/components/DiscountBlock/DiscountBlock.d.ts +5 -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 +5 -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 +8 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/HeaderBlock.js +11 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/constants.d.ts +4 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/constants.js +4 -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/HeaderBlock/types.d.ts +3 -0
- package/dist/esm/components/PriceSummary/components/HeaderBlock/types.js +1 -0
- package/dist/esm/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.d.ts +6 -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 +13 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js +17 -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 +21 -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 +36 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.d.ts +5 -0
- package/dist/esm/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.js +13 -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 +7 -0
- package/dist/esm/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.js +20 -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 +17 -0
- package/dist/esm/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.js +16 -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 +227 -0
- package/dist/esm/components/PriceSummarySmall/PriceSummarySmall.d.ts +18 -0
- package/dist/esm/components/PriceSummarySmall/PriceSummarySmall.js +17 -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 +242 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/constants.d.ts +34 -0
- package/dist/esm/constants.js +34 -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 +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/usePeriodFormat.d.ts +5 -0
- package/dist/esm/hooks/usePeriodFormat.js +17 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/locale/index.d.ts +107 -0
- package/dist/esm/locale/index.js +55 -0
- package/dist/esm/style.css +673 -0
- package/dist/esm/types.d.ts +79 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/getAppearanceIcon.d.ts +2 -0
- package/dist/esm/utils/getAppearanceIcon.js +22 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +61 -0
- package/src/components/ContentBlock/ContentBlock.tsx +41 -0
- package/src/components/ContentBlock/index.ts +1 -0
- package/src/components/ContentBlock/styles.module.scss +14 -0
- package/src/components/PriceSummary/PriceSummary.tsx +107 -0
- package/src/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.tsx +32 -0
- package/src/components/PriceSummary/components/CoveredByGrantLabel/index.ts +1 -0
- package/src/components/PriceSummary/components/CoveredByGrantLabel/styles.module.scss +8 -0
- package/src/components/PriceSummary/components/DiscountBlock/DiscountBlock.tsx +42 -0
- package/src/components/PriceSummary/components/DiscountBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/DiscountBlock/styles.module.scss +17 -0
- package/src/components/PriceSummary/components/DiscountPercentCell/DiscountPercentCell.tsx +30 -0
- package/src/components/PriceSummary/components/DiscountPercentCell/index.ts +1 -0
- package/src/components/PriceSummary/components/DiscountPercentCell/styles.module.scss +7 -0
- package/src/components/PriceSummary/components/Divider/Divider.tsx +5 -0
- package/src/components/PriceSummary/components/Divider/index.ts +1 -0
- package/src/components/PriceSummary/components/Divider/styles.module.scss +8 -0
- package/src/components/PriceSummary/components/HeaderBlock/HeaderBlock.tsx +41 -0
- package/src/components/PriceSummary/components/HeaderBlock/constants.ts +4 -0
- package/src/components/PriceSummary/components/HeaderBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/HeaderBlock/styles.module.scss +16 -0
- package/src/components/PriceSummary/components/HeaderBlock/types.ts +5 -0
- package/src/components/PriceSummary/components/InvoiceBlock/InvoiceBlock.tsx +37 -0
- package/src/components/PriceSummary/components/InvoiceBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceBlock/styles.module.scss +15 -0
- package/src/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.tsx +63 -0
- package/src/components/PriceSummary/components/InvoiceDetailsBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceDetailsBlock/styles.module.scss +18 -0
- package/src/components/PriceSummary/components/InvoiceItemBlock/InvoiceItemBlock.tsx +82 -0
- package/src/components/PriceSummary/components/InvoiceItemBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceItemBlock/styles.module.scss +42 -0
- package/src/components/PriceSummary/components/InvoiceItemLabelCell/InvoiceItemLabelCell.tsx +37 -0
- package/src/components/PriceSummary/components/InvoiceItemLabelCell/index.ts +1 -0
- package/src/components/PriceSummary/components/InvoiceItemLabelCell/styles.module.scss +16 -0
- package/src/components/PriceSummary/components/PeriodDropdown/PeriodDropdown.tsx +54 -0
- package/src/components/PriceSummary/components/PeriodDropdown/index.ts +1 -0
- package/src/components/PriceSummary/components/PeriodDropdown/styles.module.scss +18 -0
- package/src/components/PriceSummary/components/TotalValueBlock/TotalValueBlock.tsx +82 -0
- package/src/components/PriceSummary/components/TotalValueBlock/index.ts +1 -0
- package/src/components/PriceSummary/components/TotalValueBlock/styles.module.scss +54 -0
- package/src/components/PriceSummary/index.ts +1 -0
- package/src/components/PriceSummary/styles.module.scss +27 -0
- package/src/components/PriceSummarySmall/PriceSummarySmall.tsx +89 -0
- package/src/components/PriceSummarySmall/index.ts +1 -0
- package/src/components/PriceSummarySmall/styles.module.scss +42 -0
- package/src/components/index.ts +2 -0
- package/src/constants.ts +37 -0
- package/src/helpers/formatters.ts +12 -0
- package/src/helpers/index.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/usePeriodFormat.ts +30 -0
- package/src/index.ts +5 -0
- package/src/locale/index.ts +59 -0
- package/src/types.ts +93 -0
- package/src/utils/getAppearanceIcon.tsx +26 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { QuestionTooltipProps } from '@cloud-ru/ds-tooltip';
|
|
2
|
+
import { ValueOf } from '@cloud-ru/ds-utils';
|
|
3
|
+
import { APPEARANCE_STATE, PRICE_PERIOD } from './constants';
|
|
4
|
+
export type PricePeriod = ValueOf<typeof PRICE_PERIOD>;
|
|
5
|
+
/** Префикс перед итоговой суммой: без префикса (`equal`) или «от» (`from`). */
|
|
6
|
+
export type TotalSumType = 'equal' | 'from';
|
|
7
|
+
/** Визуальное состояние подсказки и дельты общей суммы. */
|
|
8
|
+
export type AppearanceState = ValueOf<typeof APPEARANCE_STATE>;
|
|
9
|
+
export type DiscountItem = {
|
|
10
|
+
/** Сумма скидки в валюте (в UI выводится со знаком «−»). */
|
|
11
|
+
value: number;
|
|
12
|
+
/** Процент скидки для бейджа `−N%`. */
|
|
13
|
+
percent?: number;
|
|
14
|
+
/** Контент тултипа-пояснения к скидке. */
|
|
15
|
+
tooltip?: QuestionTooltipProps['tip'];
|
|
16
|
+
};
|
|
17
|
+
export type DiscountDetails = {
|
|
18
|
+
/** Базовая цена до применения скидок. */
|
|
19
|
+
price: number;
|
|
20
|
+
/** Список применённых скидок. */
|
|
21
|
+
discounts: DiscountItem[];
|
|
22
|
+
};
|
|
23
|
+
export type PriceInvoiceItem = {
|
|
24
|
+
/** Подпись строки детализации. */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Скидка для строки с ценой. */
|
|
27
|
+
discount?: DiscountItem;
|
|
28
|
+
};
|
|
29
|
+
export type DiscountInvoiceItem = {
|
|
30
|
+
/** Скидка без собственной цены. */
|
|
31
|
+
discount: DiscountItem;
|
|
32
|
+
};
|
|
33
|
+
export type BaseInvoiceItem = (PriceInvoiceItem | DiscountInvoiceItem) & {
|
|
34
|
+
/** Тултип для label строки детализации. */
|
|
35
|
+
labelTooltip?: QuestionTooltipProps['tip'];
|
|
36
|
+
/** Цена строки в валюте. */
|
|
37
|
+
price?: number;
|
|
38
|
+
/** Цвет цены: обычный или акцент изменения. */
|
|
39
|
+
priceColor?: 'default' | 'changed';
|
|
40
|
+
/** Скрыть колонку цены вне зависимости от значения `price`. */
|
|
41
|
+
hidePrice?: boolean;
|
|
42
|
+
/** Ограничение количества строк в label. */
|
|
43
|
+
labelMaxLines?: number;
|
|
44
|
+
/** Количество рядом с title/label (например, `×2`). */
|
|
45
|
+
quantity?: string | number;
|
|
46
|
+
/** Показать верхний разделитель перед строкой. */
|
|
47
|
+
topDivider?: boolean;
|
|
48
|
+
/** Показать нижний разделитель после строки. */
|
|
49
|
+
bottomDivider?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type PrimaryInvoiceItem = BaseInvoiceItem & {
|
|
52
|
+
/** Явная отметка основной строки. */
|
|
53
|
+
primary: true;
|
|
54
|
+
/** Флаг покрытия позиции грантом (только для primary-строк). */
|
|
55
|
+
coveredByGrant?: boolean;
|
|
56
|
+
};
|
|
57
|
+
export type SecondaryInvoiceItem = BaseInvoiceItem & {
|
|
58
|
+
/** Secondary-строка (по умолчанию, если `primary` не задан). */
|
|
59
|
+
primary?: false;
|
|
60
|
+
coveredByGrant?: never;
|
|
61
|
+
};
|
|
62
|
+
/** Строка детализации заказа. */
|
|
63
|
+
export type InvoiceItem = PrimaryInvoiceItem | SecondaryInvoiceItem;
|
|
64
|
+
export type InvoiceDetails = {
|
|
65
|
+
/** Заголовок секции детализации. */
|
|
66
|
+
title?: string;
|
|
67
|
+
/** Количество рядом с заголовком секции. */
|
|
68
|
+
quantity?: string | number;
|
|
69
|
+
/** Цена секции детализации. */
|
|
70
|
+
price?: number;
|
|
71
|
+
/** Строки секции детализации. */
|
|
72
|
+
items: InvoiceItem[];
|
|
73
|
+
};
|
|
74
|
+
export type PriceDeltaDetails = {
|
|
75
|
+
/** Величина изменения цены. */
|
|
76
|
+
value: number;
|
|
77
|
+
/** Тип изменения: повышение или снижение. */
|
|
78
|
+
type: 'increased' | 'decreased';
|
|
79
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppearanceIcon = getAppearanceIcon;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
function getAppearanceIcon(appearance, className) {
|
|
8
|
+
let Component;
|
|
9
|
+
switch (appearance) {
|
|
10
|
+
case constants_1.APPEARANCE_STATE.Warning:
|
|
11
|
+
Component = system_1.NotifierWarningFilledSVG;
|
|
12
|
+
break;
|
|
13
|
+
case constants_1.APPEARANCE_STATE.UserError:
|
|
14
|
+
Component = system_1.CrossSVG;
|
|
15
|
+
break;
|
|
16
|
+
case constants_1.APPEARANCE_STATE.SystemError:
|
|
17
|
+
Component = system_1.QuestionSVG;
|
|
18
|
+
break;
|
|
19
|
+
case constants_1.APPEARANCE_STATE.Default:
|
|
20
|
+
default:
|
|
21
|
+
Component = system_1.NotifierInfoFilledSVG;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
return (0, jsx_runtime_1.jsx)(Component, { size: 16, "data-appearance": appearance, className: className });
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getAppearanceIcon';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getAppearanceIcon"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export type ContentBlockProps = {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
dataError?: boolean;
|
|
5
|
+
onRetry?(): void;
|
|
6
|
+
};
|
|
7
|
+
export declare function ContentBlock({ loading, dataError, onRetry, children }: PropsWithChildren<ContentBlockProps>): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | null | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
3
|
+
import { UpdateSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
4
|
+
import { Sun } from '@cloud-ru/ds-loader';
|
|
5
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
6
|
+
import { TEST_IDS } from '../../constants.js';
|
|
7
|
+
import { priceSummaryLocale } from '../../locale/index.js';
|
|
8
|
+
import styles from './styles.module.css';
|
|
9
|
+
export function ContentBlock({ loading, dataError, onRetry, children }) {
|
|
10
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
11
|
+
if (loading) {
|
|
12
|
+
return (_jsx("div", { className: styles.loadingBlock, "data-test-id": TEST_IDS.loadingBlock, children: _jsx(Sun, { size: 'm' }) }));
|
|
13
|
+
}
|
|
14
|
+
if (dataError) {
|
|
15
|
+
return (_jsxs("div", { className: styles.dataErrorBlock, children: [_jsx(Button, { view: 'function', icon: _jsx(UpdateSVG, {}), onClick: onRetry, "data-test-id": TEST_IDS.contentBlockRetry }), _jsx(Typography, { variant: VARIANT.body, size: SIZE.s, children: t('dataError') })] }));
|
|
16
|
+
}
|
|
17
|
+
return children;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContentBlock.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContentBlock.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.loadingBlock{
|
|
2
|
+
display:flex;
|
|
3
|
+
justify-content:center;
|
|
4
|
+
padding:var(--sn-primitive-dimension-4, 4px);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.dataErrorBlock{
|
|
8
|
+
display:flex;
|
|
9
|
+
flex-direction:column;
|
|
10
|
+
align-items:center;
|
|
11
|
+
color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LinkProps } from '@cloud-ru/ds-link';
|
|
2
|
+
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
3
|
+
import { DiscountDetails, InvoiceDetails } from '../../types.js';
|
|
4
|
+
import { ContentBlockProps } from '../ContentBlock/index.js';
|
|
5
|
+
import { HeaderBlockProps } from './components/HeaderBlock/index.js';
|
|
6
|
+
import { TotalValueBlockProps } from './components/TotalValueBlock/index.js';
|
|
7
|
+
export type PriceSummaryProps = WithSupportProps<TotalValueBlockProps & HeaderBlockProps & ContentBlockProps & {
|
|
8
|
+
/** Блок базовой цены и скидок. */
|
|
9
|
+
discount?: DiscountDetails;
|
|
10
|
+
/** Секции детализации заказа в аккордеоне. */
|
|
11
|
+
invoice?: InvoiceDetails[];
|
|
12
|
+
/** Начальное состояние раскрытия аккордеона invoice. */
|
|
13
|
+
invoiceExpandedDefault?: boolean;
|
|
14
|
+
/** Ссылка «Подробнее о расчёте». */
|
|
15
|
+
docsLink?: {
|
|
16
|
+
href?: LinkProps['href'];
|
|
17
|
+
label?: LinkProps['label'];
|
|
18
|
+
};
|
|
19
|
+
/** Дополнительный класс корневого контейнера. */
|
|
20
|
+
className?: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function PriceSummary({ value, totalSumType, hint, period, onPeriodChanged, periodOptions, promoBadge, loading, dataError, onRetry, discount, invoice, invoiceExpandedDefault, docsLink, className, hintAppearance, showHintTooltip, hintTooltipText, hintLink, showHintLink, valueDelta, vatType, ...rest }: PriceSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link } from '@cloud-ru/ds-link';
|
|
3
|
+
import { BACKGROUND_PREDEFINED_FILL, backgroundPredefinedFillToAcrylic } from '@cloud-ru/ds-materials';
|
|
4
|
+
import { extractSupportProps } from '@cloud-ru/ds-utils';
|
|
5
|
+
import cn from 'classnames';
|
|
6
|
+
import { priceSummaryLocale } from '../../locale/index.js';
|
|
7
|
+
import { ContentBlock } from '../ContentBlock/index.js';
|
|
8
|
+
import { DiscountBlock } from './components/DiscountBlock/index.js';
|
|
9
|
+
import { HeaderBlock } from './components/HeaderBlock/index.js';
|
|
10
|
+
import { InvoiceBlock } from './components/InvoiceBlock/index.js';
|
|
11
|
+
import { TotalValueBlock } from './components/TotalValueBlock/index.js';
|
|
12
|
+
import styles from './styles.module.css';
|
|
13
|
+
export function PriceSummary({ value, totalSumType, hint, period, onPeriodChanged, periodOptions, promoBadge, loading, dataError, onRetry, discount, invoice, invoiceExpandedDefault = true, docsLink, className, hintAppearance, showHintTooltip = false, hintTooltipText, hintLink, showHintLink, valueDelta, vatType, ...rest }) {
|
|
14
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
15
|
+
const { appearance, level } = backgroundPredefinedFillToAcrylic(BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
|
|
16
|
+
return (_jsxs("div", { className: cn(styles.priceSummary, className), "data-acrylic-appearance": appearance, "data-acrylic-level": level, ...extractSupportProps(rest), children: [_jsx("span", { className: styles.acrylic, "aria-hidden": true, "data-acrylic-background": true }), _jsxs("div", { className: styles.content, children: [_jsx(HeaderBlock, { period: period, onPeriodChanged: onPeriodChanged, periodOptions: periodOptions, promoBadge: promoBadge, vatType: vatType }), _jsxs(ContentBlock, { loading: loading, dataError: dataError, onRetry: onRetry, children: [discount && _jsx(DiscountBlock, { value: discount }), _jsx(TotalValueBlock, { value: value, totalSumType: totalSumType, hint: hint, hintAppearance: hintAppearance, showHintTooltip: showHintTooltip, hintTooltipText: hintTooltipText, hintLink: hintLink, showHintLink: showHintLink, valueDelta: valueDelta }), invoice && invoice.length > 0 && (_jsx(InvoiceBlock, { invoice: invoice, invoiceExpandedDefault: invoiceExpandedDefault })), docsLink?.href && _jsx(Link, { label: docsLink.label || t('docsLink'), href: docsLink.href, target: '_blank' })] })] })] }));
|
|
17
|
+
}
|
package/dist/esm/components/PriceSummary/components/CoveredByGrantLabel/CoveredByGrantLabel.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PromoTag, ROLE_APPEARANCE } from '@cloud-ru/ds-promo-tag';
|
|
3
|
+
import { QuestionTooltip } from '@cloud-ru/ds-tooltip';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
6
|
+
import styles from './styles.module.css';
|
|
7
|
+
export function CoveredByGrantLabel({ covered, className }) {
|
|
8
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
9
|
+
return (_jsxs("div", { className: cn(styles.coveredByGrant, className), children: [_jsx(PromoTag, { appearance: covered ? 'green' : 'neutral', roleAppearance: ROLE_APPEARANCE.Decor, label: covered ? t('coveredByGrant') : t('notCoveredByGrant') }), _jsx(QuestionTooltip, { tip: covered ? t('coveredByGrantTooltip') : t('notCoveredByGrantTooltip'), size: 'xs', placement: 'top', trigger: 'hover', tabIndex: -1 })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CoveredByGrantLabel.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CoveredByGrantLabel.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import { formatCurrency } from '../../../../helpers/index.js';
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
6
|
+
import { DiscountPercentCell } from '../DiscountPercentCell/index.js';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function DiscountBlock({ value }) {
|
|
9
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.discountGrid, children: [_jsx(Typography, { variant: VARIANT.body, size: SIZE.s, as: 'div', children: t('basePrice') }), _jsx(Typography, { variant: VARIANT.label, size: SIZE.m, as: '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 }), _jsx(Typography, { variant: VARIANT.label, size: SIZE.m, as: 'div', className: styles.discountCell, children: formatCurrency(-Math.abs(discount.value)) })] }, index))) })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountBlock.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountBlock.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.discountGrid{
|
|
2
|
+
display:grid;
|
|
3
|
+
grid-template-columns:1fr 1fr;
|
|
4
|
+
-moz-column-gap:var(--sn-primitive-dimension-8, 8px);
|
|
5
|
+
column-gap:var(--sn-primitive-dimension-8, 8px);
|
|
6
|
+
color:var(--sn-theme-color-available-version-textSecondary, var(--sn-brand-color-text-version-secondary, rgba(65, 66, 78, 0.8)));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.priceCell{
|
|
10
|
+
justify-self:end;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.discountCell{
|
|
14
|
+
justify-self:end;
|
|
15
|
+
color:var(--sn-theme-color-red-text, var(--sn-primitive-color-red-45, #a93533));
|
|
16
|
+
}
|
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 { QuestionTooltip } from '@cloud-ru/ds-tooltip';
|
|
3
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
4
|
+
import { formatNumber } from '@cloud-ru/ft-formatters';
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
6
|
+
import styles from './styles.module.css';
|
|
7
|
+
export function DiscountPercentCell({ discount }) {
|
|
8
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
9
|
+
return (_jsx("div", { className: styles.percentCell, children: discount.percent && (_jsxs(_Fragment, { children: [_jsxs(Typography, { variant: VARIANT.body, size: SIZE.s, children: [t('discount'), " ", formatNumber(-Math.abs(discount.percent)), "%"] }), discount.tooltip && _jsx(QuestionTooltip, { tip: discount.tooltip })] })) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountPercentCell.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DiscountPercentCell.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Divider(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Divider.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Divider.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
.divider{
|
|
2
|
+
width:100%;
|
|
3
|
+
height:0;
|
|
4
|
+
margin:var(--sn-primitive-dimension-4, 4px) 0;
|
|
5
|
+
border-top:var(--sn-primitive-strokeWeight-strokeRegular, 1px) dashed var(--sn-theme-color-neutral-decor, var(--sn-brand-color-neutral-80, var(--sn-primitive-color-gray-80, #e3e5ed)));
|
|
6
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PromoTagProps } from '@cloud-ru/ds-promo-tag';
|
|
2
|
+
import { PeriodDropdownProps } from '../PeriodDropdown/index.js';
|
|
3
|
+
import { VatType } from './types.js';
|
|
4
|
+
export type HeaderBlockProps = PeriodDropdownProps & {
|
|
5
|
+
vatType?: VatType;
|
|
6
|
+
promoBadge?: Pick<PromoTagProps, 'label' | 'appearance'> | string;
|
|
7
|
+
};
|
|
8
|
+
export declare function HeaderBlock({ period, onPeriodChanged, periodOptions, promoBadge, vatType, }: HeaderBlockProps): 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 { PromoTag } from '@cloud-ru/ds-promo-tag';
|
|
3
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
4
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
5
|
+
import { PeriodDropdown } from '../PeriodDropdown/index.js';
|
|
6
|
+
import { VAT_TYPE } from './constants.js';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function HeaderBlock({ period, onPeriodChanged, periodOptions, promoBadge, vatType = VAT_TYPE.Including, }) {
|
|
9
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
10
|
+
return (_jsxs(_Fragment, { children: [promoBadge && (_jsx("div", { className: styles.promoBadge, children: _jsx(PromoTag, { ...(typeof promoBadge === 'string' ? { label: promoBadge } : promoBadge) }) })), _jsxs("div", { className: styles.headline, children: [_jsx(PeriodDropdown, { period: period, onPeriodChanged: onPeriodChanged, periodOptions: periodOptions }), _jsx(Typography, { variant: VARIANT.body, size: SIZE.m, className: styles.vat, children: t(vatType === VAT_TYPE.Including ? 'vat' : 'vatExcluded') })] })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeaderBlock.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeaderBlock.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.headline{
|
|
2
|
+
display:flex;
|
|
3
|
+
gap:var(--sn-primitive-dimension-4, 4px);
|
|
4
|
+
align-items:center;
|
|
5
|
+
justify-content:space-between;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.vat{
|
|
9
|
+
color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.promoBadge{
|
|
13
|
+
display:flex;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InvoiceDetails } from '../../../../types.js';
|
|
2
|
+
export type InvoiceBlockProps = {
|
|
3
|
+
invoice: InvoiceDetails[];
|
|
4
|
+
invoiceExpandedDefault?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function InvoiceBlock({ invoice, invoiceExpandedDefault }: InvoiceBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Accordion } from '@cloud-ru/ds-accordion';
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { TEST_IDS } from '../../../../constants.js';
|
|
5
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
6
|
+
import { InvoiceDetailsBlock } from '../InvoiceDetailsBlock/index.js';
|
|
7
|
+
import styles from './styles.module.css';
|
|
8
|
+
export function InvoiceBlock({ invoice, invoiceExpandedDefault }) {
|
|
9
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
10
|
+
const invoiceBlockId = useId();
|
|
11
|
+
return (_jsx("div", { className: styles.accordion, children: _jsx(Accordion, { expandedDefault: invoiceExpandedDefault ? invoiceBlockId : undefined, children: _jsx(Accordion.CollapseBlockTertiary, { id: invoiceBlockId, title: t('orderDetails'), "data-test-id": TEST_IDS.orderDetails, children: _jsx("div", { className: styles.accordionContent, "data-test-id": TEST_IDS.orderDetailsContent, children: invoice.map((invoice, index) => (_jsx(InvoiceDetailsBlock, { invoice: invoice }, index))) }) }) }) }));
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceBlock.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceBlock.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.accordion{
|
|
2
|
+
--space-accordion-collapse-block-secondary-horizontal-padding:0;
|
|
3
|
+
--space-accordion-collapse-block-secondary-vertical-padding:var(--sn-primitive-dimension-8, 8px);
|
|
4
|
+
--space-accordion-collapse-block-secondary-gap:var(--sn-primitive-dimension-8, 8px);
|
|
5
|
+
--border-width-accordion-collapse-block-secondary:0;
|
|
6
|
+
--accordion-header-padding-vertical:0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.accordionContent{
|
|
10
|
+
display:flex;
|
|
11
|
+
flex-direction:column;
|
|
12
|
+
gap:var(--sn-primitive-dimension-8, 8px);
|
|
13
|
+
}
|
package/dist/esm/components/PriceSummary/components/InvoiceDetailsBlock/InvoiceDetailsBlock.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
3
|
+
import { formatCurrency, formatQuantity } from '../../../../helpers/index.js';
|
|
4
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
5
|
+
import { CoveredByGrantLabel } from '../CoveredByGrantLabel/index.js';
|
|
6
|
+
import { Divider } from '../Divider/index.js';
|
|
7
|
+
import { InvoiceItemBlock } from '../InvoiceItemBlock/index.js';
|
|
8
|
+
import styles from './styles.module.css';
|
|
9
|
+
export function InvoiceDetailsBlock({ invoice }) {
|
|
10
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
11
|
+
const primaryItems = invoice.items.filter(item => item.primary);
|
|
12
|
+
const firstValue = primaryItems[0]?.coveredByGrant;
|
|
13
|
+
const allSameValue = primaryItems.length > 0 && primaryItems.every(item => item.coveredByGrant === firstValue);
|
|
14
|
+
const showBlockLabel = allSameValue && firstValue !== undefined;
|
|
15
|
+
const showItemLabels = !showBlockLabel;
|
|
16
|
+
return (_jsxs("div", { className: styles.main, children: [showBlockLabel && _jsx(CoveredByGrantLabel, { covered: firstValue }), invoice.title && (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.header, children: [_jsx(Typography, { variant: VARIANT.label, size: SIZE.m, children: invoice.title }), invoice.quantity && (_jsx(Typography, { variant: VARIANT.label, size: SIZE.m, children: formatQuantity(invoice.quantity) }))] }), _jsx(Divider, {})] })), invoice.items.map((item, index) => (_jsx(InvoiceItemBlock, { item: item, index: index, showCoveredByGrantLabel: showItemLabels }, index))), invoice.price !== undefined && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsx("div", { className: styles.footer, children: _jsxs(Typography, { variant: VARIANT.label, size: SIZE.m, children: [t('price'), ": ", formatCurrency(invoice.price)] }) })] }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceDetailsBlock.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceDetailsBlock.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.main{
|
|
2
|
+
padding:var(--sn-primitive-dimension-4, 4px) var(--sn-primitive-dimension-8, 8px);
|
|
3
|
+
border:var(--sn-primitive-strokeWeight-strokeRegular, 1px) dashed var(--sn-theme-color-neutral-decor, var(--sn-brand-color-neutral-80, var(--sn-primitive-color-gray-80, #e3e5ed)));
|
|
4
|
+
border-radius:var(--sn-brand-anatomy-radius-block-m, var(--sn-primitive-dimension-4, 4px));
|
|
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 { InvoiceItem } from '../../../../types.js';
|
|
2
|
+
export type InvoiceItemBlockProps = {
|
|
3
|
+
item: InvoiceItem;
|
|
4
|
+
index: number;
|
|
5
|
+
showCoveredByGrantLabel?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function InvoiceItemBlock({ item, index, showCoveredByGrantLabel }: InvoiceItemBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
3
|
+
import { formatCurrency } from '../../../../helpers/index.js';
|
|
4
|
+
import { priceSummaryLocale } from '../../../../locale/index.js';
|
|
5
|
+
import { CoveredByGrantLabel } from '../CoveredByGrantLabel/index.js';
|
|
6
|
+
import { DiscountPercentCell } from '../DiscountPercentCell/index.js';
|
|
7
|
+
import { Divider } from '../Divider/index.js';
|
|
8
|
+
import { InvoiceItemLabelCell } from '../InvoiceItemLabelCell/index.js';
|
|
9
|
+
import styles from './styles.module.css';
|
|
10
|
+
export function InvoiceItemBlock({ item, index, showCoveredByGrantLabel }) {
|
|
11
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
12
|
+
const isEven = (index + 1) % 2 === 0;
|
|
13
|
+
const isSecondary = item.primary === undefined ? isEven : !item.primary;
|
|
14
|
+
const getPriceItem = () => {
|
|
15
|
+
if (item.hidePrice) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return item.price !== undefined ? formatCurrency(item.price) : t('notAvailable');
|
|
19
|
+
};
|
|
20
|
+
return (_jsxs(_Fragment, { children: [item.topDivider && _jsx(Divider, {}), item.coveredByGrant !== undefined && showCoveredByGrantLabel && (_jsx(CoveredByGrantLabel, { covered: item.coveredByGrant })), _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 }) }), _jsx(Typography, { variant: VARIANT.body, size: SIZE.s, as: 'div', className: styles.priceCell, "data-secondary": isSecondary, "data-price-color": item.priceColor ?? 'default', children: getPriceItem() })] })), item.discount && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.percentCell, "data-secondary": isSecondary, children: _jsx(DiscountPercentCell, { discount: item.discount }) }), _jsx(Typography, { variant: VARIANT.body, size: SIZE.s, as: 'div', className: styles.discountCell, "data-secondary": isSecondary, children: formatCurrency(-Math.abs(item.discount.value)) })] }))] }), item.bottomDivider && _jsx(Divider, {})] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemBlock.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemBlock.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.itemGrid{
|
|
2
|
+
display:grid;
|
|
3
|
+
grid-template-columns:1fr auto;
|
|
4
|
+
-moz-column-gap:var(--sn-primitive-dimension-8, 8px);
|
|
5
|
+
column-gap:var(--sn-primitive-dimension-8, 8px);
|
|
6
|
+
}
|
|
7
|
+
.itemGrid[data-discount=true]{
|
|
8
|
+
margin-bottom:var(--sn-primitive-dimension-4, 4px);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.labelCell{
|
|
12
|
+
overflow:hidden;
|
|
13
|
+
display:flex;
|
|
14
|
+
gap:var(--sn-primitive-dimension-4, 4px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.priceCell{
|
|
18
|
+
justify-self:end;
|
|
19
|
+
}
|
|
20
|
+
.priceCell[data-price-color=changed]{
|
|
21
|
+
color:var(--sn-theme-color-green-accent, var(--sn-primitive-color-green-55, #41b954));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.labelCell[data-secondary=true],
|
|
25
|
+
.priceCell[data-secondary=true],
|
|
26
|
+
.percentCell[data-secondary=true]{
|
|
27
|
+
color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.discountCell{
|
|
31
|
+
justify-self:end;
|
|
32
|
+
color:var(--sn-theme-color-red-accent, var(--sn-primitive-color-red-55, #d52e33));
|
|
33
|
+
}
|
|
34
|
+
.discountCell[data-secondary=true]{
|
|
35
|
+
color:var(--sn-theme-color-available-version-textDisabled, var(--sn-brand-color-text-version-disabled, rgba(65, 66, 78, 0.3490196078)));
|
|
36
|
+
}
|