@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,42 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.itemGrid {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: 1fr auto;
|
|
6
|
+
column-gap: base.$sn-primitive-dimension-8;
|
|
7
|
+
|
|
8
|
+
&[data-discount='true'] {
|
|
9
|
+
margin-bottom: base.$sn-primitive-dimension-4;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.labelCell {
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: base.$sn-primitive-dimension-4;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.priceCell {
|
|
20
|
+
justify-self: end;
|
|
21
|
+
|
|
22
|
+
&[data-price-color='changed'] {
|
|
23
|
+
color: base.$sn-theme-color-green-accent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.labelCell,
|
|
28
|
+
.priceCell,
|
|
29
|
+
.percentCell {
|
|
30
|
+
&[data-secondary='true'] {
|
|
31
|
+
color: base.$sn-theme-color-available-version-textTertiary;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.discountCell {
|
|
36
|
+
justify-self: end;
|
|
37
|
+
color: base.$sn-theme-color-red-accent;
|
|
38
|
+
|
|
39
|
+
&[data-secondary='true'] {
|
|
40
|
+
color: base.$sn-theme-color-available-version-textDisabled;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { QuestionTooltip } from '@cloud-ru/ds-tooltip';
|
|
2
|
+
import { TruncateString } from '@cloud-ru/ds-truncate-string';
|
|
3
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
4
|
+
|
|
5
|
+
import { formatQuantity } from '../../../../helpers';
|
|
6
|
+
import { InvoiceItem } from '../../../../types';
|
|
7
|
+
import styles from './styles.module.scss';
|
|
8
|
+
|
|
9
|
+
export type InvoiceItemLabelCellProps = {
|
|
10
|
+
item: InvoiceItem;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function InvoiceItemLabelCell({ item }: InvoiceItemLabelCellProps) {
|
|
14
|
+
const isLabelVisible = 'label' in item && item.label !== undefined;
|
|
15
|
+
|
|
16
|
+
if (!isLabelVisible) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<div className={styles.labelCell}>
|
|
23
|
+
<Typography variant={VARIANT.body} size={SIZE.s} className={styles.label}>
|
|
24
|
+
{item.labelMaxLines ? <TruncateString text={item.label} maxLines={item.labelMaxLines} /> : item.label}
|
|
25
|
+
</Typography>
|
|
26
|
+
|
|
27
|
+
{item.labelTooltip && <QuestionTooltip tip={item.labelTooltip} />}
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
{item.quantity && (
|
|
31
|
+
<Typography variant={VARIANT.body} size={SIZE.s} className={styles.quantity}>
|
|
32
|
+
{formatQuantity(item.quantity)}
|
|
33
|
+
</Typography>
|
|
34
|
+
)}
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InvoiceItemLabelCell';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.labelCell {
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: base.$sn-primitive-dimension-2;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.label {
|
|
9
|
+
flex: 0 1 auto;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.quantity {
|
|
14
|
+
flex: 0 0 auto;
|
|
15
|
+
white-space: nowrap;
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
2
|
+
import { ButtonDropdown } from '@cloud-ru/ds-uikit-product-button-predefined';
|
|
3
|
+
|
|
4
|
+
import { PERIOD_OPTION_TEST_IDS, TEST_IDS } from '../../../../constants';
|
|
5
|
+
import { usePeriodFormat } from '../../../../hooks';
|
|
6
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
7
|
+
import { PricePeriod } from '../../../../types';
|
|
8
|
+
import styles from './styles.module.scss';
|
|
9
|
+
|
|
10
|
+
export type PeriodDropdownProps = {
|
|
11
|
+
period: PricePeriod;
|
|
12
|
+
periodOptions: PricePeriod[];
|
|
13
|
+
onPeriodChanged?(period: PricePeriod): void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function PeriodDropdown({ period, onPeriodChanged = () => {}, periodOptions }: PeriodDropdownProps) {
|
|
17
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
18
|
+
const formatPeriod = usePeriodFormat();
|
|
19
|
+
|
|
20
|
+
const actions = periodOptions
|
|
21
|
+
.filter(item => item !== period)
|
|
22
|
+
.map(item => ({
|
|
23
|
+
id: item,
|
|
24
|
+
content: { label: formatPeriod(item) },
|
|
25
|
+
onClick: () => onPeriodChanged(item),
|
|
26
|
+
'data-test-id': PERIOD_OPTION_TEST_IDS[item],
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={styles.period} data-single={actions.length === 0 ? true : undefined}>
|
|
31
|
+
<Typography variant={VARIANT.body} size={SIZE.m}>
|
|
32
|
+
{t('total')}
|
|
33
|
+
</Typography>
|
|
34
|
+
|
|
35
|
+
{actions.length === 0 && (
|
|
36
|
+
<div className={styles.single}>
|
|
37
|
+
<Typography variant={VARIANT.body} size={SIZE.m}>
|
|
38
|
+
{formatPeriod(period)}
|
|
39
|
+
</Typography>
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
{actions.length > 0 && (
|
|
44
|
+
<ButtonDropdown
|
|
45
|
+
size='s'
|
|
46
|
+
label={formatPeriod(period)}
|
|
47
|
+
items={actions}
|
|
48
|
+
closeDroplistOnItemClick
|
|
49
|
+
data-test-id={TEST_IDS.periodDropdown}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PeriodDropdown';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
.period {
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: base.$sn-primitive-dimension-8;
|
|
6
|
+
align-items: center;
|
|
7
|
+
|
|
8
|
+
&[data-single] {
|
|
9
|
+
gap: base.$sn-primitive-dimension-4;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.single {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
min-height: base.$sn-primitive-dimension-32;
|
|
17
|
+
color: base.$sn-theme-color-available-version-textTertiary;
|
|
18
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Link, ROLE_APPEARANCE } from '@cloud-ru/ds-link';
|
|
2
|
+
import { Tooltip } from '@cloud-ru/ds-tooltip';
|
|
3
|
+
import { SIZE, Typography, VARIANT, WEIGHT } from '@cloud-ru/ds-typography';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { APPEARANCE_STATE } from '../../../../constants';
|
|
7
|
+
import { formatCurrency } from '../../../../helpers';
|
|
8
|
+
import { priceSummaryLocale } from '../../../../locale';
|
|
9
|
+
import { AppearanceState, PriceDeltaDetails, TotalSumType } from '../../../../types';
|
|
10
|
+
import { getAppearanceIcon } from '../../../../utils';
|
|
11
|
+
import styles from './styles.module.scss';
|
|
12
|
+
|
|
13
|
+
export type TotalValueBlockProps = {
|
|
14
|
+
value?: number;
|
|
15
|
+
valueDelta?: PriceDeltaDetails;
|
|
16
|
+
totalSumType?: TotalSumType;
|
|
17
|
+
hint?: string;
|
|
18
|
+
hintAppearance?: AppearanceState;
|
|
19
|
+
showHintTooltip?: boolean;
|
|
20
|
+
hintTooltipText?: ReactNode;
|
|
21
|
+
hintLink?: {
|
|
22
|
+
href?: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
showHintLink?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function TotalValueBlock({
|
|
29
|
+
value,
|
|
30
|
+
totalSumType = 'equal',
|
|
31
|
+
hint,
|
|
32
|
+
hintAppearance = APPEARANCE_STATE.Default,
|
|
33
|
+
showHintTooltip,
|
|
34
|
+
hintTooltipText,
|
|
35
|
+
hintLink,
|
|
36
|
+
showHintLink,
|
|
37
|
+
valueDelta,
|
|
38
|
+
}: TotalValueBlockProps) {
|
|
39
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
40
|
+
|
|
41
|
+
const totalSumPrefix = totalSumType === 'from' ? `${t('totalSumFromPrefix')} ` : '';
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className={styles.content} data-appearance={hintAppearance}>
|
|
45
|
+
<Typography variant={VARIANT.headline} size={SIZE.s} weight={WEIGHT.thin}>
|
|
46
|
+
{value !== undefined
|
|
47
|
+
? `${totalSumPrefix}${formatCurrency(Number(value))}`
|
|
48
|
+
: (t as (key: string) => string)('notAvailable')}
|
|
49
|
+
</Typography>
|
|
50
|
+
|
|
51
|
+
{valueDelta && (
|
|
52
|
+
<Typography variant={VARIANT.body} size={SIZE.s} className={styles.valueDelta}>
|
|
53
|
+
{`${t(`${valueDelta.type}Price`)} ${formatCurrency(valueDelta.value)}`}
|
|
54
|
+
</Typography>
|
|
55
|
+
)}
|
|
56
|
+
|
|
57
|
+
<Tooltip
|
|
58
|
+
open={showHintTooltip && hintTooltipText ? undefined : false}
|
|
59
|
+
tip={hintTooltipText}
|
|
60
|
+
placement='left-start'
|
|
61
|
+
>
|
|
62
|
+
{hint && (
|
|
63
|
+
<div className={styles.hint} data-appearance={hintAppearance}>
|
|
64
|
+
{getAppearanceIcon(hintAppearance, styles.hintIcon)}
|
|
65
|
+
<Typography variant={VARIANT.body} size={SIZE.s}>
|
|
66
|
+
{hint}
|
|
67
|
+
</Typography>
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
</Tooltip>
|
|
71
|
+
{showHintLink && (
|
|
72
|
+
<Link
|
|
73
|
+
roleAppearance={ROLE_APPEARANCE.OnAccent}
|
|
74
|
+
appearance='neutral'
|
|
75
|
+
href={hintLink?.href}
|
|
76
|
+
label={hintLink?.label}
|
|
77
|
+
className={styles.link}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TotalValueBlock';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
|
|
3
|
+
$text-appearance-colors: (
|
|
4
|
+
'userError': base.$sn-theme-color-red-text,
|
|
5
|
+
'warning': base.$sn-theme-color-yellow-text,
|
|
6
|
+
'systemError': base.$sn-theme-color-available-version-textDisabled,
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
$icon-appearance-colors: (
|
|
10
|
+
'default': base.$sn-theme-color-neutral-accent,
|
|
11
|
+
'userError': base.$sn-theme-color-red-accent,
|
|
12
|
+
'warning': base.$sn-theme-color-yellow-accent,
|
|
13
|
+
'systemError': base.$sn-theme-color-available-version-textDisabled,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
.content {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
text-align: start;
|
|
20
|
+
|
|
21
|
+
@each $appearance, $color in $text-appearance-colors {
|
|
22
|
+
&[data-appearance='#{$appearance}'] {
|
|
23
|
+
color: $color;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.hint {
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: base.$sn-primitive-dimension-2;
|
|
31
|
+
align-items: center;
|
|
32
|
+
color: base.$sn-theme-color-available-version-textTertiary;
|
|
33
|
+
|
|
34
|
+
@each $appearance, $color in $text-appearance-colors {
|
|
35
|
+
&[data-appearance='#{$appearance}'] {
|
|
36
|
+
color: $color;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.hintIcon {
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
box-sizing: content-box;
|
|
44
|
+
|
|
45
|
+
@each $appearance, $color in $icon-appearance-colors {
|
|
46
|
+
&[data-appearance='#{$appearance}'] {
|
|
47
|
+
color: $color;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.valueDelta {
|
|
53
|
+
color: base.$sn-theme-color-available-version-textSecondary;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PriceSummary';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/components/block.module' as block;
|
|
3
|
+
@use '@cloud-ru/ds-materials' as m;
|
|
4
|
+
|
|
5
|
+
.acrylic {
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset: 0;
|
|
9
|
+
border-radius: inherit;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.priceSummary {
|
|
13
|
+
position: relative;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
width: 100%;
|
|
16
|
+
color: base.$sn-theme-color-available-version-textMain;
|
|
17
|
+
|
|
18
|
+
@include base.composite-var(block.$block, 'anatomy', 'm');
|
|
19
|
+
@include m.with-material('acrylic', #{acrylic});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.content {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: base.$sn-primitive-dimension-4;
|
|
27
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
2
|
+
import { NotifierInfoFilledSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { LinkProps } from '@cloud-ru/ds-link';
|
|
4
|
+
import { BACKGROUND_PREDEFINED_FILL, backgroundPredefinedFillToAcrylic } from '@cloud-ru/ds-materials';
|
|
5
|
+
import { QuestionTooltip } from '@cloud-ru/ds-tooltip';
|
|
6
|
+
import { SIZE, Typography, VARIANT } from '@cloud-ru/ds-typography';
|
|
7
|
+
import { extractSupportProps, WithSupportProps } from '@cloud-ru/ds-utils';
|
|
8
|
+
import cn from 'classnames';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
10
|
+
|
|
11
|
+
import { formatCurrency } from '../../helpers';
|
|
12
|
+
import { priceSummaryLocale } from '../../locale';
|
|
13
|
+
import { ContentBlock, ContentBlockProps } from '../ContentBlock';
|
|
14
|
+
import styles from './styles.module.scss';
|
|
15
|
+
|
|
16
|
+
export type PriceSummarySmallProps = WithSupportProps<
|
|
17
|
+
ContentBlockProps & {
|
|
18
|
+
/** Итоговая сумма. */
|
|
19
|
+
value: number | undefined;
|
|
20
|
+
/** Function-ссылка внизу блока. */
|
|
21
|
+
docsLink?: {
|
|
22
|
+
href?: LinkProps['href'];
|
|
23
|
+
label?: LinkProps['label'];
|
|
24
|
+
};
|
|
25
|
+
/** Контент подсказки для иконки рядом с итоговой суммой. */
|
|
26
|
+
hintTooltipText?: ReactNode;
|
|
27
|
+
/** Дополнительный класс корневого контейнера. */
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
export function PriceSummarySmall({
|
|
33
|
+
value = 0,
|
|
34
|
+
docsLink,
|
|
35
|
+
hintTooltipText,
|
|
36
|
+
loading,
|
|
37
|
+
dataError,
|
|
38
|
+
onRetry,
|
|
39
|
+
className,
|
|
40
|
+
...rest
|
|
41
|
+
}: PriceSummarySmallProps) {
|
|
42
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
43
|
+
const { appearance, level } = backgroundPredefinedFillToAcrylic(BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
className={cn(styles.priceSummarySmall, className)}
|
|
48
|
+
data-acrylic-appearance={appearance}
|
|
49
|
+
data-acrylic-level={level}
|
|
50
|
+
{...extractSupportProps(rest)}
|
|
51
|
+
>
|
|
52
|
+
<span className={styles.acrylic} aria-hidden data-acrylic-background />
|
|
53
|
+
|
|
54
|
+
<div className={styles.content}>
|
|
55
|
+
<Typography variant={VARIANT.body} size={SIZE.m}>
|
|
56
|
+
{t('total')}
|
|
57
|
+
</Typography>
|
|
58
|
+
|
|
59
|
+
<ContentBlock loading={loading} dataError={dataError} onRetry={onRetry}>
|
|
60
|
+
<div className={styles.value}>
|
|
61
|
+
{hintTooltipText ? (
|
|
62
|
+
<QuestionTooltip tip={hintTooltipText}>
|
|
63
|
+
<NotifierInfoFilledSVG size={16} className={styles.icon} />
|
|
64
|
+
</QuestionTooltip>
|
|
65
|
+
) : (
|
|
66
|
+
<NotifierInfoFilledSVG size={16} className={styles.icon} />
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
<Typography variant={VARIANT.title} size={SIZE.m}>
|
|
70
|
+
{formatCurrency(value)}
|
|
71
|
+
</Typography>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
{docsLink?.href && (
|
|
75
|
+
<Button
|
|
76
|
+
as='a'
|
|
77
|
+
view='function'
|
|
78
|
+
size='m'
|
|
79
|
+
label={docsLink.label || t('costLink')}
|
|
80
|
+
href={docsLink.href}
|
|
81
|
+
target='_blank'
|
|
82
|
+
className={styles.docLink}
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
85
|
+
</ContentBlock>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PriceSummarySmall';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/components/block.module' as block;
|
|
3
|
+
@use '@cloud-ru/ds-materials' as m;
|
|
4
|
+
|
|
5
|
+
.acrylic {
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset: 0;
|
|
9
|
+
border-radius: inherit;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.priceSummarySmall {
|
|
13
|
+
position: relative;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
width: 100%;
|
|
16
|
+
color: base.$sn-theme-color-available-version-textMain;
|
|
17
|
+
|
|
18
|
+
@include base.composite-var(block.$block, 'anatomy', 'm');
|
|
19
|
+
@include m.with-material('acrylic', #{acrylic});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.content {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: base.$sn-primitive-dimension-4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.value {
|
|
30
|
+
display: flex;
|
|
31
|
+
gap: base.$sn-primitive-dimension-4;
|
|
32
|
+
align-items: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.icon {
|
|
36
|
+
flex-shrink: 0;
|
|
37
|
+
color: base.$sn-theme-color-available-version-textTertiary;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.docLink {
|
|
41
|
+
align-self: flex-start;
|
|
42
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const TEST_IDS = {
|
|
2
|
+
priceSummary: 'price-summary',
|
|
3
|
+
priceSummarySmall: 'price-summary-small',
|
|
4
|
+
periodDropdown: 'price-summary-period-dropdown',
|
|
5
|
+
periodOptionYear: 'price-summary-period-option-year',
|
|
6
|
+
periodOptionMonth: 'price-summary-period-option-month',
|
|
7
|
+
periodOptionDay: 'price-summary-period-option-day',
|
|
8
|
+
periodOptionHour: 'price-summary-period-option-hour',
|
|
9
|
+
periodOptionMinute: 'price-summary-period-option-minute',
|
|
10
|
+
contentBlockRetry: 'price-summary-content-block-retry',
|
|
11
|
+
loadingBlock: 'price-summary-loading-block',
|
|
12
|
+
orderDetails: 'price-summary-order-details',
|
|
13
|
+
orderDetailsContent: 'price-summary-order-details-content',
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export const APPEARANCE_STATE = {
|
|
17
|
+
Default: 'default',
|
|
18
|
+
UserError: 'userError',
|
|
19
|
+
SystemError: 'systemError',
|
|
20
|
+
Warning: 'warning',
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
export const PRICE_PERIOD = {
|
|
24
|
+
Year: 'year',
|
|
25
|
+
Month: 'month',
|
|
26
|
+
Day: 'day',
|
|
27
|
+
Hour: 'hour',
|
|
28
|
+
Minute: 'minute',
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export const PERIOD_OPTION_TEST_IDS = {
|
|
32
|
+
[PRICE_PERIOD.Year]: TEST_IDS.periodOptionYear,
|
|
33
|
+
[PRICE_PERIOD.Month]: TEST_IDS.periodOptionMonth,
|
|
34
|
+
[PRICE_PERIOD.Day]: TEST_IDS.periodOptionDay,
|
|
35
|
+
[PRICE_PERIOD.Hour]: TEST_IDS.periodOptionHour,
|
|
36
|
+
[PRICE_PERIOD.Minute]: TEST_IDS.periodOptionMinute,
|
|
37
|
+
} as const;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { formatNumber } from '@cloud-ru/ft-formatters';
|
|
2
|
+
|
|
3
|
+
export function formatCurrency(value: number) {
|
|
4
|
+
return formatNumber(value.toFixed(2), {
|
|
5
|
+
precision: 2,
|
|
6
|
+
type: formatNumber.types.Currency,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function formatQuantity(value: string | number) {
|
|
11
|
+
return typeof value === 'string' ? value : `×${value}`;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatters';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './usePeriodFormat';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import { PRICE_PERIOD } from '../constants';
|
|
4
|
+
import { priceSummaryLocale } from '../locale';
|
|
5
|
+
import { PricePeriod } from '../types';
|
|
6
|
+
|
|
7
|
+
type PeriodLabelKey =
|
|
8
|
+
| 'pricePeriodYear'
|
|
9
|
+
| 'pricePeriodMonth'
|
|
10
|
+
| 'pricePeriodDay'
|
|
11
|
+
| 'pricePeriodHour'
|
|
12
|
+
| 'pricePeriodMinute';
|
|
13
|
+
|
|
14
|
+
const PERIOD_LABEL_KEYS: Record<PricePeriod, PeriodLabelKey> = {
|
|
15
|
+
[PRICE_PERIOD.Year]: 'pricePeriodYear',
|
|
16
|
+
[PRICE_PERIOD.Month]: 'pricePeriodMonth',
|
|
17
|
+
[PRICE_PERIOD.Day]: 'pricePeriodDay',
|
|
18
|
+
[PRICE_PERIOD.Hour]: 'pricePeriodHour',
|
|
19
|
+
[PRICE_PERIOD.Minute]: 'pricePeriodMinute',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function formatPeriodLabel(t: (key: PeriodLabelKey) => string, period: PricePeriod): string {
|
|
23
|
+
return t(PERIOD_LABEL_KEYS[period]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function usePeriodFormat() {
|
|
27
|
+
const { t } = priceSummaryLocale.useTranslations();
|
|
28
|
+
|
|
29
|
+
return useCallback((period: PricePeriod) => formatPeriodLabel(t, period), [t]);
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineLocale, defineMessages } from '@cloud-ru/ds-locale';
|
|
2
|
+
|
|
3
|
+
const PRICE_SUMMARY_MESSAGES = defineMessages({
|
|
4
|
+
'en-GB': {
|
|
5
|
+
total: 'Total',
|
|
6
|
+
vat: 'VAT included',
|
|
7
|
+
vatExcluded: 'VAT excluded',
|
|
8
|
+
docsLink: 'Calculation details',
|
|
9
|
+
costLink: 'Cost',
|
|
10
|
+
dataError: 'Failed to load data',
|
|
11
|
+
basePrice: 'Base price',
|
|
12
|
+
discount: 'Discount',
|
|
13
|
+
orderDetails: 'Order breakdown',
|
|
14
|
+
price: 'Cost',
|
|
15
|
+
notAvailable: 'N/A',
|
|
16
|
+
pricePeriodYear: 'per year',
|
|
17
|
+
pricePeriodMonth: 'per month',
|
|
18
|
+
pricePeriodDay: 'per day',
|
|
19
|
+
pricePeriodHour: 'per hour',
|
|
20
|
+
pricePeriodMinute: 'per minute',
|
|
21
|
+
totalSumFromPrefix: 'from',
|
|
22
|
+
increasedPrice: 'Increased by',
|
|
23
|
+
decreasedPrice: 'Decreased by',
|
|
24
|
+
coveredByGrant: 'Covered by grants',
|
|
25
|
+
notCoveredByGrant: 'Not covered by grant',
|
|
26
|
+
coveredByGrantTooltip: 'Amount is covered by grant',
|
|
27
|
+
notCoveredByGrantTooltip: 'Amount is not covered by grant',
|
|
28
|
+
},
|
|
29
|
+
'ru-RU': {
|
|
30
|
+
total: 'Итого',
|
|
31
|
+
vat: 'с НДС',
|
|
32
|
+
vatExcluded: 'без НДС',
|
|
33
|
+
docsLink: 'Подробнее о расчёте',
|
|
34
|
+
costLink: 'Стоимость',
|
|
35
|
+
dataError: 'Не удалось загрузить данные',
|
|
36
|
+
basePrice: 'Базовая цена',
|
|
37
|
+
discount: 'Скидка',
|
|
38
|
+
orderDetails: 'Детализация заказа',
|
|
39
|
+
price: 'Стоимость',
|
|
40
|
+
notAvailable: 'н/д',
|
|
41
|
+
pricePeriodYear: 'в год',
|
|
42
|
+
pricePeriodMonth: 'в месяц',
|
|
43
|
+
pricePeriodDay: 'в день',
|
|
44
|
+
pricePeriodHour: 'в час',
|
|
45
|
+
pricePeriodMinute: 'в минуту',
|
|
46
|
+
totalSumFromPrefix: 'от',
|
|
47
|
+
increasedPrice: 'Повышение на',
|
|
48
|
+
decreasedPrice: 'Снижение на',
|
|
49
|
+
coveredByGrant: 'Покрывается грантами',
|
|
50
|
+
notCoveredByGrant: 'Не покрыто грантом',
|
|
51
|
+
coveredByGrantTooltip: 'Сумма покрыта грантом',
|
|
52
|
+
notCoveredByGrantTooltip: 'Сумма не покрыта грантом',
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type PriceSummaryMessages = (typeof PRICE_SUMMARY_MESSAGES)['en-GB'];
|
|
57
|
+
|
|
58
|
+
/** locale компонента PriceSummary: `priceSummaryLocale.useTranslations()` в коде, `priceSummaryLocale.extend(...)` в сервисе. */
|
|
59
|
+
export const priceSummaryLocale = defineLocale('@cloud-ru/ds-uikit-product-price-summary', PRICE_SUMMARY_MESSAGES);
|