@taiga-ui/addon-commerce 2.49.2 → 2.50.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/bundles/taiga-ui-addon-commerce-components-money.umd.js +88 -39
- package/bundles/taiga-ui-addon-commerce-components-money.umd.js.map +1 -1
- package/bundles/taiga-ui-addon-commerce-components-money.umd.min.js +1 -1
- package/bundles/taiga-ui-addon-commerce-components-money.umd.min.js.map +1 -1
- package/components/money/index.d.ts +5 -0
- package/components/money/money.component.d.ts +4 -8
- package/components/money/pipes/fraction-part.pipe.d.ts +7 -0
- package/components/money/pipes/integer-part.pipe.d.ts +7 -0
- package/components/money/pipes/sign-symbol.pipe.d.ts +5 -0
- package/components/money/taiga-ui-addon-commerce-components-money.metadata.json +1 -1
- package/components/money/utils/format-fraction-part.d.ts +7 -0
- package/components/money/utils/format-sign-symbol.d.ts +2 -0
- package/esm2015/components/money/index.js +6 -1
- package/esm2015/components/money/money.component.js +6 -28
- package/esm2015/components/money/money.module.js +10 -2
- package/esm2015/components/money/pipes/fraction-part.pipe.js +26 -0
- package/esm2015/components/money/pipes/integer-part.pipe.js +20 -0
- package/esm2015/components/money/pipes/sign-symbol.pipe.js +13 -0
- package/esm2015/components/money/utils/format-fraction-part.js +7 -0
- package/esm2015/components/money/utils/format-sign-symbol.js +12 -0
- package/esm2015/types/money-sign.js +1 -1
- package/esm5/components/money/index.js +6 -1
- package/esm5/components/money/money.component.js +6 -36
- package/esm5/components/money/money.module.js +10 -2
- package/esm5/components/money/pipes/fraction-part.pipe.js +27 -0
- package/esm5/components/money/pipes/integer-part.pipe.js +21 -0
- package/esm5/components/money/pipes/sign-symbol.pipe.js +16 -0
- package/esm5/components/money/utils/format-fraction-part.js +7 -0
- package/esm5/components/money/utils/format-sign-symbol.js +12 -0
- package/esm5/types/money-sign.js +1 -1
- package/fesm2015/taiga-ui-addon-commerce-components-money.js +77 -30
- package/fesm2015/taiga-ui-addon-commerce-components-money.js.map +1 -1
- package/fesm5/taiga-ui-addon-commerce-components-money.js +82 -38
- package/fesm5/taiga-ui-addon-commerce-components-money.js.map +1 -1
- package/package.json +4 -4
- package/types/money-sign.d.ts +2 -0
- package/types/taiga-ui-addon-commerce-types.metadata.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __param } from 'tslib';
|
|
2
|
-
import { InjectionToken, Inject, Input, HostBinding, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
2
|
+
import { InjectionToken, Inject, Input, HostBinding, Component, ChangeDetectionStrategy, Pipe, NgModule } from '@angular/core';
|
|
3
3
|
import { CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp } from '@taiga-ui/cdk';
|
|
4
|
-
import { formatNumber, TUI_NUMBER_FORMAT } from '@taiga-ui/core';
|
|
5
4
|
import { CommonModule } from '@angular/common';
|
|
6
5
|
import { TuiCurrencyPipeModule } from '@taiga-ui/addon-commerce/pipes';
|
|
6
|
+
import { TUI_NUMBER_FORMAT, formatNumber } from '@taiga-ui/core';
|
|
7
7
|
|
|
8
8
|
const TUI_MONEY_DEFAULT_DEFAULT_OPTIONS = {
|
|
9
9
|
decimal: 'not-zero',
|
|
@@ -21,9 +21,19 @@ const tuiMoneyOptionsProvider = (options) => ({
|
|
|
21
21
|
useValue: Object.assign(Object.assign({}, TUI_MONEY_DEFAULT_DEFAULT_OPTIONS), options),
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
function tuiFormatSignSymbol(value, sign) {
|
|
25
|
+
if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {
|
|
29
|
+
/** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */
|
|
30
|
+
return CHAR_EN_DASH;
|
|
31
|
+
}
|
|
32
|
+
return CHAR_PLUS;
|
|
33
|
+
}
|
|
34
|
+
|
|
24
35
|
let TuiMoneyComponent = class TuiMoneyComponent {
|
|
25
|
-
constructor(
|
|
26
|
-
this.numberFormat = numberFormat;
|
|
36
|
+
constructor(options) {
|
|
27
37
|
this.options = options;
|
|
28
38
|
this.value = NaN;
|
|
29
39
|
this.decimal = this.options.decimal;
|
|
@@ -33,27 +43,8 @@ let TuiMoneyComponent = class TuiMoneyComponent {
|
|
|
33
43
|
this.precision = this.options.precision;
|
|
34
44
|
this.singleColor = this.options.singleColor;
|
|
35
45
|
}
|
|
36
|
-
get integerPart() {
|
|
37
|
-
return formatNumber(Math.floor(Math.abs(this.value)), null, this.numberFormat.decimalSeparator, this.numberFormat.thousandSeparator);
|
|
38
|
-
}
|
|
39
|
-
get fractionPart() {
|
|
40
|
-
const { decimal, value } = this;
|
|
41
|
-
const fraction = value.toFixed(this.precision).split('.')[1];
|
|
42
|
-
return decimal === 'never' ||
|
|
43
|
-
(parseInt(fraction, 10) === 0 && decimal !== 'always')
|
|
44
|
-
? ''
|
|
45
|
-
: this.numberFormat.decimalSeparator + fraction;
|
|
46
|
-
}
|
|
47
46
|
get signSymbol() {
|
|
48
|
-
|
|
49
|
-
if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {
|
|
50
|
-
return '';
|
|
51
|
-
}
|
|
52
|
-
if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {
|
|
53
|
-
/** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */
|
|
54
|
-
return CHAR_EN_DASH;
|
|
55
|
-
}
|
|
56
|
-
return CHAR_PLUS;
|
|
47
|
+
return tuiFormatSignSymbol(this.value, this.sign);
|
|
57
48
|
}
|
|
58
49
|
get red() {
|
|
59
50
|
return (this.colored &&
|
|
@@ -70,7 +61,6 @@ let TuiMoneyComponent = class TuiMoneyComponent {
|
|
|
70
61
|
}
|
|
71
62
|
};
|
|
72
63
|
TuiMoneyComponent.ctorParameters = () => [
|
|
73
|
-
{ type: undefined, decorators: [{ type: Inject, args: [TUI_NUMBER_FORMAT,] }] },
|
|
74
64
|
{ type: undefined, decorators: [{ type: Inject, args: [TUI_MONEY_OPTIONS,] }] }
|
|
75
65
|
];
|
|
76
66
|
__decorate([
|
|
@@ -113,20 +103,77 @@ __decorate([
|
|
|
113
103
|
TuiMoneyComponent = __decorate([
|
|
114
104
|
Component({
|
|
115
105
|
selector: 'tui-money',
|
|
106
|
+
template: "<span\n automation-id=\"tui-money__sign\"\n [textContent]=\"value | tuiSignSymbol: sign\"\n></span>\n<span\n automation-id=\"tui-money__integer-part\"\n [textContent]=\"value | tuiIntegerPart: precision\"\n></span>\n<span class=\"t-lighter\">\n <span\n automation-id=\"tui-money__fraction-part\"\n [textContent]=\"value | tuiFractionPart: decimal: precision\"\n ></span>\n <span\n automation-id=\"tui-money__currency\"\n class=\"t-currency\"\n [textContent]=\"currency | tuiCurrency\"\n ></span>\n</span>\n",
|
|
116
107
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
117
|
-
template: "<span automation-id=\"tui-money__sign\">{{ signSymbol }}</span>\n<span automation-id=\"tui-money__integer-part\">{{ integerPart }}</span>\n<span class=\"t-lighter\">\n <span automation-id=\"tui-money__fraction-part\">{{ fractionPart }}</span>\n <span\n automation-id=\"tui-money__currency\"\n class=\"t-currency\"\n [textContent]=\"currency | tuiCurrency\"\n ></span>\n</span>\n",
|
|
118
108
|
styles: [":host{white-space:nowrap}:host._red{color:var(--tui-negative)}:host._green{color:var(--tui-positive)}:host:not(._inherit-color) .t-lighter{opacity:var(--tui-disabled-opacity)}.t-currency:not(:empty){padding-left:.2rem}"]
|
|
119
109
|
}),
|
|
120
|
-
__param(0, Inject(
|
|
121
|
-
__param(1, Inject(TUI_MONEY_OPTIONS))
|
|
110
|
+
__param(0, Inject(TUI_MONEY_OPTIONS))
|
|
122
111
|
], TuiMoneyComponent);
|
|
123
112
|
|
|
113
|
+
function tuiFormatFractionPart(options) {
|
|
114
|
+
const { value, decimal, numberFormat, precision } = options;
|
|
115
|
+
const fraction = value.toFixed(precision).split('.')[1];
|
|
116
|
+
const shouldShow = decimal !== 'never' && (decimal === 'always' || !!parseInt(fraction, 10));
|
|
117
|
+
return shouldShow ? `${numberFormat.decimalSeparator}${fraction}` : '';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let TuiFractionPartPipe = class TuiFractionPartPipe {
|
|
121
|
+
constructor(numberFormat) {
|
|
122
|
+
this.numberFormat = numberFormat;
|
|
123
|
+
}
|
|
124
|
+
transform(value, decimal, precision) {
|
|
125
|
+
return tuiFormatFractionPart({
|
|
126
|
+
value,
|
|
127
|
+
decimal,
|
|
128
|
+
precision,
|
|
129
|
+
numberFormat: this.numberFormat,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
TuiFractionPartPipe.ctorParameters = () => [
|
|
134
|
+
{ type: undefined, decorators: [{ type: Inject, args: [TUI_NUMBER_FORMAT,] }] }
|
|
135
|
+
];
|
|
136
|
+
TuiFractionPartPipe = __decorate([
|
|
137
|
+
Pipe({ name: 'tuiFractionPart' }),
|
|
138
|
+
__param(0, Inject(TUI_NUMBER_FORMAT))
|
|
139
|
+
], TuiFractionPartPipe);
|
|
140
|
+
|
|
141
|
+
let TuiIntegerPartPipe = class TuiIntegerPartPipe {
|
|
142
|
+
constructor(numberFormat) {
|
|
143
|
+
this.numberFormat = numberFormat;
|
|
144
|
+
}
|
|
145
|
+
transform(value, precision) {
|
|
146
|
+
return formatNumber(Math.floor(Math.abs(Number(value.toFixed(precision)))), null, this.numberFormat.decimalSeparator, this.numberFormat.thousandSeparator);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
TuiIntegerPartPipe.ctorParameters = () => [
|
|
150
|
+
{ type: undefined, decorators: [{ type: Inject, args: [TUI_NUMBER_FORMAT,] }] }
|
|
151
|
+
];
|
|
152
|
+
TuiIntegerPartPipe = __decorate([
|
|
153
|
+
Pipe({ name: 'tuiIntegerPart' }),
|
|
154
|
+
__param(0, Inject(TUI_NUMBER_FORMAT))
|
|
155
|
+
], TuiIntegerPartPipe);
|
|
156
|
+
|
|
157
|
+
let TuiSignSymbolPipe = class TuiSignSymbolPipe {
|
|
158
|
+
transform(value, sign) {
|
|
159
|
+
return tuiFormatSignSymbol(value, sign);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
TuiSignSymbolPipe = __decorate([
|
|
163
|
+
Pipe({ name: 'tuiSignSymbol' })
|
|
164
|
+
], TuiSignSymbolPipe);
|
|
165
|
+
|
|
124
166
|
let TuiMoneyModule = class TuiMoneyModule {
|
|
125
167
|
};
|
|
126
168
|
TuiMoneyModule = __decorate([
|
|
127
169
|
NgModule({
|
|
128
170
|
imports: [CommonModule, TuiCurrencyPipeModule],
|
|
129
|
-
declarations: [
|
|
171
|
+
declarations: [
|
|
172
|
+
TuiMoneyComponent,
|
|
173
|
+
TuiFractionPartPipe,
|
|
174
|
+
TuiIntegerPartPipe,
|
|
175
|
+
TuiSignSymbolPipe,
|
|
176
|
+
],
|
|
130
177
|
exports: [TuiMoneyComponent],
|
|
131
178
|
})
|
|
132
179
|
], TuiMoneyModule);
|
|
@@ -135,5 +182,5 @@ TuiMoneyModule = __decorate([
|
|
|
135
182
|
* Generated bundle index. Do not edit.
|
|
136
183
|
*/
|
|
137
184
|
|
|
138
|
-
export { TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, TUI_MONEY_OPTIONS, TuiMoneyComponent, TuiMoneyModule, tuiMoneyOptionsProvider };
|
|
185
|
+
export { TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, TUI_MONEY_OPTIONS, TuiFractionPartPipe, TuiIntegerPartPipe, TuiMoneyComponent, TuiMoneyModule, TuiSignSymbolPipe, tuiFormatFractionPart, tuiFormatSignSymbol, tuiMoneyOptionsProvider };
|
|
139
186
|
//# sourceMappingURL=taiga-ui-addon-commerce-components-money.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taiga-ui-addon-commerce-components-money.js","sources":["ng://@taiga-ui/addon-commerce/components/money/money-options.ts","ng://@taiga-ui/addon-commerce/components/money/money.component.ts","ng://@taiga-ui/addon-commerce/components/money/money.module.ts","ng://@taiga-ui/addon-commerce/components/money/taiga-ui-addon-commerce-components-money.ts"],"sourcesContent":["import {InjectionToken, ValueProvider} from '@angular/core';\nimport {TuiCurrency} from '@taiga-ui/addon-commerce/enums';\nimport {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {TuiDecimalT} from '@taiga-ui/core';\n\nexport interface TuiMoneyOptions {\n readonly decimal: TuiDecimalT;\n readonly currency: TuiCurrencyVariants;\n readonly sign: TuiMoneySignT;\n readonly colored: boolean;\n readonly precision: number;\n readonly singleColor: boolean;\n}\n\nexport const TUI_MONEY_DEFAULT_DEFAULT_OPTIONS: TuiMoneyOptions = {\n decimal: 'not-zero',\n currency: TuiCurrency.Ruble,\n sign: 'negative-only',\n colored: false,\n precision: 2,\n singleColor: false,\n};\n\nexport const TUI_MONEY_OPTIONS = new InjectionToken<TuiMoneyOptions>(\n 'Default parameters for money component',\n {\n factory: () => TUI_MONEY_DEFAULT_DEFAULT_OPTIONS,\n },\n);\n\nexport const tuiMoneyOptionsProvider: (\n options: Partial<TuiMoneyOptions>,\n) => ValueProvider = (options: Partial<TuiMoneyOptions>) => ({\n provide: TUI_MONEY_OPTIONS,\n useValue: {...TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, ...options},\n});\n","import {\n ChangeDetectionStrategy,\n Component,\n HostBinding,\n Inject,\n Input,\n} from '@angular/core';\nimport {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp} from '@taiga-ui/cdk';\nimport {\n formatNumber,\n TUI_NUMBER_FORMAT,\n TuiDecimalT,\n TuiNumberFormatSettings,\n} from '@taiga-ui/core';\n\nimport {TUI_MONEY_OPTIONS, TuiMoneyOptions} from './money-options';\n\n@Component({\n selector: 'tui-money',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './money.template.html',\n styleUrls: ['./money.style.less'],\n})\nexport class TuiMoneyComponent {\n @Input()\n @tuiDefaultProp()\n value = NaN;\n\n @Input()\n @tuiDefaultProp()\n decimal: TuiDecimalT = this.options.decimal;\n\n @Input()\n @tuiDefaultProp()\n currency: TuiCurrencyVariants = this.options.currency;\n\n @Input()\n @tuiDefaultProp()\n sign: TuiMoneySignT = this.options.sign;\n\n @Input()\n @tuiDefaultProp()\n colored = this.options.colored;\n\n @Input()\n @tuiDefaultProp()\n precision = this.options.precision;\n\n @Input()\n @tuiDefaultProp()\n singleColor = this.options.singleColor;\n\n get integerPart(): string {\n return formatNumber(\n Math.floor(Math.abs(this.value)),\n null,\n this.numberFormat.decimalSeparator,\n this.numberFormat.thousandSeparator,\n );\n }\n\n get fractionPart(): string {\n const {decimal, value} = this;\n const fraction = value.toFixed(this.precision).split('.')[1];\n\n return decimal === 'never' ||\n (parseInt(fraction, 10) === 0 && decimal !== 'always')\n ? ''\n : this.numberFormat.decimalSeparator + fraction;\n }\n\n get signSymbol(): '' | typeof CHAR_EN_DASH | typeof CHAR_PLUS {\n const {sign, value} = this;\n\n if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {\n return '';\n }\n\n if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {\n /** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */\n return CHAR_EN_DASH;\n }\n\n return CHAR_PLUS;\n }\n\n @HostBinding('class._red')\n get red(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_EN_DASH ||\n (this.value < 0 && this.sign !== 'force-positive'))\n );\n }\n\n @HostBinding('class._green')\n get green(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_PLUS ||\n (this.value > 0 && this.sign !== 'force-negative'))\n );\n }\n\n @HostBinding('class._inherit-color')\n get inheritColor(): boolean {\n return this.singleColor || (this.value === 0 && this.colored);\n }\n\n constructor(\n @Inject(TUI_NUMBER_FORMAT)\n private readonly numberFormat: TuiNumberFormatSettings,\n @Inject(TUI_MONEY_OPTIONS)\n private readonly options: TuiMoneyOptions,\n ) {}\n}\n","import {CommonModule} from '@angular/common';\nimport {NgModule} from '@angular/core';\nimport {TuiCurrencyPipeModule} from '@taiga-ui/addon-commerce/pipes';\n\nimport {TuiMoneyComponent} from './money.component';\n\n@NgModule({\n imports: [CommonModule, TuiCurrencyPipeModule],\n declarations: [TuiMoneyComponent],\n exports: [TuiMoneyComponent],\n})\nexport class TuiMoneyModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAca,iCAAiC,GAAoB;IAC9D,OAAO,EAAE,UAAU;IACnB,QAAQ;IACR,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,KAAK;EACpB;MAEW,iBAAiB,GAAG,IAAI,cAAc,CAC/C,wCAAwC,EACxC;IACI,OAAO,EAAE,MAAM,iCAAiC;CACnD,EACH;MAEW,uBAAuB,GAEf,CAAC,OAAiC,MAAM;IACzD,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,kCAAM,iCAAiC,GAAK,OAAO,CAAC;CAC/D;;ICXY,iBAAiB,GAA9B,MAAa,iBAAiB;IAsF1B,YAEqB,YAAqC,EAErC,OAAwB;QAFxB,iBAAY,GAAZ,YAAY,CAAyB;QAErC,YAAO,GAAP,OAAO,CAAiB;QAvF7C,UAAK,GAAG,GAAG,CAAC;QAIZ,YAAO,GAAgB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAI5C,aAAQ,GAAwB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAItD,SAAI,GAAkB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAIxC,YAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAI/B,cAAS,GAAG,IAAI,CAAC,OAAO,CA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CAAC;QAC9C,YAAY,EAAE,CAAC,iBAAiB,CAAC;QACjC,OAAO,EAAE,CAAC,iBAAiB,CAAC;KAC/B,CAAC;GACW,cAAc,CAAG;;ACX9B;;;;;;"}
|
|
1
|
+
{"version":3,"file":"taiga-ui-addon-commerce-components-money.js","sources":["ng://@taiga-ui/addon-commerce/components/money/money-options.ts","ng://@taiga-ui/addon-commerce/components/money/utils/format-sign-symbol.ts","ng://@taiga-ui/addon-commerce/components/money/money.component.ts","ng://@taiga-ui/addon-commerce/components/money/utils/format-fraction-part.ts","ng://@taiga-ui/addon-commerce/components/money/pipes/fraction-part.pipe.ts","ng://@taiga-ui/addon-commerce/components/money/pipes/integer-part.pipe.ts","ng://@taiga-ui/addon-commerce/components/money/pipes/sign-symbol.pipe.ts","ng://@taiga-ui/addon-commerce/components/money/money.module.ts","ng://@taiga-ui/addon-commerce/components/money/taiga-ui-addon-commerce-components-money.ts"],"sourcesContent":["import {InjectionToken, ValueProvider} from '@angular/core';\nimport {TuiCurrency} from '@taiga-ui/addon-commerce/enums';\nimport {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {TuiDecimalT} from '@taiga-ui/core';\n\nexport interface TuiMoneyOptions {\n readonly decimal: TuiDecimalT;\n readonly currency: TuiCurrencyVariants;\n readonly sign: TuiMoneySignT;\n readonly colored: boolean;\n readonly precision: number;\n readonly singleColor: boolean;\n}\n\nexport const TUI_MONEY_DEFAULT_DEFAULT_OPTIONS: TuiMoneyOptions = {\n decimal: 'not-zero',\n currency: TuiCurrency.Ruble,\n sign: 'negative-only',\n colored: false,\n precision: 2,\n singleColor: false,\n};\n\nexport const TUI_MONEY_OPTIONS = new InjectionToken<TuiMoneyOptions>(\n 'Default parameters for money component',\n {\n factory: () => TUI_MONEY_DEFAULT_DEFAULT_OPTIONS,\n },\n);\n\nexport const tuiMoneyOptionsProvider: (\n options: Partial<TuiMoneyOptions>,\n) => ValueProvider = (options: Partial<TuiMoneyOptions>) => ({\n provide: TUI_MONEY_OPTIONS,\n useValue: {...TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, ...options},\n});\n","import {TuiMoneySignSymbol, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {CHAR_EN_DASH, CHAR_PLUS} from '@taiga-ui/cdk';\n\nexport function tuiFormatSignSymbol(\n value: number,\n sign: TuiMoneySignT,\n): TuiMoneySignSymbol {\n if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {\n return '';\n }\n\n if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {\n /** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */\n return CHAR_EN_DASH;\n }\n\n return CHAR_PLUS;\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n HostBinding,\n Inject,\n Input,\n} from '@angular/core';\nimport {\n TuiCurrencyVariants,\n TuiMoneySignSymbol,\n TuiMoneySignT,\n} from '@taiga-ui/addon-commerce/types';\nimport {CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp} from '@taiga-ui/cdk';\nimport {TuiDecimalT} from '@taiga-ui/core';\n\nimport {TUI_MONEY_OPTIONS, TuiMoneyOptions} from './money-options';\nimport {tuiFormatSignSymbol} from './utils/format-sign-symbol';\n\n@Component({\n selector: 'tui-money',\n templateUrl: './money.template.html',\n styleUrls: ['./money.style.less'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TuiMoneyComponent {\n @Input()\n @tuiDefaultProp()\n value = NaN;\n\n @Input()\n @tuiDefaultProp()\n decimal: TuiDecimalT = this.options.decimal;\n\n @Input()\n @tuiDefaultProp()\n currency: TuiCurrencyVariants = this.options.currency;\n\n @Input()\n @tuiDefaultProp()\n sign: TuiMoneySignT = this.options.sign;\n\n @Input()\n @tuiDefaultProp()\n colored = this.options.colored;\n\n @Input()\n @tuiDefaultProp()\n precision = this.options.precision;\n\n @Input()\n @tuiDefaultProp()\n singleColor = this.options.singleColor;\n\n get signSymbol(): TuiMoneySignSymbol {\n return tuiFormatSignSymbol(this.value, this.sign);\n }\n\n @HostBinding('class._red')\n get red(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_EN_DASH ||\n (this.value < 0 && this.sign !== 'force-positive'))\n );\n }\n\n @HostBinding('class._green')\n get green(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_PLUS ||\n (this.value > 0 && this.sign !== 'force-negative'))\n );\n }\n\n @HostBinding('class._inherit-color')\n get inheritColor(): boolean {\n return this.singleColor || (this.value === 0 && this.colored);\n }\n\n constructor(@Inject(TUI_MONEY_OPTIONS) private readonly options: TuiMoneyOptions) {}\n}\n","import {TuiDecimalT, TuiNumberFormatSettings} from '@taiga-ui/core';\n\nexport function tuiFormatFractionPart(options: {\n value: number;\n decimal: TuiDecimalT;\n precision: number;\n numberFormat: TuiNumberFormatSettings;\n}): string {\n const {value, decimal, numberFormat, precision} = options;\n const fraction = value.toFixed(precision).split('.')[1];\n const shouldShow =\n decimal !== 'never' && (decimal === 'always' || !!parseInt(fraction, 10));\n\n return shouldShow ? `${numberFormat.decimalSeparator}${fraction}` : '';\n}\n","import {Inject, Pipe, PipeTransform} from '@angular/core';\nimport {TUI_NUMBER_FORMAT, TuiDecimalT, TuiNumberFormatSettings} from '@taiga-ui/core';\n\nimport {tuiFormatFractionPart} from '../utils/format-fraction-part';\n\n@Pipe({name: 'tuiFractionPart'})\nexport class TuiFractionPartPipe implements PipeTransform {\n constructor(\n @Inject(TUI_NUMBER_FORMAT) private readonly numberFormat: TuiNumberFormatSettings,\n ) {}\n\n transform(value: number, decimal: TuiDecimalT, precision: number): string {\n return tuiFormatFractionPart({\n value,\n decimal,\n precision,\n numberFormat: this.numberFormat,\n });\n }\n}\n","import {Inject, Pipe, PipeTransform} from '@angular/core';\nimport {formatNumber, TUI_NUMBER_FORMAT, TuiNumberFormatSettings} from '@taiga-ui/core';\n\n@Pipe({name: 'tuiIntegerPart'})\nexport class TuiIntegerPartPipe implements PipeTransform {\n constructor(\n @Inject(TUI_NUMBER_FORMAT) private readonly numberFormat: TuiNumberFormatSettings,\n ) {}\n\n transform(value: number, precision: number): string {\n return formatNumber(\n Math.floor(Math.abs(Number(value.toFixed(precision)))),\n null,\n this.numberFormat.decimalSeparator,\n this.numberFormat.thousandSeparator,\n );\n }\n}\n","import {Pipe, PipeTransform} from '@angular/core';\nimport {TuiMoneySignSymbol, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\n\nimport {tuiFormatSignSymbol} from '../utils/format-sign-symbol';\n\n@Pipe({name: 'tuiSignSymbol'})\nexport class TuiSignSymbolPipe implements PipeTransform {\n transform(value: number, sign: TuiMoneySignT): TuiMoneySignSymbol {\n return tuiFormatSignSymbol(value, sign);\n }\n}\n","import {CommonModule} from '@angular/common';\nimport {NgModule} from '@angular/core';\nimport {TuiCurrencyPipeModule} from '@taiga-ui/addon-commerce/pipes';\n\nimport {TuiMoneyComponent} from './money.component';\nimport {TuiFractionPartPipe} from './pipes/fraction-part.pipe';\nimport {TuiIntegerPartPipe} from './pipes/integer-part.pipe';\nimport {TuiSignSymbolPipe} from './pipes/sign-symbol.pipe';\n\n@NgModule({\n imports: [CommonModule, TuiCurrencyPipeModule],\n declarations: [\n TuiMoneyComponent,\n TuiFractionPartPipe,\n TuiIntegerPartPipe,\n TuiSignSymbolPipe,\n ],\n exports: [TuiMoneyComponent],\n})\nexport class TuiMoneyModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAca,iCAAiC,GAAoB;IAC9D,OAAO,EAAE,UAAU;IACnB,QAAQ;IACR,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,KAAK;EACpB;MAEW,iBAAiB,GAAG,IAAI,cAAc,CAC/C,wCAAwC,EACxC;IACI,OAAO,EAAE,MAAM,iCAAiC;CACnD,EACH;MAEW,uBAAuB,GAEf,CAAC,OAAiC,MAAM;IACzD,OAAO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S,CAAC,KAAa,EAAE,IAAmB;QACxC,OAAO,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAC3C;EACJ;AAJY,iBAAiB;IAD7B,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,EAAC,CAAC;GACjB,iBAAiB,CAI7B;;ICSY,cAAc,GAA3B,MAAa,cAAc;EAAG;AAAjB,cAAc;IAV1B,QAAQ,CAAC;QACN,OAAO,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC;QAC9C,YAAY,EAAE;YACV,iBAAiB;YACjB,mBAAmB;YACnB,kBAAkB;YAClB,iBAAiB;SACpB;QACD,OAAO,EAAE,CAAC,iBAAiB,CAAC;KAC/B,CAAC;GACW,cAAc,CAAG;;ACnB9B;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __assign, __decorate, __param } from 'tslib';
|
|
2
|
-
import { InjectionToken, Inject, Input, HostBinding, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
2
|
+
import { InjectionToken, Inject, Input, HostBinding, Component, ChangeDetectionStrategy, Pipe, NgModule } from '@angular/core';
|
|
3
3
|
import { CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp } from '@taiga-ui/cdk';
|
|
4
|
-
import { formatNumber, TUI_NUMBER_FORMAT } from '@taiga-ui/core';
|
|
5
4
|
import { CommonModule } from '@angular/common';
|
|
6
5
|
import { TuiCurrencyPipeModule } from '@taiga-ui/addon-commerce/pipes';
|
|
6
|
+
import { TUI_NUMBER_FORMAT, formatNumber } from '@taiga-ui/core';
|
|
7
7
|
|
|
8
8
|
var TUI_MONEY_DEFAULT_DEFAULT_OPTIONS = {
|
|
9
9
|
decimal: 'not-zero',
|
|
@@ -21,9 +21,19 @@ var tuiMoneyOptionsProvider = function (options) { return ({
|
|
|
21
21
|
useValue: __assign(__assign({}, TUI_MONEY_DEFAULT_DEFAULT_OPTIONS), options),
|
|
22
22
|
}); };
|
|
23
23
|
|
|
24
|
+
function tuiFormatSignSymbol(value, sign) {
|
|
25
|
+
if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {
|
|
29
|
+
/** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */
|
|
30
|
+
return CHAR_EN_DASH;
|
|
31
|
+
}
|
|
32
|
+
return CHAR_PLUS;
|
|
33
|
+
}
|
|
34
|
+
|
|
24
35
|
var TuiMoneyComponent = /** @class */ (function () {
|
|
25
|
-
function TuiMoneyComponent(
|
|
26
|
-
this.numberFormat = numberFormat;
|
|
36
|
+
function TuiMoneyComponent(options) {
|
|
27
37
|
this.options = options;
|
|
28
38
|
this.value = NaN;
|
|
29
39
|
this.decimal = this.options.decimal;
|
|
@@ -33,36 +43,9 @@ var TuiMoneyComponent = /** @class */ (function () {
|
|
|
33
43
|
this.precision = this.options.precision;
|
|
34
44
|
this.singleColor = this.options.singleColor;
|
|
35
45
|
}
|
|
36
|
-
Object.defineProperty(TuiMoneyComponent.prototype, "integerPart", {
|
|
37
|
-
get: function () {
|
|
38
|
-
return formatNumber(Math.floor(Math.abs(this.value)), null, this.numberFormat.decimalSeparator, this.numberFormat.thousandSeparator);
|
|
39
|
-
},
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(TuiMoneyComponent.prototype, "fractionPart", {
|
|
44
|
-
get: function () {
|
|
45
|
-
var _a = this, decimal = _a.decimal, value = _a.value;
|
|
46
|
-
var fraction = value.toFixed(this.precision).split('.')[1];
|
|
47
|
-
return decimal === 'never' ||
|
|
48
|
-
(parseInt(fraction, 10) === 0 && decimal !== 'always')
|
|
49
|
-
? ''
|
|
50
|
-
: this.numberFormat.decimalSeparator + fraction;
|
|
51
|
-
},
|
|
52
|
-
enumerable: true,
|
|
53
|
-
configurable: true
|
|
54
|
-
});
|
|
55
46
|
Object.defineProperty(TuiMoneyComponent.prototype, "signSymbol", {
|
|
56
47
|
get: function () {
|
|
57
|
-
|
|
58
|
-
if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {
|
|
62
|
-
/** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */
|
|
63
|
-
return CHAR_EN_DASH;
|
|
64
|
-
}
|
|
65
|
-
return CHAR_PLUS;
|
|
48
|
+
return tuiFormatSignSymbol(this.value, this.sign);
|
|
66
49
|
},
|
|
67
50
|
enumerable: true,
|
|
68
51
|
configurable: true
|
|
@@ -93,7 +76,6 @@ var TuiMoneyComponent = /** @class */ (function () {
|
|
|
93
76
|
configurable: true
|
|
94
77
|
});
|
|
95
78
|
TuiMoneyComponent.ctorParameters = function () { return [
|
|
96
|
-
{ type: undefined, decorators: [{ type: Inject, args: [TUI_NUMBER_FORMAT,] }] },
|
|
97
79
|
{ type: undefined, decorators: [{ type: Inject, args: [TUI_MONEY_OPTIONS,] }] }
|
|
98
80
|
]; };
|
|
99
81
|
__decorate([
|
|
@@ -136,23 +118,85 @@ var TuiMoneyComponent = /** @class */ (function () {
|
|
|
136
118
|
TuiMoneyComponent = __decorate([
|
|
137
119
|
Component({
|
|
138
120
|
selector: 'tui-money',
|
|
121
|
+
template: "<span\n automation-id=\"tui-money__sign\"\n [textContent]=\"value | tuiSignSymbol: sign\"\n></span>\n<span\n automation-id=\"tui-money__integer-part\"\n [textContent]=\"value | tuiIntegerPart: precision\"\n></span>\n<span class=\"t-lighter\">\n <span\n automation-id=\"tui-money__fraction-part\"\n [textContent]=\"value | tuiFractionPart: decimal: precision\"\n ></span>\n <span\n automation-id=\"tui-money__currency\"\n class=\"t-currency\"\n [textContent]=\"currency | tuiCurrency\"\n ></span>\n</span>\n",
|
|
139
122
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
140
|
-
template: "<span automation-id=\"tui-money__sign\">{{ signSymbol }}</span>\n<span automation-id=\"tui-money__integer-part\">{{ integerPart }}</span>\n<span class=\"t-lighter\">\n <span automation-id=\"tui-money__fraction-part\">{{ fractionPart }}</span>\n <span\n automation-id=\"tui-money__currency\"\n class=\"t-currency\"\n [textContent]=\"currency | tuiCurrency\"\n ></span>\n</span>\n",
|
|
141
123
|
styles: [":host{white-space:nowrap}:host._red{color:var(--tui-negative)}:host._green{color:var(--tui-positive)}:host:not(._inherit-color) .t-lighter{opacity:var(--tui-disabled-opacity)}.t-currency:not(:empty){padding-left:.2rem}"]
|
|
142
124
|
}),
|
|
143
|
-
__param(0, Inject(
|
|
144
|
-
__param(1, Inject(TUI_MONEY_OPTIONS))
|
|
125
|
+
__param(0, Inject(TUI_MONEY_OPTIONS))
|
|
145
126
|
], TuiMoneyComponent);
|
|
146
127
|
return TuiMoneyComponent;
|
|
147
128
|
}());
|
|
148
129
|
|
|
130
|
+
function tuiFormatFractionPart(options) {
|
|
131
|
+
var value = options.value, decimal = options.decimal, numberFormat = options.numberFormat, precision = options.precision;
|
|
132
|
+
var fraction = value.toFixed(precision).split('.')[1];
|
|
133
|
+
var shouldShow = decimal !== 'never' && (decimal === 'always' || !!parseInt(fraction, 10));
|
|
134
|
+
return shouldShow ? "" + numberFormat.decimalSeparator + fraction : '';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var TuiFractionPartPipe = /** @class */ (function () {
|
|
138
|
+
function TuiFractionPartPipe(numberFormat) {
|
|
139
|
+
this.numberFormat = numberFormat;
|
|
140
|
+
}
|
|
141
|
+
TuiFractionPartPipe.prototype.transform = function (value, decimal, precision) {
|
|
142
|
+
return tuiFormatFractionPart({
|
|
143
|
+
value: value,
|
|
144
|
+
decimal: decimal,
|
|
145
|
+
precision: precision,
|
|
146
|
+
numberFormat: this.numberFormat,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
TuiFractionPartPipe.ctorParameters = function () { return [
|
|
150
|
+
{ type: undefined, decorators: [{ type: Inject, args: [TUI_NUMBER_FORMAT,] }] }
|
|
151
|
+
]; };
|
|
152
|
+
TuiFractionPartPipe = __decorate([
|
|
153
|
+
Pipe({ name: 'tuiFractionPart' }),
|
|
154
|
+
__param(0, Inject(TUI_NUMBER_FORMAT))
|
|
155
|
+
], TuiFractionPartPipe);
|
|
156
|
+
return TuiFractionPartPipe;
|
|
157
|
+
}());
|
|
158
|
+
|
|
159
|
+
var TuiIntegerPartPipe = /** @class */ (function () {
|
|
160
|
+
function TuiIntegerPartPipe(numberFormat) {
|
|
161
|
+
this.numberFormat = numberFormat;
|
|
162
|
+
}
|
|
163
|
+
TuiIntegerPartPipe.prototype.transform = function (value, precision) {
|
|
164
|
+
return formatNumber(Math.floor(Math.abs(Number(value.toFixed(precision)))), null, this.numberFormat.decimalSeparator, this.numberFormat.thousandSeparator);
|
|
165
|
+
};
|
|
166
|
+
TuiIntegerPartPipe.ctorParameters = function () { return [
|
|
167
|
+
{ type: undefined, decorators: [{ type: Inject, args: [TUI_NUMBER_FORMAT,] }] }
|
|
168
|
+
]; };
|
|
169
|
+
TuiIntegerPartPipe = __decorate([
|
|
170
|
+
Pipe({ name: 'tuiIntegerPart' }),
|
|
171
|
+
__param(0, Inject(TUI_NUMBER_FORMAT))
|
|
172
|
+
], TuiIntegerPartPipe);
|
|
173
|
+
return TuiIntegerPartPipe;
|
|
174
|
+
}());
|
|
175
|
+
|
|
176
|
+
var TuiSignSymbolPipe = /** @class */ (function () {
|
|
177
|
+
function TuiSignSymbolPipe() {
|
|
178
|
+
}
|
|
179
|
+
TuiSignSymbolPipe.prototype.transform = function (value, sign) {
|
|
180
|
+
return tuiFormatSignSymbol(value, sign);
|
|
181
|
+
};
|
|
182
|
+
TuiSignSymbolPipe = __decorate([
|
|
183
|
+
Pipe({ name: 'tuiSignSymbol' })
|
|
184
|
+
], TuiSignSymbolPipe);
|
|
185
|
+
return TuiSignSymbolPipe;
|
|
186
|
+
}());
|
|
187
|
+
|
|
149
188
|
var TuiMoneyModule = /** @class */ (function () {
|
|
150
189
|
function TuiMoneyModule() {
|
|
151
190
|
}
|
|
152
191
|
TuiMoneyModule = __decorate([
|
|
153
192
|
NgModule({
|
|
154
193
|
imports: [CommonModule, TuiCurrencyPipeModule],
|
|
155
|
-
declarations: [
|
|
194
|
+
declarations: [
|
|
195
|
+
TuiMoneyComponent,
|
|
196
|
+
TuiFractionPartPipe,
|
|
197
|
+
TuiIntegerPartPipe,
|
|
198
|
+
TuiSignSymbolPipe,
|
|
199
|
+
],
|
|
156
200
|
exports: [TuiMoneyComponent],
|
|
157
201
|
})
|
|
158
202
|
], TuiMoneyModule);
|
|
@@ -163,5 +207,5 @@ var TuiMoneyModule = /** @class */ (function () {
|
|
|
163
207
|
* Generated bundle index. Do not edit.
|
|
164
208
|
*/
|
|
165
209
|
|
|
166
|
-
export { TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, TUI_MONEY_OPTIONS, TuiMoneyComponent, TuiMoneyModule, tuiMoneyOptionsProvider };
|
|
210
|
+
export { TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, TUI_MONEY_OPTIONS, TuiFractionPartPipe, TuiIntegerPartPipe, TuiMoneyComponent, TuiMoneyModule, TuiSignSymbolPipe, tuiFormatFractionPart, tuiFormatSignSymbol, tuiMoneyOptionsProvider };
|
|
167
211
|
//# sourceMappingURL=taiga-ui-addon-commerce-components-money.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taiga-ui-addon-commerce-components-money.js","sources":["ng://@taiga-ui/addon-commerce/components/money/money-options.ts","ng://@taiga-ui/addon-commerce/components/money/money.component.ts","ng://@taiga-ui/addon-commerce/components/money/money.module.ts","ng://@taiga-ui/addon-commerce/components/money/taiga-ui-addon-commerce-components-money.ts"],"sourcesContent":["import {InjectionToken, ValueProvider} from '@angular/core';\nimport {TuiCurrency} from '@taiga-ui/addon-commerce/enums';\nimport {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {TuiDecimalT} from '@taiga-ui/core';\n\nexport interface TuiMoneyOptions {\n readonly decimal: TuiDecimalT;\n readonly currency: TuiCurrencyVariants;\n readonly sign: TuiMoneySignT;\n readonly colored: boolean;\n readonly precision: number;\n readonly singleColor: boolean;\n}\n\nexport const TUI_MONEY_DEFAULT_DEFAULT_OPTIONS: TuiMoneyOptions = {\n decimal: 'not-zero',\n currency: TuiCurrency.Ruble,\n sign: 'negative-only',\n colored: false,\n precision: 2,\n singleColor: false,\n};\n\nexport const TUI_MONEY_OPTIONS = new InjectionToken<TuiMoneyOptions>(\n 'Default parameters for money component',\n {\n factory: () => TUI_MONEY_DEFAULT_DEFAULT_OPTIONS,\n },\n);\n\nexport const tuiMoneyOptionsProvider: (\n options: Partial<TuiMoneyOptions>,\n) => ValueProvider = (options: Partial<TuiMoneyOptions>) => ({\n provide: TUI_MONEY_OPTIONS,\n useValue: {...TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, ...options},\n});\n","import {\n ChangeDetectionStrategy,\n Component,\n HostBinding,\n Inject,\n Input,\n} from '@angular/core';\nimport {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp} from '@taiga-ui/cdk';\nimport {\n formatNumber,\n TUI_NUMBER_FORMAT,\n TuiDecimalT,\n TuiNumberFormatSettings,\n} from '@taiga-ui/core';\n\nimport {TUI_MONEY_OPTIONS, TuiMoneyOptions} from './money-options';\n\n@Component({\n selector: 'tui-money',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './money.template.html',\n styleUrls: ['./money.style.less'],\n})\nexport class TuiMoneyComponent {\n @Input()\n @tuiDefaultProp()\n value = NaN;\n\n @Input()\n @tuiDefaultProp()\n decimal: TuiDecimalT = this.options.decimal;\n\n @Input()\n @tuiDefaultProp()\n currency: TuiCurrencyVariants = this.options.currency;\n\n @Input()\n @tuiDefaultProp()\n sign: TuiMoneySignT = this.options.sign;\n\n @Input()\n @tuiDefaultProp()\n colored = this.options.colored;\n\n @Input()\n @tuiDefaultProp()\n precision = this.options.precision;\n\n @Input()\n @tuiDefaultProp()\n singleColor = this.options.singleColor;\n\n get integerPart(): string {\n return formatNumber(\n Math.floor(Math.abs(this.value)),\n null,\n this.numberFormat.decimalSeparator,\n this.numberFormat.thousandSeparator,\n );\n }\n\n get fractionPart(): string {\n const {decimal, value} = this;\n const fraction = value.toFixed(this.precision).split('.')[1];\n\n return decimal === 'never' ||\n (parseInt(fraction, 10) === 0 && decimal !== 'always')\n ? ''\n : this.numberFormat.decimalSeparator + fraction;\n }\n\n get signSymbol(): '' | typeof CHAR_EN_DASH | typeof CHAR_PLUS {\n const {sign, value} = this;\n\n if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {\n return '';\n }\n\n if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {\n /** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */\n return CHAR_EN_DASH;\n }\n\n return CHAR_PLUS;\n }\n\n @HostBinding('class._red')\n get red(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_EN_DASH ||\n (this.value < 0 && this.sign !== 'force-positive'))\n );\n }\n\n @HostBinding('class._green')\n get green(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_PLUS ||\n (this.value > 0 && this.sign !== 'force-negative'))\n );\n }\n\n @HostBinding('class._inherit-color')\n get inheritColor(): boolean {\n return this.singleColor || (this.value === 0 && this.colored);\n }\n\n constructor(\n @Inject(TUI_NUMBER_FORMAT)\n private readonly numberFormat: TuiNumberFormatSettings,\n @Inject(TUI_MONEY_OPTIONS)\n private readonly options: TuiMoneyOptions,\n ) {}\n}\n","import {CommonModule} from '@angular/common';\nimport {NgModule} from '@angular/core';\nimport {TuiCurrencyPipeModule} from '@taiga-ui/addon-commerce/pipes';\n\nimport {TuiMoneyComponent} from './money.component';\n\n@NgModule({\n imports: [CommonModule, TuiCurrencyPipeModule],\n declarations: [TuiMoneyComponent],\n exports: [TuiMoneyComponent],\n})\nexport class TuiMoneyModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;IAca,iCAAiC,GAAoB;IAC9D,OAAO,EAAE,UAAU;IACnB,QAAQ;IACR,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,KAAK;EACpB;IAEW,iBAAiB,GAAG,IAAI,cAAc,CAC/C,wCAAwC,EACxC;IACI,OAAO,EAAE,cAAM,OAAA,iCAAiC,GAAA;CACnD,EACH;IAEW,uBAAuB,GAEf,UAAC,OAAiC,IAAK,QAAC;IACzD,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,wBAAM,iCAAiC,GAAK,OAAO,CAAC;CAC/D;;;IC2EG,2BAEqB,YAAqC,EAErC,OAAwB;QAFxB,iBAAY,GAAZ,YAAY,CAAyB;QAErC,YAAO,GAAP,OAAO,CAAiB;QAvF7C,UAAK,GAAG,GAAG,CAAC;QAIZ,YAAO,GAAgB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAI5C,aAAQ,GAAwB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAItD,SAAI,GAAkB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAIxC,YAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAI/B,cAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QAInC,gBAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;KAgEnC;IA9DJ,sBAAI,0CAAW;aAAf;YACI,OAAO,YAAY,CACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAChC,IAAI,EACJ,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAClC,IAAI,CAAC,YAAY,C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ources":["ng://@taiga-ui/addon-commerce/components/money/money-options.ts","ng://@taiga-ui/addon-commerce/components/money/utils/format-sign-symbol.ts","ng://@taiga-ui/addon-commerce/components/money/money.component.ts","ng://@taiga-ui/addon-commerce/components/money/utils/format-fraction-part.ts","ng://@taiga-ui/addon-commerce/components/money/pipes/fraction-part.pipe.ts","ng://@taiga-ui/addon-commerce/components/money/pipes/integer-part.pipe.ts","ng://@taiga-ui/addon-commerce/components/money/pipes/sign-symbol.pipe.ts","ng://@taiga-ui/addon-commerce/components/money/money.module.ts","ng://@taiga-ui/addon-commerce/components/money/taiga-ui-addon-commerce-components-money.ts"],"sourcesContent":["import {InjectionToken, ValueProvider} from '@angular/core';\nimport {TuiCurrency} from '@taiga-ui/addon-commerce/enums';\nimport {TuiCurrencyVariants, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {TuiDecimalT} from '@taiga-ui/core';\n\nexport interface TuiMoneyOptions {\n readonly decimal: TuiDecimalT;\n readonly currency: TuiCurrencyVariants;\n readonly sign: TuiMoneySignT;\n readonly colored: boolean;\n readonly precision: number;\n readonly singleColor: boolean;\n}\n\nexport const TUI_MONEY_DEFAULT_DEFAULT_OPTIONS: TuiMoneyOptions = {\n decimal: 'not-zero',\n currency: TuiCurrency.Ruble,\n sign: 'negative-only',\n colored: false,\n precision: 2,\n singleColor: false,\n};\n\nexport const TUI_MONEY_OPTIONS = new InjectionToken<TuiMoneyOptions>(\n 'Default parameters for money component',\n {\n factory: () => TUI_MONEY_DEFAULT_DEFAULT_OPTIONS,\n },\n);\n\nexport const tuiMoneyOptionsProvider: (\n options: Partial<TuiMoneyOptions>,\n) => ValueProvider = (options: Partial<TuiMoneyOptions>) => ({\n provide: TUI_MONEY_OPTIONS,\n useValue: {...TUI_MONEY_DEFAULT_DEFAULT_OPTIONS, ...options},\n});\n","import {TuiMoneySignSymbol, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\nimport {CHAR_EN_DASH, CHAR_PLUS} from '@taiga-ui/cdk';\n\nexport function tuiFormatSignSymbol(\n value: number,\n sign: TuiMoneySignT,\n): TuiMoneySignSymbol {\n if (sign === 'never' || !value || (sign === 'negative-only' && value > 0)) {\n return '';\n }\n\n if (sign === 'force-negative' || (value < 0 && sign !== 'force-positive')) {\n /** TODO(nsbarsukov): investigate if it should be replaced by {@link CHAR_HYPHEN} */\n return CHAR_EN_DASH;\n }\n\n return CHAR_PLUS;\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n HostBinding,\n Inject,\n Input,\n} from '@angular/core';\nimport {\n TuiCurrencyVariants,\n TuiMoneySignSymbol,\n TuiMoneySignT,\n} from '@taiga-ui/addon-commerce/types';\nimport {CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp} from '@taiga-ui/cdk';\nimport {TuiDecimalT} from '@taiga-ui/core';\n\nimport {TUI_MONEY_OPTIONS, TuiMoneyOptions} from './money-options';\nimport {tuiFormatSignSymbol} from './utils/format-sign-symbol';\n\n@Component({\n selector: 'tui-money',\n templateUrl: './money.template.html',\n styleUrls: ['./money.style.less'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TuiMoneyComponent {\n @Input()\n @tuiDefaultProp()\n value = NaN;\n\n @Input()\n @tuiDefaultProp()\n decimal: TuiDecimalT = this.options.decimal;\n\n @Input()\n @tuiDefaultProp()\n currency: TuiCurrencyVariants = this.options.currency;\n\n @Input()\n @tuiDefaultProp()\n sign: TuiMoneySignT = this.options.sign;\n\n @Input()\n @tuiDefaultProp()\n colored = this.options.colored;\n\n @Input()\n @tuiDefaultProp()\n precision = this.options.precision;\n\n @Input()\n @tuiDefaultProp()\n singleColor = this.options.singleColor;\n\n get signSymbol(): TuiMoneySignSymbol {\n return tuiFormatSignSymbol(this.value, this.sign);\n }\n\n @HostBinding('class._red')\n get red(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_EN_DASH ||\n (this.value < 0 && this.sign !== 'force-positive'))\n );\n }\n\n @HostBinding('class._green')\n get green(): boolean {\n return (\n this.colored &&\n (this.signSymbol === CHAR_PLUS ||\n (this.value > 0 && this.sign !== 'force-negative'))\n );\n }\n\n @HostBinding('class._inherit-color')\n get inheritColor(): boolean {\n return this.singleColor || (this.value === 0 && this.colored);\n }\n\n constructor(@Inject(TUI_MONEY_OPTIONS) private readonly options: TuiMoneyOptions) {}\n}\n","import {TuiDecimalT, TuiNumberFormatSettings} from '@taiga-ui/core';\n\nexport function tuiFormatFractionPart(options: {\n value: number;\n decimal: TuiDecimalT;\n precision: number;\n numberFormat: TuiNumberFormatSettings;\n}): string {\n const {value, decimal, numberFormat, precision} = options;\n const fraction = value.toFixed(precision).split('.')[1];\n const shouldShow =\n decimal !== 'never' && (decimal === 'always' || !!parseInt(fraction, 10));\n\n return shouldShow ? `${numberFormat.decimalSeparator}${fraction}` : '';\n}\n","import {Inject, Pipe, PipeTransform} from '@angular/core';\nimport {TUI_NUMBER_FORMAT, TuiDecimalT, TuiNumberFormatSettings} from '@taiga-ui/core';\n\nimport {tuiFormatFractionPart} from '../utils/format-fraction-part';\n\n@Pipe({name: 'tuiFractionPart'})\nexport class TuiFractionPartPipe implements PipeTransform {\n constructor(\n @Inject(TUI_NUMBER_FORMAT) private readonly numberFormat: TuiNumberFormatSettings,\n ) {}\n\n transform(value: number, decimal: TuiDecimalT, precision: number): string {\n return tuiFormatFractionPart({\n value,\n decimal,\n precision,\n numberFormat: this.numberFormat,\n });\n }\n}\n","import {Inject, Pipe, PipeTransform} from '@angular/core';\nimport {formatNumber, TUI_NUMBER_FORMAT, TuiNumberFormatSettings} from '@taiga-ui/core';\n\n@Pipe({name: 'tuiIntegerPart'})\nexport class TuiIntegerPartPipe implements PipeTransform {\n constructor(\n @Inject(TUI_NUMBER_FORMAT) private readonly numberFormat: TuiNumberFormatSettings,\n ) {}\n\n transform(value: number, precision: number): string {\n return formatNumber(\n Math.floor(Math.abs(Number(value.toFixed(precision)))),\n null,\n this.numberFormat.decimalSeparator,\n this.numberFormat.thousandSeparator,\n );\n }\n}\n","import {Pipe, PipeTransform} from '@angular/core';\nimport {TuiMoneySignSymbol, TuiMoneySignT} from '@taiga-ui/addon-commerce/types';\n\nimport {tuiFormatSignSymbol} from '../utils/format-sign-symbol';\n\n@Pipe({name: 'tuiSignSymbol'})\nexport class TuiSignSymbolPipe implements PipeTransform {\n transform(value: number, sign: TuiMoneySignT): TuiMoneySignSymbol {\n return tuiFormatSignSymbol(value, sign);\n }\n}\n","import {CommonModule} from '@angular/common';\nimport {NgModule} from '@angular/core';\nimport {TuiCurrencyPipeModule} from '@taiga-ui/addon-commerce/pipes';\n\nimport {TuiMoneyComponent} from './money.component';\nimport {TuiFractionPartPipe} from './pipes/fraction-part.pipe';\nimport {TuiIntegerPartPipe} from './pipes/integer-part.pipe';\nimport {TuiSignSymbolPipe} from './pipes/sign-symbol.pipe';\n\n@NgModule({\n imports: [CommonModule, TuiCurrencyPipeModule],\n declarations: [\n TuiMoneyComponent,\n TuiFractionPartPipe,\n TuiIntegerPartPipe,\n TuiSignSymbolPipe,\n ],\n exports: [TuiMoneyComponent],\n})\nexport class TuiMoneyModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;IAca,iCAAiC,GAAoB;IAC9D,OAAO,EAAE,UAAU;IACnB,QAAQ;IACR,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,KAAK;EACpB;IAEW,iBAAiB,GAAG,IAAI,cAAc,CAC/C,wCAAwC,EACxC;IACI,OAAO,EAAE,cAAM,OAAA,iCAAiC,GAAA;CACnD,EACH;IAEW,uBAAuB,GAEf,UAAC,OAAiC,IAAK,QAAC;IACzD,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,wBAAM,iCAAiC,GAAK,OAAO,CAAC;CAC/D;;SChCe,mBAAmB,CAC/B,KAAa,EACb,IAAmB;IAEnB,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,KA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AiB,CAI7B;IAAD,wBAAC;CAJD;;;ICaA;KAA8B;IAAjB,cAAc;QAV1B,QAAQ,CAAC;YACN,OAAO,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC;YAC9C,YAAY,EAAE;gBACV,iBAAiB;gBACjB,mBAAmB;gBACnB,kBAAkB;gBAClB,iBAAiB;aACpB;YACD,OAAO,EAAE,CAAC,iBAAiB,CAAC;SAC/B,CAAC;OACW,cAAc,CAAG;IAAD,qBAAC;CAA9B;;ACnBA;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiga-ui/addon-commerce",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.50.0",
|
|
4
4
|
"description": "Extension package for Taiga UI related to commerce, payment systems, currencies etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"@angular/core": ">=9.0.0",
|
|
19
19
|
"@angular/forms": ">=9.0.0",
|
|
20
20
|
"@ng-web-apis/common": ">=1.12.1 < 2",
|
|
21
|
-
"@taiga-ui/cdk": ">=2.
|
|
22
|
-
"@taiga-ui/core": ">=2.
|
|
23
|
-
"@taiga-ui/i18n": ">=2.
|
|
21
|
+
"@taiga-ui/cdk": ">=2.50.0",
|
|
22
|
+
"@taiga-ui/core": ">=2.50.0",
|
|
23
|
+
"@taiga-ui/i18n": ">=2.50.0",
|
|
24
24
|
"@tinkoff/ng-polymorpheus": ">=3.1.12 < 4",
|
|
25
25
|
"angular2-text-mask": ">=9.0.0",
|
|
26
26
|
"rxjs": ">=6.0.0"
|
package/types/money-sign.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"metadata":{"TuiCodeCVCLength":{"__symbolic":"interface"},"TuiCurrencyAutocompletion":{"__symbolic":"interface"},"TuiCurrencyVariants":{"__symbolic":"interface"},"TuiMoneySignT":{"__symbolic":"interface"}},"origins":{"TuiCodeCVCLength":"./code-length","TuiCurrencyAutocompletion":"./currency-variants","TuiCurrencyVariants":"./currency-variants","TuiMoneySignT":"./money-sign"},"importAs":"@taiga-ui/addon-commerce/types"}
|
|
1
|
+
{"__symbolic":"module","version":4,"metadata":{"TuiCodeCVCLength":{"__symbolic":"interface"},"TuiCurrencyAutocompletion":{"__symbolic":"interface"},"TuiCurrencyVariants":{"__symbolic":"interface"},"TuiMoneySignT":{"__symbolic":"interface"},"TuiMoneySignSymbol":{"__symbolic":"interface"}},"origins":{"TuiCodeCVCLength":"./code-length","TuiCurrencyAutocompletion":"./currency-variants","TuiCurrencyVariants":"./currency-variants","TuiMoneySignT":"./money-sign","TuiMoneySignSymbol":"./money-sign"},"importAs":"@taiga-ui/addon-commerce/types"}
|