@tsi-developpement/tsi-shared-ui 1.9.13 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/esm2022/lib/functions/currency-state.functions.mjs +203 -0
  2. package/esm2022/lib/pipes/tsi-currency.pipe.mjs +17 -19
  3. package/esm2022/lib/tsi-components/input-components/editable-grid/editable-grid.component.mjs +3 -3
  4. package/esm2022/lib/tsi-components/input-components/tsi-currency-other-input/tsi-currency-other-input.component.mjs +49 -28
  5. package/esm2022/lib/tsi-components/input-components/tsi-currency-societe-input/tsi-currency-societe-input.component.mjs +46 -28
  6. package/esm2022/lib/tsi-components/output-components/tsi-currency-other-display/tsi-currency-other-display.component.mjs +37 -10
  7. package/esm2022/lib/tsi-components/output-components/tsi-currency-societe-display/tsi-currency-societe-display.component.mjs +33 -40
  8. package/esm2022/lib/tsi-components/output-components/tsi-display-grid/tsi-display-grid.component.mjs +3 -3
  9. package/esm2022/lib/tsi-components/output-components/tsi-generic-grid/tsi-generic-grid.component.mjs +3 -3
  10. package/esm2022/lib/tsi-components/poc/locale-poc/locale-poc.component.mjs +68 -36
  11. package/esm2022/lib/tsi-components/tsi-generic-form/tsi-generic-form.component.mjs +1 -1
  12. package/esm2022/lib/tsi-components/tsi-kanban/tsi-kanban.component.mjs +1 -1
  13. package/esm2022/lib/tsi-components/tsi-search-box/tsi-search-box.component.mjs +1 -1
  14. package/fesm2022/tsi-developpement-tsi-shared-ui.mjs +595 -319
  15. package/fesm2022/tsi-developpement-tsi-shared-ui.mjs.map +1 -1
  16. package/lib/consts/app-providers.d.ts +1 -1
  17. package/lib/functions/currency-state.functions.d.ts +80 -0
  18. package/lib/pipes/tsi-currency.pipe.d.ts +6 -4
  19. package/lib/providers/shared-ui-tsi.provider.d.ts +1 -1
  20. package/lib/tsi-components/input-components/tsi-currency-other-input/tsi-currency-other-input.component.d.ts +15 -10
  21. package/lib/tsi-components/input-components/tsi-currency-societe-input/tsi-currency-societe-input.component.d.ts +13 -10
  22. package/lib/tsi-components/output-components/tsi-currency-other-display/tsi-currency-other-display.component.d.ts +16 -6
  23. package/lib/tsi-components/output-components/tsi-currency-societe-display/tsi-currency-societe-display.component.d.ts +12 -13
  24. package/lib/tsi-components/poc/locale-poc/locale-poc.component.d.ts +39 -21
  25. package/package.json +1 -1
@@ -3,4 +3,4 @@ import { FormStateService } from "../services/form/form-state.service";
3
3
  import { PresentationDesignerBaseService } from "../services/presentation-setting/presentation-designer-base.service";
4
4
  import { GenericValidationStateService } from "../services/validation/generic-validation-state.service";
5
5
  import { InputRegistryService } from "../services/validation/input-registry.service";
6
- export declare const appProviders: (typeof GenericValidationStateService | typeof InputRegistryService | typeof PresentationDesignerBaseService | typeof DynamicFormService | typeof FormStateService)[];
6
+ export declare const appProviders: (typeof PresentationDesignerBaseService | typeof GenericValidationStateService | typeof InputRegistryService | typeof DynamicFormService | typeof FormStateService)[];
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Internal currency-state resolution shared by the four currency components
3
+ * (Tsi-Currency-Other-Input/Display, Tsi-Currency-Societe-Input/Display).
4
+ *
5
+ * This module is intentionally NOT re-exported from `functions/index.ts`, so it
6
+ * is an internal implementation detail and not part of the library public API.
7
+ *
8
+ * A currency "state" combines two independent checks:
9
+ * 1. Is the currency code a recognized ISO-4217 code?
10
+ * 2. Does the value carry more decimal places than the currency supports?
11
+ * The result drives a two-tier visual state in the components:
12
+ * - `error` → invalid/missing code, or (inputs) a value that exceeds the
13
+ * currency's decimals and therefore cannot be safely edited;
14
+ * - `warning` → (displays) a value that exceeds the currency's decimals, shown
15
+ * raw so no precision is hidden.
16
+ */
17
+ /**
18
+ * i18n keys resolved by the host app's `LocalizePipe`. Centralized here so the
19
+ * components and the backend translation files (FR/EN/AR) stay in sync.
20
+ */
21
+ export declare const CurrencyStateKeys: {
22
+ readonly noCurrencySupplied: "sharedUi-currency-error-noCurrencySupplied";
23
+ readonly invalidCurrencySupplied: "sharedUi-currency-error-invalidCurrencySupplied";
24
+ readonly valueExceedsDecimalsError: "sharedUi-currency-error-valueExceedsDecimals";
25
+ readonly valueExceedsDecimalsWarning: "sharedUi-currency-warning-valueExceedsDecimals";
26
+ };
27
+ /**
28
+ * Placeholders replaced when building a message, so the currency and the decimal
29
+ * figures are named inline. Translations must include the tokens they need
30
+ * (see the FR/EN/AR translation files):
31
+ * - `{devise}` → the currency code
32
+ * - `{decimals}` → the value's decimal-place count (mismatch messages only)
33
+ * - `{allowed}` → the decimals the currency allows (mismatch messages only)
34
+ */
35
+ export declare const CurrencyPlaceholder = "{devise}";
36
+ export declare const ValueDecimalsPlaceholder = "{decimals}";
37
+ export declare const AllowedDecimalsPlaceholder = "{allowed}";
38
+ export type CurrencyStateSeverity = 'ok' | 'error' | 'warning';
39
+ export interface CurrencyState {
40
+ /** Overall severity of the current (code, value) pair. */
41
+ severity: CurrencyStateSeverity;
42
+ /** Whether the currency code itself is a recognized ISO-4217 code. */
43
+ isValid: boolean;
44
+ /** Translation key for the tooltip message (empty when severity === 'ok'). */
45
+ tooltipKey: string;
46
+ /** Fraction digits the currency supports (ISO/locale default); -1 if unknown. */
47
+ isoDecimals: number;
48
+ /** Decimal places the value carries; set only on a decimals mismatch. */
49
+ valueDecimals?: number;
50
+ /** Normalized (upper-cased) currency code, when one was supplied. */
51
+ currencyCode?: string;
52
+ }
53
+ /**
54
+ * Returns `true` when `code` is a recognized ISO-4217 currency code.
55
+ *
56
+ * Prefers the exact `Intl.supportedValuesOf('currency')` list; on older runtimes
57
+ * falls back to a 3-letter well-formedness check plus `Intl.NumberFormat`.
58
+ * Case-insensitive (the code is upper-cased before checking).
59
+ */
60
+ export declare function isValidCurrency(code?: string): boolean;
61
+ /**
62
+ * Resolves the display state for a (currency code, value) pair.
63
+ *
64
+ * @param code ISO-4217 currency code supplied to the component.
65
+ * @param value the monetary value being shown/edited.
66
+ * @param locale locale used to derive the currency's fraction digits.
67
+ * @param mismatchSeverity severity applied when the value exceeds the currency's
68
+ * decimals: `'error'` for inputs (renders read-only),
69
+ * `'warning'` for displays (renders the raw value).
70
+ */
71
+ export declare function resolveCurrencyState(code: string | undefined, value: number | null | undefined, locale: string, mismatchSeverity: 'error' | 'warning'): CurrencyState;
72
+ /**
73
+ * Builds the tooltip message for a resolved state using the supplied `translate`
74
+ * callback (typically `LocalizePipe.transform`). Falls back to a built-in
75
+ * English message when the key resolves to itself (missing translation), so a
76
+ * raw key slug is never shown. Any {@link CurrencyPlaceholder} token in the
77
+ * message is replaced with the currency code, so the offending currency is named
78
+ * inline.
79
+ */
80
+ export declare function localizeCurrencyState(state: CurrencyState, translate: (key: string) => string): string;
@@ -1,10 +1,12 @@
1
- import { CurrencyPipe } from '@angular/common';
2
1
  import { PipeTransform } from '@angular/core';
3
2
  import * as i0 from "@angular/core";
4
3
  export declare class TsiCurrencyPipe implements PipeTransform {
5
- private currencyPipe;
6
- constructor(currencyPipe: CurrencyPipe);
7
- transform(value: number | undefined, currencyCode: string, display?: 'code' | 'symbol' | 'symbol-narrow' | string, digitsInfo?: string, locale?: string): string | null;
4
+ private readonly _display;
5
+ private _locale;
6
+ private _localizationService;
7
+ private _currencyPipe;
8
+ constructor();
9
+ transform(value: number | undefined, currencyCode: string): string | null;
8
10
  static ɵfac: i0.ɵɵFactoryDeclaration<TsiCurrencyPipe, never>;
9
11
  static ɵpipe: i0.ɵɵPipeDeclaration<TsiCurrencyPipe, "tsiCurrency", false>;
10
12
  }
@@ -2,7 +2,7 @@ import { DynamicDialogConfig, DynamicDialogRef } from "primeng/dynamicdialog";
2
2
  import { TabView } from "primeng/tabview";
3
3
  import { JwtHelperService } from "@auth0/angular-jwt";
4
4
  import { ConfirmationService, MessageService } from "primeng/api";
5
- export declare const SharedUiTsiProviders: (typeof DynamicDialogRef | typeof DynamicDialogConfig | typeof JwtHelperService | typeof TabView | typeof MessageService | typeof ConfirmationService | {
5
+ export declare const SharedUiTsiProviders: (typeof TabView | typeof DynamicDialogRef | typeof DynamicDialogConfig | typeof JwtHelperService | typeof MessageService | typeof ConfirmationService | {
6
6
  provide: import("@angular/core").InjectionToken<unknown>;
7
7
  useValue: import("@angular/core").InjectionToken<unknown>;
8
8
  })[];
@@ -1,18 +1,23 @@
1
- import { EventEmitter, OnInit } from '@angular/core';
1
+ import { EventEmitter } from '@angular/core';
2
2
  import { TsiInputBase } from '../../../tsi-base/tsi-input-base/tsi-input-base.component';
3
- import { LocalizePipe } from '../../../pipes/localize.pipe';
3
+ import { CurrencyState } from '../../../functions/currency-state.functions';
4
4
  import * as i0 from "@angular/core";
5
- export declare class TsiCurrencyOtherInputComponent extends TsiInputBase<number | undefined> implements OnInit {
6
- private _localizationPipe;
7
- numOfDecimal?: number;
8
- currency?: string;
5
+ export declare class TsiCurrencyOtherInputComponent extends TsiInputBase<number | undefined> {
6
+ protected currencyState: CurrencyState;
7
+ protected tooltipMessage: string;
8
+ private isValueChanged;
9
+ private _currency?;
10
+ get currency(): string | undefined;
11
+ set currency(value: string | undefined);
12
+ get inputField(): number | undefined;
13
+ set inputField(value: number | undefined);
9
14
  class: any;
10
15
  inputFieldChange: EventEmitter<number>;
11
- private isValueChanged;
12
- constructor(_localizationPipe: LocalizePipe);
16
+ private _localizePipe;
17
+ ngOnInit(): void;
13
18
  valueChanged(event: any): void;
14
19
  onChangeofOptions(): void;
15
- ngOnInit(): void;
20
+ private updateCurrencyState;
16
21
  static ɵfac: i0.ɵɵFactoryDeclaration<TsiCurrencyOtherInputComponent, never>;
17
- static ɵcmp: i0.ɵɵComponentDeclaration<TsiCurrencyOtherInputComponent, "Tsi-Currency-Other-Input", never, { "numOfDecimal": { "alias": "numOfDecimal"; "required": false; }; "currency": { "alias": "currency"; "required": false; }; "class": { "alias": "class"; "required": false; }; }, { "inputFieldChange": "inputFieldChange"; }, never, never, false, never>;
22
+ static ɵcmp: i0.ɵɵComponentDeclaration<TsiCurrencyOtherInputComponent, "Tsi-Currency-Other-Input", never, { "currency": { "alias": "currency"; "required": false; }; "class": { "alias": "class"; "required": false; }; }, { "inputFieldChange": "inputFieldChange"; }, never, never, false, never>;
18
23
  }
@@ -1,21 +1,24 @@
1
- import { EventEmitter, OnInit } from '@angular/core';
1
+ import { EventEmitter } from '@angular/core';
2
2
  import { TsiInputBase } from '../../../tsi-base/tsi-input-base/tsi-input-base.component';
3
- import { AppSettingsService } from '../../../services/settings/app-settings.service';
4
- import { LocalizePipe } from '../../../pipes/localize.pipe';
3
+ import { CurrencyState } from '../../../functions/currency-state.functions';
5
4
  import * as i0 from "@angular/core";
6
- export declare class TsiCurrencySocieteInputComponent extends TsiInputBase<number | undefined> implements OnInit {
7
- private appSettingsService;
8
- private _localizationPipe;
9
- currency: string;
10
- protected numOfDecimal?: number;
5
+ export declare class TsiCurrencySocieteInputComponent extends TsiInputBase<number | undefined> {
6
+ private isValueChanged;
7
+ protected currency: string;
8
+ protected currencyState: CurrencyState;
9
+ protected tooltipMessage: string;
11
10
  style: any;
11
+ get inputField(): number | undefined;
12
+ set inputField(value: number | undefined);
12
13
  class: any;
13
14
  inputFieldChange: EventEmitter<number>;
14
- private isValueChanged;
15
- constructor(appSettingsService: AppSettingsService, _localizationPipe: LocalizePipe);
15
+ private _appSettingsService;
16
+ private _localizePipe;
17
+ constructor();
16
18
  ngOnInit(): void;
17
19
  valueChanged(event: any): void;
18
20
  onChangeofOptions(): void;
21
+ private updateCurrencyState;
19
22
  static ɵfac: i0.ɵɵFactoryDeclaration<TsiCurrencySocieteInputComponent, never>;
20
23
  static ɵcmp: i0.ɵɵComponentDeclaration<TsiCurrencySocieteInputComponent, "Tsi-Currency-Societe-Input", never, { "class": { "alias": "class"; "required": false; }; }, { "inputFieldChange": "inputFieldChange"; }, never, never, false, never>;
21
24
  }
@@ -1,11 +1,21 @@
1
- import { LocaleCode } from '../../../enums/Language';
1
+ import { OnInit } from '@angular/core';
2
+ import { CurrencyState } from '../../../functions/currency-state.functions';
2
3
  import * as i0 from "@angular/core";
3
- export declare class TsiCurrencyOtherDisplayComponent {
4
+ export declare class TsiCurrencyOtherDisplayComponent implements OnInit {
5
+ protected currencyState: CurrencyState;
6
+ protected tooltipMessage: string;
7
+ private _currency?;
8
+ private _inputData?;
9
+ get currency(): string | undefined;
10
+ get inputData(): number | undefined;
11
+ set currency(value: string | undefined);
12
+ set inputData(value: number | undefined);
13
+ private _localizePipe;
4
14
  private _localizationService;
5
- protected locale: LocaleCode;
15
+ private readonly _locale;
6
16
  constructor();
7
- inputData?: number;
8
- currency?: string;
17
+ ngOnInit(): void;
18
+ private updateCurrencyState;
9
19
  static ɵfac: i0.ɵɵFactoryDeclaration<TsiCurrencyOtherDisplayComponent, never>;
10
- static ɵcmp: i0.ɵɵComponentDeclaration<TsiCurrencyOtherDisplayComponent, "Tsi-Currency-Other-Display", never, { "inputData": { "alias": "inputData"; "required": false; }; "currency": { "alias": "currency"; "required": false; }; }, {}, never, never, false, never>;
20
+ static ɵcmp: i0.ɵɵComponentDeclaration<TsiCurrencyOtherDisplayComponent, "Tsi-Currency-Other-Display", never, { "currency": { "alias": "currency"; "required": false; }; "inputData": { "alias": "inputData"; "required": false; }; }, {}, never, never, false, never>;
11
21
  }
@@ -1,21 +1,20 @@
1
1
  import { OnInit } from '@angular/core';
2
- import { LocalizePipe } from '../../../pipes/localize.pipe';
3
- import { AppSettingsService } from '../../../services/settings/app-settings.service';
4
- import { LocaleCode } from '../../../enums/Language';
2
+ import { CurrencyState } from '../../../functions/currency-state.functions';
5
3
  import * as i0 from "@angular/core";
6
4
  export declare class TsiCurrencySocieteDisplayComponent implements OnInit {
7
- private localizationPipe;
8
- private appSettingsService;
9
- currency: string;
10
- protected numOfDecimal?: number;
11
- private _digitsInfo;
5
+ protected currency: string;
6
+ protected currencyState: CurrencyState;
7
+ protected tooltipMessage: string;
8
+ private _inputData?;
9
+ get inputData(): number | undefined;
10
+ set inputData(value: number | undefined);
11
+ private _appSettingsService;
12
+ private _localizePipe;
12
13
  private _localizationService;
13
- protected locale: LocaleCode;
14
- inputData?: number;
15
- currencyTraductionKey: string;
16
- constructor(localizationPipe: LocalizePipe, appSettingsService: AppSettingsService);
17
- getDigitsInfo(): string;
14
+ private readonly _locale;
15
+ constructor();
18
16
  ngOnInit(): void;
17
+ private updateCurrencyState;
19
18
  static ɵfac: i0.ɵɵFactoryDeclaration<TsiCurrencySocieteDisplayComponent, never>;
20
19
  static ɵcmp: i0.ɵɵComponentDeclaration<TsiCurrencySocieteDisplayComponent, "Tsi-Currency-Societe-Display", never, { "inputData": { "alias": "inputData"; "required": false; }; }, {}, never, never, false, never>;
21
20
  }
@@ -1,49 +1,67 @@
1
+ import { KeyValue } from '@angular/common';
1
2
  import * as i0 from "@angular/core";
2
3
  /**
3
- * POC component used to validate and demonstrate the library's
4
- * locale integration and numeric formatting behavior.
4
+ * Proof-of-concept (POC) component used to validate and demonstrate
5
+ * the library's locale handling and numeric formatting behavior.
5
6
  *
6
- * The page allows testers to:
7
- * - Enter values using the library input components
8
- * - Immediately observe the formatted output using display components
7
+ * This page allows testers and developers to:
8
+ * - Enter values through input components
9
+ * - Instantly observe formatted results via display components
9
10
  *
10
- * This component is intended for:
11
- * - manual QA testing
12
- * - locale formatting validation
13
- * - development debugging
11
+ * Main purposes:
12
+ * - Manual QA validation
13
+ * - Locale and formatting verification
14
+ * - Development and debugging support
14
15
  *
15
- * Tested formatting types:
16
+ * Covered formatting scenarios:
16
17
  * - Company currency
17
18
  * - External currency
18
19
  * - Decimal numbers
19
20
  * - Rates / percentages
20
- * - Integers
21
+ * - Integers (with grouping)
21
22
  */
22
23
  export declare class LocalePocComponent {
23
24
  /**
24
- * Company currency value.
25
+ * Available currencies used for testing currency inputs and displays.
26
+ */
27
+ currencies: KeyValue<string, string>[];
28
+ /**
29
+ * Company currency code.
30
+ * Bound to the `Tsi-Currency-Societe-Input` component.
31
+ */
32
+ currencySocieteCode: string;
33
+ /**
34
+ * Company currency amount.
25
35
  * Bound to the `Tsi-Currency-Societe-Input` component.
26
36
  */
27
- currencySociete: number;
37
+ currencySocieteValue: number;
38
+ /**
39
+ * External currency code.
40
+ * Bound to the `Tsi-Currency-Other-Input` component.
41
+ */
42
+ currencyOtherCode: string;
28
43
  /**
29
- * External currency value.
44
+ * External currency amount.
30
45
  * Bound to the `Tsi-Currency-Other-Input` component.
31
46
  */
32
- currencyOther: number;
47
+ currencyOtherValue: number;
33
48
  /**
34
- * Decimal value used to validate locale-specific
35
- * decimal separators and grouping behavior.
49
+ * Decimal value used to validate locale-specific:
50
+ * - decimal separators
51
+ * - digit grouping behavior
36
52
  */
37
- decimal: number;
53
+ decimalValue: number;
38
54
  /**
39
55
  * Rate value used to test percentage / rate formatting.
40
56
  */
41
- rate: number;
57
+ rateValue: number;
42
58
  /**
43
59
  * Integer value used to validate thousands grouping
44
- * without decimal digits.
60
+ * without decimal precision.
45
61
  */
46
- integer: number;
62
+ integerValue: number;
63
+ private _appSettingsService;
64
+ constructor();
47
65
  static ɵfac: i0.ɵɵFactoryDeclaration<LocalePocComponent, never>;
48
66
  static ɵcmp: i0.ɵɵComponentDeclaration<LocalePocComponent, "lib-locale-poc", never, {}, {}, never, never, false, never>;
49
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsi-developpement/tsi-shared-ui",
3
- "version": "1.9.13",
3
+ "version": "1.10.0",
4
4
  "author": "TSI",
5
5
  "license": "MIT",
6
6
  "peerDependencies": {