@dsivd/prestations-ng 15.3.1-beta6 → 15.3.1-beta8

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.
@@ -6811,6 +6811,19 @@ function formatWithThousandSeparators(value) {
6811
6811
  return value.replace(CURRENCY_REGEXP, THOUSANDS_SEPARATOR);
6812
6812
  }
6813
6813
  // eslint-disable-next-line prefer-arrow/prefer-arrow-functions,jsdoc/require-jsdoc
6814
+ function formatNumberAsGiven(value) {
6815
+ if (value === undefined || value === null || value === '') {
6816
+ return null;
6817
+ }
6818
+ const [intg, dec] = removeFormatting(value).split(DECIMALS_SEPARATOR);
6819
+ if (!!dec?.length && dec !== undefined) {
6820
+ return formatWithThousandSeparators(intg) + DECIMALS_SEPARATOR + dec;
6821
+ }
6822
+ else {
6823
+ return formatWithThousandSeparators(intg);
6824
+ }
6825
+ }
6826
+ // eslint-disable-next-line prefer-arrow/prefer-arrow-functions,jsdoc/require-jsdoc
6814
6827
  function formatDecimalCurrency(value, maxDecimalCount, maxLength, allowFreeInput) {
6815
6828
  if (value === undefined || value === null || value === '') {
6816
6829
  return null;
@@ -6875,9 +6888,15 @@ class NumberCurrencyFormatterDirective {
6875
6888
  }
6876
6889
  setFormatting(value) {
6877
6890
  // Hooks on the inputs of the component to customize the behavior
6878
- const formattedValue = this.host.allowDecimal
6879
- ? formatDecimalCurrency(value, this.host.maxDecimalCount, this.host.maxlength, this.host.allowFreeInput)
6880
- : formatNonDecimalCurrency(value);
6891
+ let formattedValue = null;
6892
+ if (this.host.allowFreeInput && !this.host.allowDecimal) {
6893
+ formattedValue = formatNumberAsGiven(value);
6894
+ }
6895
+ else {
6896
+ formattedValue = this.host.allowDecimal
6897
+ ? formatDecimalCurrency(value, this.host.maxDecimalCount, this.host.maxlength, this.host.allowFreeInput)
6898
+ : formatNonDecimalCurrency(value);
6899
+ }
6881
6900
  const newValueWithoutFormatting = removeFormatting(formattedValue);
6882
6901
  if (this.hasValueChanged(newValueWithoutFormatting)) {
6883
6902
  // Since we have altered the model (i.e. by removing some decimals), we have to update it
@@ -6910,6 +6929,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
6910
6929
  args: ['modelChange', ['$event']]
6911
6930
  }] } });
6912
6931
 
6932
+ const isDefined = (value) => value === 0 || !!value;
6913
6933
  class FoehnInputNumberComponent extends FoehnInputStringComponent {
6914
6934
  constructor(currencyHelper, dictionaryService) {
6915
6935
  super();
@@ -6967,6 +6987,11 @@ class FoehnInputNumberComponent extends FoehnInputStringComponent {
6967
6987
  noCommaString && typeof noCommaString === 'string'
6968
6988
  ? noCommaString.replace(CLEAN_NEGATIVE_AND_DECIMAL_NUMBERS_PATTERN, '')
6969
6989
  : noCommaString;
6990
+ // check that it is a number in any of its possible form
6991
+ // to avoid -3.14-23--534
6992
+ if (!NEGATIVE_AND_DECIMAL_NUMBERS_PATTERN.test(cleanNumber)) {
6993
+ cleanNumber = this.model;
6994
+ }
6970
6995
  }
6971
6996
  super.updateNgModel(cleanNumber);
6972
6997
  // Need to update HTML input value because we let user input what he wants and then we clean model
@@ -6981,35 +7006,11 @@ class FoehnInputNumberComponent extends FoehnInputStringComponent {
6981
7006
  this.model_ = value;
6982
7007
  this.updateInputElementValue(value);
6983
7008
  }
6984
- isValueInRange(value) {
6985
- if (this.allowNegative && value === '-') {
6986
- return true;
6987
- }
6988
- const valueAsNumber = this.toNumber(value);
6989
- if (!this.isEmpty(this.min) || !this.isEmpty(this.max)) {
6990
- if (isNaN(valueAsNumber)) {
6991
- return false;
6992
- }
6993
- if (!this.isEmpty(this.min) && !this.isEmpty(this.max)) {
6994
- return valueAsNumber >= this.min && valueAsNumber <= this.max;
6995
- }
6996
- if (!this.isEmpty(this.min)) {
6997
- return valueAsNumber >= this.min;
6998
- }
6999
- if (!this.isEmpty(this.max)) {
7000
- return valueAsNumber <= this.max;
7001
- }
7002
- }
7003
- return true;
7004
- }
7005
- toNumber(value) {
7006
- return this.allowDecimal ? parseFloat(value) : parseInt(value, 10);
7007
- }
7008
7009
  isStringAValidNumber(value) {
7009
7010
  return this.getValidationRegex().test(value);
7010
7011
  }
7011
7012
  isModelValid(value) {
7012
- return this.isStringAValidNumber(value) && this.isValueInRange(value);
7013
+ return this.isStringAValidNumber(value);
7013
7014
  }
7014
7015
  getValidationRegex(isForClean = false) {
7015
7016
  if (this.allowDecimal || this.allowNegative) {
@@ -7082,6 +7083,21 @@ class FoehnInputNumberComponent extends FoehnInputStringComponent {
7082
7083
  if (!!this.hideStandardHelpText) {
7083
7084
  return;
7084
7085
  }
7086
+ if (!this.allowFreeInput) {
7087
+ if (isDefined(this.min) && isDefined(this.max)) {
7088
+ if (!!this.helpText?.length) {
7089
+ this.helpText += '<br/>';
7090
+ }
7091
+ else {
7092
+ this.helpText = '';
7093
+ }
7094
+ this.helpText += this.dictionaryService.getKeySync('foehn-input-number.standard-help-text.label', {
7095
+ minValue: formatNumberAsGiven(this.min.toString()),
7096
+ maxValue: formatNumberAsGiven(this.max.toString())
7097
+ });
7098
+ }
7099
+ return;
7100
+ }
7085
7101
  if (!!this.helpText?.length) {
7086
7102
  this.helpText += '<br/>';
7087
7103
  }
@@ -12823,5 +12839,5 @@ class SelectedSlot {
12823
12839
  * Generated bundle index. Do not edit.
12824
12840
  */
12825
12841
 
12826
- export { APP_INFO_API_URL, AbstractFoehnUploaderComponent, AbstractListDetailPageComponent, AbstractMenuPageComponent, AbstractPageComponent, AbstractPageFromMenuComponent, ActionStatut, Address, AddressTypeLight, ApplicationInfo, ApplicationInfoService, BAD_PARAMS_HELP_TEXT, BoDocumentError, BoDocumentsWithErrors, BoMultiUploadService, Breadcrumb, BreadcrumbEventService, BreadcrumbItem, CAPTCHA_ERROR_NAME, CURRENCY_REGEXP, Calendar, Canton, Captcha, ComponentError, Configuration, Country, CurrencyHelper, CurrentWeek, DECIMALS_SEPARATOR, DEFAULT_INTERNATIONAL_AND_NO_SWISS, DEFAULT_INTERNATIONAL_AND_NO_SWISS_MOBILE, DEFAULT_INTERNATIONAL_AND_NO_SWISS_PHONE, DEFAULT_INTERNATIONAL_HELP_TEXT, DEFAULT_SWISS_HELP_TEXT, DEFAULT_SWISS_MOBILE_PHONE_HELP_TEXT, DEFAULT_SWISS_PHONE_HELP_TEXT, DICTIONARY_BASE_URL, DateHelper, DatePickerHelper, DatePickerNavigationHelper, DayMonth, DaySlots, DisplayCurrencyPipe, DisplayDatePipe, DisplayLoginMessagesData, District, Document, DocumentError, DocumentReference, DocumentReferenceWithFile, DocumentsWithErrors, EPaymentService, EtapeInfo, FORM_SUPPORT_CYBER_TITLE_FALLBACK, FocusedDay, FoehnAbbrComponent, FoehnAddressModule, FoehnAgendaComponent, FoehnAgendaModule, FoehnAgendaNavigationComponent, FoehnAgendaTimeslotPanelComponent, FoehnAutocompleteComponent, FoehnAutocompleteModule, FoehnBoMultiUploadComponent, FoehnBoMultiUploadModule, FoehnBooleanCheckboxComponent, FoehnBooleanModule, FoehnBooleanRadioComponent, FoehnBreadcrumbComponent, FoehnBreadcrumbModule, FoehnCheckableGroupComponent, FoehnCheckablesModule, FoehnCheckboxComponent, FoehnConfirmModalComponent, FoehnConfirmModalContent, FoehnConfirmModalModule, FoehnConfirmModalService, FoehnDateComponent, FoehnDatePickerButtonComponent, FoehnDatePickerButtonModule, FoehnDatePickerComponent, FoehnDatePickerModule, FoehnDecisionElectroniqueComponent, FoehnDecisionElectroniqueModule, FoehnDisplayAddressComponent, FoehnErrorPillComponent, FoehnFormComponent, FoehnFormModule, FoehnHeaderComponent, FoehnHeaderModule, FoehnHelpModalComponent, FoehnHelpModalModule, FoehnIconCalendarComponent, FoehnIconCheckComponent, FoehnIconCheckSquareOComponent, FoehnIconChevronDownComponent, FoehnIconChevronLeftComponent, FoehnIconChevronRightComponent, FoehnIconChevronUpComponent, FoehnIconClockComponent, FoehnIconCommentDotsComponent, FoehnIconEditComponent, FoehnIconExternalLinkAltComponent, FoehnIconFilePdfComponent, FoehnIconInfoCircleComponent, FoehnIconLockComponent, FoehnIconMapMarkerComponent, FoehnIconMinusCircleComponent, FoehnIconPlusCircleComponent, FoehnIconPlusSquareComponent, FoehnIconSearchComponent, FoehnIconTimesComponent, FoehnIconTrashAltComponent, FoehnIconUnlockAltComponent, FoehnIconsModule, FoehnInputAddressComponent, FoehnInputComponent, FoehnInputEmailComponent, FoehnInputForeignLocalityComponent, FoehnInputForeignStreetComponent, FoehnInputHiddenComponent, FoehnInputModule, FoehnInputNav13Component, FoehnInputNav13Module, FoehnInputNumberComponent, FoehnInputPasswordComponent, FoehnInputPhoneComponent, FoehnInputStringComponent, FoehnInputTextComponent, FoehnInputTextareaComponent, FoehnListComponent, FoehnListItem, FoehnListModule, FoehnListSummaryComponent, FoehnMenuItemComponent, FoehnMenuItemTransmitComponent, FoehnMenuPrestationModule, FoehnMiscModule, FoehnModalComponent, FoehnModalModule, FoehnMultiUploadComponent, FoehnMultiUploadModule, FoehnMultiselectAutocompleteComponent, FoehnMultiselectAutocompleteModule, FoehnNavigationComponent, FoehnNavigationModule, FoehnNavigationService, FoehnNotFoundModule, FoehnNotfoundComponent, FoehnPageComponent, FoehnPageCounterComponent, FoehnPageModalComponent, FoehnPageModule, FoehnPageService, FoehnPictureUploadComponent, FoehnPictureUploadModule, FoehnRadioComponent, FoehnRecapSectionComponent, FoehnRecapSectionModule, FoehnRemainingAlertsSummaryComponent, FoehnRemainingAlertsSummaryModule, FoehnSelectComponent, FoehnSkipLinkComponent, FoehnStatusProgressBarComponent, FoehnStatusProgressBarModule, FoehnTableColumnConfiguration, FoehnTableComponent, FoehnTableModule, FoehnTablePageChangeEvent, FoehnTimeComponent, FoehnUserConnectedAsComponent, FoehnUserConnectedAsModule, FoehnValidationAlertSummaryComponent, FoehnValidationAlertSummaryModule, FoehnValidationAlertsComponent, FoehnValidationAlertsModule, FooterLink, FormMetadata, FormPostResponse, FormSelectOption, FormatIdePipe, FormatterModule, GESDEM_MAX_DATA_LENGTH, GesdemActionRecoveryLoginComponent, GesdemActionRecoveryModule, GesdemActionRecoveryRegistrationComponent, GesdemConfirmationComponent, GesdemConfirmationModule, GesdemErrorComponent, GesdemErrorModule, GesdemEventService, GesdemHandlerService, GesdemLoaderGuard, GesdemStatutUtils, GrowlBrokerService, GrowlMessage, GrowlType, I18nForm, IbanFormatterDirective, IdeFormatterDirective, Locality, MonthYear, MultiUploadService, Municipality, NDCFormatterDirective, NavigationDirection, NumberCurrencyFormatterDirective, ObjectHelper, PORTAIL_BASE_URL_INT, PageChangeEvent, PaginationWeek, PendingFiles, PendingUploadService, PipeModule, PlaceOfOrigin, Portail, PostalLocality, Preferences, PrestationsNgCoreModule, RECAPTCHA_API_URL, RecaptchaService, RedirectComponent, SESSION_INFO_API_URL, SWISS_ISO_ID, SdkDictionaryModule, SdkDictionaryPipe, SdkDictionaryService, SdkEpaymentComponent, SdkEpaymentModule, SdkRecaptchaComponent, SdkRecaptchaModule, SdkRedirectModule, SdkStatisticsService, SelectedSlot, ServiceLocator, SessionInfo, SessionInfoData, SessionInfoWithApplicationService, Street, StreetNumber, THOUSANDS_SEPARATOR, TableSort, UploaderHelper, ValidationHandlerService, formatDecimalCurrency, formatNonDecimalCurrency, replaceAll };
12842
+ export { APP_INFO_API_URL, AbstractFoehnUploaderComponent, AbstractListDetailPageComponent, AbstractMenuPageComponent, AbstractPageComponent, AbstractPageFromMenuComponent, ActionStatut, Address, AddressTypeLight, ApplicationInfo, ApplicationInfoService, BAD_PARAMS_HELP_TEXT, BoDocumentError, BoDocumentsWithErrors, BoMultiUploadService, Breadcrumb, BreadcrumbEventService, BreadcrumbItem, CAPTCHA_ERROR_NAME, CURRENCY_REGEXP, Calendar, Canton, Captcha, ComponentError, Configuration, Country, CurrencyHelper, CurrentWeek, DECIMALS_SEPARATOR, DEFAULT_INTERNATIONAL_AND_NO_SWISS, DEFAULT_INTERNATIONAL_AND_NO_SWISS_MOBILE, DEFAULT_INTERNATIONAL_AND_NO_SWISS_PHONE, DEFAULT_INTERNATIONAL_HELP_TEXT, DEFAULT_SWISS_HELP_TEXT, DEFAULT_SWISS_MOBILE_PHONE_HELP_TEXT, DEFAULT_SWISS_PHONE_HELP_TEXT, DICTIONARY_BASE_URL, DateHelper, DatePickerHelper, DatePickerNavigationHelper, DayMonth, DaySlots, DisplayCurrencyPipe, DisplayDatePipe, DisplayLoginMessagesData, District, Document, DocumentError, DocumentReference, DocumentReferenceWithFile, DocumentsWithErrors, EPaymentService, EtapeInfo, FORM_SUPPORT_CYBER_TITLE_FALLBACK, FocusedDay, FoehnAbbrComponent, FoehnAddressModule, FoehnAgendaComponent, FoehnAgendaModule, FoehnAgendaNavigationComponent, FoehnAgendaTimeslotPanelComponent, FoehnAutocompleteComponent, FoehnAutocompleteModule, FoehnBoMultiUploadComponent, FoehnBoMultiUploadModule, FoehnBooleanCheckboxComponent, FoehnBooleanModule, FoehnBooleanRadioComponent, FoehnBreadcrumbComponent, FoehnBreadcrumbModule, FoehnCheckableGroupComponent, FoehnCheckablesModule, FoehnCheckboxComponent, FoehnConfirmModalComponent, FoehnConfirmModalContent, FoehnConfirmModalModule, FoehnConfirmModalService, FoehnDateComponent, FoehnDatePickerButtonComponent, FoehnDatePickerButtonModule, FoehnDatePickerComponent, FoehnDatePickerModule, FoehnDecisionElectroniqueComponent, FoehnDecisionElectroniqueModule, FoehnDisplayAddressComponent, FoehnErrorPillComponent, FoehnFormComponent, FoehnFormModule, FoehnHeaderComponent, FoehnHeaderModule, FoehnHelpModalComponent, FoehnHelpModalModule, FoehnIconCalendarComponent, FoehnIconCheckComponent, FoehnIconCheckSquareOComponent, FoehnIconChevronDownComponent, FoehnIconChevronLeftComponent, FoehnIconChevronRightComponent, FoehnIconChevronUpComponent, FoehnIconClockComponent, FoehnIconCommentDotsComponent, FoehnIconEditComponent, FoehnIconExternalLinkAltComponent, FoehnIconFilePdfComponent, FoehnIconInfoCircleComponent, FoehnIconLockComponent, FoehnIconMapMarkerComponent, FoehnIconMinusCircleComponent, FoehnIconPlusCircleComponent, FoehnIconPlusSquareComponent, FoehnIconSearchComponent, FoehnIconTimesComponent, FoehnIconTrashAltComponent, FoehnIconUnlockAltComponent, FoehnIconsModule, FoehnInputAddressComponent, FoehnInputComponent, FoehnInputEmailComponent, FoehnInputForeignLocalityComponent, FoehnInputForeignStreetComponent, FoehnInputHiddenComponent, FoehnInputModule, FoehnInputNav13Component, FoehnInputNav13Module, FoehnInputNumberComponent, FoehnInputPasswordComponent, FoehnInputPhoneComponent, FoehnInputStringComponent, FoehnInputTextComponent, FoehnInputTextareaComponent, FoehnListComponent, FoehnListItem, FoehnListModule, FoehnListSummaryComponent, FoehnMenuItemComponent, FoehnMenuItemTransmitComponent, FoehnMenuPrestationModule, FoehnMiscModule, FoehnModalComponent, FoehnModalModule, FoehnMultiUploadComponent, FoehnMultiUploadModule, FoehnMultiselectAutocompleteComponent, FoehnMultiselectAutocompleteModule, FoehnNavigationComponent, FoehnNavigationModule, FoehnNavigationService, FoehnNotFoundModule, FoehnNotfoundComponent, FoehnPageComponent, FoehnPageCounterComponent, FoehnPageModalComponent, FoehnPageModule, FoehnPageService, FoehnPictureUploadComponent, FoehnPictureUploadModule, FoehnRadioComponent, FoehnRecapSectionComponent, FoehnRecapSectionModule, FoehnRemainingAlertsSummaryComponent, FoehnRemainingAlertsSummaryModule, FoehnSelectComponent, FoehnSkipLinkComponent, FoehnStatusProgressBarComponent, FoehnStatusProgressBarModule, FoehnTableColumnConfiguration, FoehnTableComponent, FoehnTableModule, FoehnTablePageChangeEvent, FoehnTimeComponent, FoehnUserConnectedAsComponent, FoehnUserConnectedAsModule, FoehnValidationAlertSummaryComponent, FoehnValidationAlertSummaryModule, FoehnValidationAlertsComponent, FoehnValidationAlertsModule, FooterLink, FormMetadata, FormPostResponse, FormSelectOption, FormatIdePipe, FormatterModule, GESDEM_MAX_DATA_LENGTH, GesdemActionRecoveryLoginComponent, GesdemActionRecoveryModule, GesdemActionRecoveryRegistrationComponent, GesdemConfirmationComponent, GesdemConfirmationModule, GesdemErrorComponent, GesdemErrorModule, GesdemEventService, GesdemHandlerService, GesdemLoaderGuard, GesdemStatutUtils, GrowlBrokerService, GrowlMessage, GrowlType, I18nForm, IbanFormatterDirective, IdeFormatterDirective, Locality, MonthYear, MultiUploadService, Municipality, NDCFormatterDirective, NavigationDirection, NumberCurrencyFormatterDirective, ObjectHelper, PORTAIL_BASE_URL_INT, PageChangeEvent, PaginationWeek, PendingFiles, PendingUploadService, PipeModule, PlaceOfOrigin, Portail, PostalLocality, Preferences, PrestationsNgCoreModule, RECAPTCHA_API_URL, RecaptchaService, RedirectComponent, SESSION_INFO_API_URL, SWISS_ISO_ID, SdkDictionaryModule, SdkDictionaryPipe, SdkDictionaryService, SdkEpaymentComponent, SdkEpaymentModule, SdkRecaptchaComponent, SdkRecaptchaModule, SdkRedirectModule, SdkStatisticsService, SelectedSlot, ServiceLocator, SessionInfo, SessionInfoData, SessionInfoWithApplicationService, Street, StreetNumber, THOUSANDS_SEPARATOR, TableSort, UploaderHelper, ValidationHandlerService, formatDecimalCurrency, formatNonDecimalCurrency, formatNumberAsGiven, replaceAll };
12827
12843
  //# sourceMappingURL=dsivd-prestations-ng.mjs.map