@pepperi-addons/ngx-lib 0.4.2-beta.98 → 0.4.2-scroll.1

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 (185) hide show
  1. package/chips/chips.component.d.ts +1 -3
  2. package/core/common/pipes/common-pipes.d.ts +3 -0
  3. package/core/customization/customization.model.d.ts +1 -1
  4. package/esm2020/checkbox/checkbox.component.mjs +3 -3
  5. package/esm2020/chips/chips.component.mjs +8 -11
  6. package/esm2020/color/color.component.mjs +3 -3
  7. package/esm2020/core/common/pipes/common-pipes.mjs +14 -4
  8. package/esm2020/core/customization/customization.model.mjs +7 -1
  9. package/esm2020/core/customization/customization.service.mjs +2 -1
  10. package/esm2020/core/http/services/loader.service.mjs +3 -3
  11. package/esm2020/draggable-items/draggable-items.component.mjs +3 -3
  12. package/esm2020/form/field-generator.component.mjs +3 -3
  13. package/esm2020/form/form.component.mjs +3 -3
  14. package/esm2020/form/internal-carusel.component.mjs +10 -6
  15. package/esm2020/form/internal-field-generator.component.mjs +3 -3
  16. package/esm2020/form/internal-form.component.mjs +3 -3
  17. package/esm2020/form/internal-menu.component.mjs +4 -6
  18. package/esm2020/form/internal-page.component.mjs +3 -4
  19. package/esm2020/image/image.component.mjs +3 -3
  20. package/esm2020/images-filmstrip/images-filmstrip.component.mjs +3 -3
  21. package/esm2020/link/link.component.mjs +9 -3
  22. package/esm2020/list/list-actions.component.mjs +1 -1
  23. package/esm2020/list/list-chooser.component.mjs +1 -1
  24. package/esm2020/list/list-sorting.component.mjs +1 -1
  25. package/esm2020/list/list-views.component.mjs +1 -1
  26. package/esm2020/list/list.component.mjs +22 -10
  27. package/esm2020/list/list.model.mjs +1 -1
  28. package/esm2020/menu/menu-item.component.mjs +3 -3
  29. package/esm2020/menu/menu.component.mjs +6 -3
  30. package/esm2020/menu/menu.model.mjs +2 -1
  31. package/esm2020/profile-data-views-list/profile-data-view/profile-data-view.component.mjs +1 -1
  32. package/esm2020/profile-data-views-list/profile-data-views-card/profile-data-views-card.component.mjs +25 -9
  33. package/esm2020/profile-data-views-list/profile-data-views-list.component.mjs +58 -26
  34. package/esm2020/profile-data-views-list/profile-data-views-list.model.mjs +1 -1
  35. package/esm2020/quantity-selector/quantity-selector.component.mjs +7 -3
  36. package/esm2020/query-builder/common/model/legacy.mjs +1 -1
  37. package/esm2020/query-builder/common/model/operator.mjs +72 -62
  38. package/esm2020/query-builder/common/services/output-query.service.mjs +5 -3
  39. package/esm2020/query-builder/common/services/query-structure.service.mjs +24 -1
  40. package/esm2020/query-builder/query-builder-item/query-builder-item.component.mjs +3 -3
  41. package/esm2020/query-builder/query-builder-section/query-builder-section.component.mjs +3 -3
  42. package/esm2020/query-builder/query-builder.module.mjs +14 -3
  43. package/esm2020/query-builder/query-builder.service.mjs +2 -2
  44. package/esm2020/remote-loader/remote-loader.service.mjs +16 -16
  45. package/esm2020/rich-html-textarea/rich-html-textarea.component.mjs +10 -3
  46. package/esm2020/select/select.component.mjs +3 -3
  47. package/esm2020/select-panel/select-panel.component.mjs +3 -5
  48. package/esm2020/signature/signature-dialog.component.mjs +2 -1
  49. package/esm2020/signature/signature.component.mjs +4 -4
  50. package/esm2020/skeleton-loader/public-api.mjs +2 -2
  51. package/esm2020/skeleton-loader/skeleton-loader.component.mjs +3 -3
  52. package/esm2020/smart-filters/common/model/operator.mjs +11 -4
  53. package/esm2020/smart-filters/common/model/type.mjs +1 -1
  54. package/esm2020/smart-filters/multi-select-filter/multi-select-filter.component.mjs +3 -3
  55. package/esm2020/smart-filters/text-filter/text-filter.component.mjs +3 -3
  56. package/esm2020/textbox/textbox.component.mjs +26 -6
  57. package/fesm2015/pepperi-addons-ngx-lib-checkbox.mjs +2 -2
  58. package/fesm2015/pepperi-addons-ngx-lib-checkbox.mjs.map +1 -1
  59. package/fesm2015/pepperi-addons-ngx-lib-chips.mjs +7 -10
  60. package/fesm2015/pepperi-addons-ngx-lib-chips.mjs.map +1 -1
  61. package/fesm2015/pepperi-addons-ngx-lib-color.mjs +2 -2
  62. package/fesm2015/pepperi-addons-ngx-lib-color.mjs.map +1 -1
  63. package/fesm2015/pepperi-addons-ngx-lib-draggable-items.mjs +2 -2
  64. package/fesm2015/pepperi-addons-ngx-lib-draggable-items.mjs.map +1 -1
  65. package/fesm2015/pepperi-addons-ngx-lib-form.mjs +22 -21
  66. package/fesm2015/pepperi-addons-ngx-lib-form.mjs.map +1 -1
  67. package/fesm2015/pepperi-addons-ngx-lib-image.mjs +2 -2
  68. package/fesm2015/pepperi-addons-ngx-lib-image.mjs.map +1 -1
  69. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.mjs +2 -2
  70. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.mjs.map +1 -1
  71. package/fesm2015/pepperi-addons-ngx-lib-link.mjs +8 -2
  72. package/fesm2015/pepperi-addons-ngx-lib-link.mjs.map +1 -1
  73. package/fesm2015/pepperi-addons-ngx-lib-list.mjs +25 -13
  74. package/fesm2015/pepperi-addons-ngx-lib-list.mjs.map +1 -1
  75. package/fesm2015/pepperi-addons-ngx-lib-menu.mjs +8 -4
  76. package/fesm2015/pepperi-addons-ngx-lib-menu.mjs.map +1 -1
  77. package/fesm2015/pepperi-addons-ngx-lib-profile-data-views-list.mjs +81 -33
  78. package/fesm2015/pepperi-addons-ngx-lib-profile-data-views-list.mjs.map +1 -1
  79. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.mjs +7 -2
  80. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.mjs.map +1 -1
  81. package/fesm2015/pepperi-addons-ngx-lib-query-builder.mjs +119 -70
  82. package/fesm2015/pepperi-addons-ngx-lib-query-builder.mjs.map +1 -1
  83. package/fesm2015/pepperi-addons-ngx-lib-remote-loader.mjs +16 -16
  84. package/fesm2015/pepperi-addons-ngx-lib-remote-loader.mjs.map +1 -1
  85. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.mjs +9 -2
  86. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.mjs.map +1 -1
  87. package/fesm2015/pepperi-addons-ngx-lib-select-panel.mjs +2 -4
  88. package/fesm2015/pepperi-addons-ngx-lib-select-panel.mjs.map +1 -1
  89. package/fesm2015/pepperi-addons-ngx-lib-select.mjs +2 -2
  90. package/fesm2015/pepperi-addons-ngx-lib-select.mjs.map +1 -1
  91. package/fesm2015/pepperi-addons-ngx-lib-signature.mjs +5 -3
  92. package/fesm2015/pepperi-addons-ngx-lib-signature.mjs.map +1 -1
  93. package/fesm2015/pepperi-addons-ngx-lib-skeleton-loader.mjs +3 -3
  94. package/fesm2015/pepperi-addons-ngx-lib-skeleton-loader.mjs.map +1 -1
  95. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.mjs +14 -7
  96. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.mjs.map +1 -1
  97. package/fesm2015/pepperi-addons-ngx-lib-textbox.mjs +26 -5
  98. package/fesm2015/pepperi-addons-ngx-lib-textbox.mjs.map +1 -1
  99. package/fesm2015/pepperi-addons-ngx-lib.mjs +547 -532
  100. package/fesm2015/pepperi-addons-ngx-lib.mjs.map +1 -1
  101. package/fesm2020/pepperi-addons-ngx-lib-checkbox.mjs +2 -2
  102. package/fesm2020/pepperi-addons-ngx-lib-checkbox.mjs.map +1 -1
  103. package/fesm2020/pepperi-addons-ngx-lib-chips.mjs +7 -10
  104. package/fesm2020/pepperi-addons-ngx-lib-chips.mjs.map +1 -1
  105. package/fesm2020/pepperi-addons-ngx-lib-color.mjs +2 -2
  106. package/fesm2020/pepperi-addons-ngx-lib-color.mjs.map +1 -1
  107. package/fesm2020/pepperi-addons-ngx-lib-draggable-items.mjs +2 -2
  108. package/fesm2020/pepperi-addons-ngx-lib-draggable-items.mjs.map +1 -1
  109. package/fesm2020/pepperi-addons-ngx-lib-form.mjs +22 -21
  110. package/fesm2020/pepperi-addons-ngx-lib-form.mjs.map +1 -1
  111. package/fesm2020/pepperi-addons-ngx-lib-image.mjs +2 -2
  112. package/fesm2020/pepperi-addons-ngx-lib-image.mjs.map +1 -1
  113. package/fesm2020/pepperi-addons-ngx-lib-images-filmstrip.mjs +2 -2
  114. package/fesm2020/pepperi-addons-ngx-lib-images-filmstrip.mjs.map +1 -1
  115. package/fesm2020/pepperi-addons-ngx-lib-link.mjs +8 -2
  116. package/fesm2020/pepperi-addons-ngx-lib-link.mjs.map +1 -1
  117. package/fesm2020/pepperi-addons-ngx-lib-list.mjs +25 -13
  118. package/fesm2020/pepperi-addons-ngx-lib-list.mjs.map +1 -1
  119. package/fesm2020/pepperi-addons-ngx-lib-menu.mjs +8 -4
  120. package/fesm2020/pepperi-addons-ngx-lib-menu.mjs.map +1 -1
  121. package/fesm2020/pepperi-addons-ngx-lib-profile-data-views-list.mjs +81 -33
  122. package/fesm2020/pepperi-addons-ngx-lib-profile-data-views-list.mjs.map +1 -1
  123. package/fesm2020/pepperi-addons-ngx-lib-quantity-selector.mjs +6 -2
  124. package/fesm2020/pepperi-addons-ngx-lib-quantity-selector.mjs.map +1 -1
  125. package/fesm2020/pepperi-addons-ngx-lib-query-builder.mjs +115 -69
  126. package/fesm2020/pepperi-addons-ngx-lib-query-builder.mjs.map +1 -1
  127. package/fesm2020/pepperi-addons-ngx-lib-remote-loader.mjs +15 -15
  128. package/fesm2020/pepperi-addons-ngx-lib-remote-loader.mjs.map +1 -1
  129. package/fesm2020/pepperi-addons-ngx-lib-rich-html-textarea.mjs +9 -2
  130. package/fesm2020/pepperi-addons-ngx-lib-rich-html-textarea.mjs.map +1 -1
  131. package/fesm2020/pepperi-addons-ngx-lib-select-panel.mjs +2 -4
  132. package/fesm2020/pepperi-addons-ngx-lib-select-panel.mjs.map +1 -1
  133. package/fesm2020/pepperi-addons-ngx-lib-select.mjs +2 -2
  134. package/fesm2020/pepperi-addons-ngx-lib-select.mjs.map +1 -1
  135. package/fesm2020/pepperi-addons-ngx-lib-signature.mjs +4 -3
  136. package/fesm2020/pepperi-addons-ngx-lib-signature.mjs.map +1 -1
  137. package/fesm2020/pepperi-addons-ngx-lib-skeleton-loader.mjs +3 -3
  138. package/fesm2020/pepperi-addons-ngx-lib-skeleton-loader.mjs.map +1 -1
  139. package/fesm2020/pepperi-addons-ngx-lib-smart-filters.mjs +14 -7
  140. package/fesm2020/pepperi-addons-ngx-lib-smart-filters.mjs.map +1 -1
  141. package/fesm2020/pepperi-addons-ngx-lib-textbox.mjs +25 -5
  142. package/fesm2020/pepperi-addons-ngx-lib-textbox.mjs.map +1 -1
  143. package/fesm2020/pepperi-addons-ngx-lib.mjs +544 -529
  144. package/fesm2020/pepperi-addons-ngx-lib.mjs.map +1 -1
  145. package/form/internal-carusel.component.d.ts +1 -0
  146. package/form/internal-menu.component.d.ts +1 -2
  147. package/link/link.component.d.ts +3 -1
  148. package/list/list.component.d.ts +1 -1
  149. package/list/list.model.d.ts +1 -2
  150. package/menu/menu.component.d.ts +2 -1
  151. package/menu/menu.model.d.ts +1 -0
  152. package/package.json +1 -1
  153. package/profile-data-views-list/profile-data-view/profile-data-view.component.d.ts +3 -3
  154. package/profile-data-views-list/profile-data-views-card/profile-data-views-card.component.d.ts +5 -4
  155. package/profile-data-views-list/profile-data-views-list.component.d.ts +13 -10
  156. package/profile-data-views-list/profile-data-views-list.model.d.ts +8 -0
  157. package/query-builder/common/model/legacy.d.ts +2 -0
  158. package/query-builder/common/model/operator.d.ts +11 -1
  159. package/query-builder/common/services/query-structure.service.d.ts +1 -0
  160. package/query-builder/query-builder.module.d.ts +7 -3
  161. package/remote-loader/remote-loader.service.d.ts +1 -1
  162. package/rich-html-textarea/rich-html-textarea.component.d.ts +3 -1
  163. package/rich-html-textarea/rich-html-textarea.component.theme.scss +4 -2
  164. package/select-panel/select-panel.component.d.ts +1 -2
  165. package/signature/signature-dialog.component.d.ts +1 -1
  166. package/skeleton-loader/skeleton-loader.component.d.ts +3 -3
  167. package/smart-filters/boolean-filter/boolean-filter.component.d.ts +1 -0
  168. package/smart-filters/common/model/operator.d.ts +1 -0
  169. package/smart-filters/common/model/type.d.ts +1 -1
  170. package/smart-filters/date-filter/date-filter.component.d.ts +1 -0
  171. package/smart-filters/multi-select-filter/multi-select-filter.component.d.ts +1 -0
  172. package/smart-filters/number-filter/number-filter.component.d.ts +1 -0
  173. package/smart-filters/text-filter/text-filter.component.d.ts +1 -0
  174. package/src/assets/i18n/de.ngx-lib.json +4 -1
  175. package/src/assets/i18n/en.ngx-lib.json +7 -1
  176. package/src/core/style/abstracts/mixins.scss +73 -11
  177. package/src/core/style/abstracts/variables.scss +1 -1
  178. package/src/core/style/base/base.scss +5 -3
  179. package/src/core/style/base/typography.scss +2 -1
  180. package/src/core/style/components/button.scss +11 -0
  181. package/src/core/style/components/general.scss +2 -4
  182. package/textbox/textbox.component.d.ts +2 -0
  183. package/theming.scss +5 -1
  184. package/src/assets/images/sail-away.jpg +0 -0
  185. package/src/core/style/abstracts/AbstractsIntro.stories.mdx +0 -7
@@ -6,11 +6,11 @@ import { HttpResponse, HTTP_INTERCEPTORS, HttpHeaders, HttpClientModule } from '
6
6
  import * as i3 from '@angular/forms';
7
7
  import { FormControl, Validators, ReactiveFormsModule, FormBuilder } from '@angular/forms';
8
8
  import { throwError, BehaviorSubject, Subject } from 'rxjs';
9
- import { catchError, filter, distinctUntilChanged, finalize, tap } from 'rxjs/operators';
9
+ import { catchError, debounceTime, filter, distinctUntilChanged, finalize, tap } from 'rxjs/operators';
10
10
  import * as i1 from '@ngx-translate/core';
11
11
  import { TranslateModule } from '@ngx-translate/core';
12
- import * as i1$1 from '@angular/platform-browser';
13
12
  import { coerceNumberProperty, _isNumberValue } from '@angular/cdk/coercion';
13
+ import * as i1$1 from '@angular/platform-browser';
14
14
  import { createCustomElement } from '@angular/elements';
15
15
  import * as i6 from '@angular/router';
16
16
  import { Router } from '@angular/router';
@@ -52,7 +52,7 @@ class PepLoaderService {
52
52
  get onChanged$() {
53
53
  return this.showLoaderSubject
54
54
  .asObservable()
55
- .pipe(filter(v => v !== undefined), distinctUntilChanged());
55
+ .pipe(debounceTime(500), filter(v => v !== undefined), distinctUntilChanged());
56
56
  }
57
57
  showLoaderChanged(show) {
58
58
  const eventData = {
@@ -382,606 +382,614 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImpor
382
382
  }]
383
383
  }], ctorParameters: function () { return [{ type: PepLayoutService }, { type: i0.Renderer2 }, { type: i0.ElementRef }]; } });
384
384
 
385
- class PepCapitalizePipe {
386
- transform(value) {
387
- if (value) {
388
- return value.charAt(0).toUpperCase() + value.slice(1);
385
+ class PepUtilitiesService {
386
+ constructor(translate = null) {
387
+ this.translate = translate;
388
+ this.culture = 'en-US';
389
+ this.culture = this.translate?.getBrowserCultureLang() || 'en-US';
390
+ // try {
391
+ // import(`@angular/common/locales/global/${this.culture}`);
392
+ // } catch {}
393
+ }
394
+ prepareNumberToFormat(value, fallbackValue = 0) {
395
+ // If the decimal separator is ',' change it to '.'
396
+ if (value?.length > 0) {
397
+ // If the decimal separator is ',' change it to '.' for let the formatting works.
398
+ value = this.changeDecimalSeparatorWhenItsComma(value);
399
+ // console.log('coerceNumberProperty after change decimal separator value is', value);
389
400
  }
390
- return value;
401
+ return coerceNumberProperty(value, fallbackValue);
391
402
  }
392
- }
393
- PepCapitalizePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepCapitalizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
394
- PepCapitalizePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepCapitalizePipe, name: "pepCapitalize" });
395
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepCapitalizePipe, decorators: [{
396
- type: Pipe,
397
- args: [{ name: 'pepCapitalize' }]
398
- }] });
399
- class PepEncodePipe {
400
- transform(value) {
401
- if (value) {
402
- const v = btoa(value);
403
- return v;
403
+ // adapted from https://github.com/sindresorhus/parse-ms.
404
+ // moved to internal function because parse-ms is now pure ESM.
405
+ parseMs(milliseconds) {
406
+ if (typeof milliseconds !== 'number') {
407
+ throw new TypeError('Expected a number');
404
408
  }
405
- return value;
409
+ return {
410
+ days: Math.trunc(milliseconds / 86400000),
411
+ hours: Math.trunc(milliseconds / 3600000) % 24,
412
+ minutes: Math.trunc(milliseconds / 60000) % 60,
413
+ seconds: Math.trunc(milliseconds / 1000) % 60,
414
+ milliseconds: Math.trunc(milliseconds) % 1000
415
+ };
406
416
  }
407
- }
408
- PepEncodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEncodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
409
- PepEncodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepEncodePipe, name: "pepEncode" });
410
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEncodePipe, decorators: [{
411
- type: Pipe,
412
- args: [{ name: 'pepEncode' }]
413
- }] });
414
- class PepEscapePipe {
415
- transform(value) {
416
- if (value) {
417
- const v = escape(value);
418
- return v;
417
+ // adapted from https://github.com/rafaelrinaldi/add-zero.
418
+ // moved to internal function b/c addZero is unmaintained (7+ years).
419
+ // stripped out negative sign logic since we're already doing it elsewhere.
420
+ addZero(value, digits = 2) {
421
+ digits = digits || 2;
422
+ let str = value.toString();
423
+ let size = 0;
424
+ size = digits - str.length + 1;
425
+ str = new Array(size).join('0').concat(str);
426
+ return str;
427
+ }
428
+ isCurrencyShouldBeOnRight(currencySymbol) {
429
+ let res = false;
430
+ if (currencySymbol == "€" ||
431
+ currencySymbol == "₪" ||
432
+ currencySymbol == "Ft" ||
433
+ currencySymbol == "Kč" ||
434
+ currencySymbol == "руб" ||
435
+ currencySymbol == "zł" ||
436
+ currencySymbol == "kr.") {
437
+ res = true;
419
438
  }
420
- return value;
439
+ return res;
421
440
  }
422
- }
423
- PepEscapePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEscapePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
424
- PepEscapePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepEscapePipe, name: "pepEscape" });
425
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEscapePipe, decorators: [{
426
- type: Pipe,
427
- args: [{ name: 'pepEscape' }]
428
- }] });
429
- class PepReplaceLineBreaksPipe {
430
- transform(value) {
431
- const newValue = value.replace(/(<br\ ?\/?>)/g, ' ');
432
- return newValue;
441
+ cutValueByFractionDigits(value, maxFractionDigits) {
442
+ let res = value;
443
+ maxFractionDigits = maxFractionDigits || 2;
444
+ const decimalSeparator = this.getDecimalSeparator();
445
+ if (value.includes(decimalSeparator)) {
446
+ const valueArr = value.split(decimalSeparator);
447
+ // if (valueArr[1].length < maxFractionDigits) {
448
+ valueArr[1] = valueArr[1].padEnd(maxFractionDigits, '0');
449
+ // }
450
+ res = `${valueArr[0]}${decimalSeparator}${valueArr[1].slice(0, maxFractionDigits)}`;
451
+ }
452
+ return res;
433
453
  }
434
- }
435
- PepReplaceLineBreaksPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepReplaceLineBreaksPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
436
- PepReplaceLineBreaksPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepReplaceLineBreaksPipe, name: "pepReplaceLineBreaks" });
437
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepReplaceLineBreaksPipe, decorators: [{
438
- type: Pipe,
439
- args: [{ name: 'pepReplaceLineBreaks' }]
440
- }] });
441
- class PepDateFormatterPipe {
442
- transform(value, culture, showTime = false) {
443
- let res = '';
444
- value = new Date(value);
445
- if (value) {
446
- res = value.toLocaleDateString(culture || 'en-US');
447
- if (showTime) {
448
- res +=
449
- ' ' +
450
- value.toLocaleTimeString(culture || 'en-US', {
451
- hour: '2-digit',
452
- minute: '2-digit',
453
- });
454
+ parseDate(dateStr, showTime = false) {
455
+ let retVal = null;
456
+ if (dateStr !== '') {
457
+ retVal = new Date(dateStr);
458
+ // Convert to date with no offset.
459
+ if (!showTime) {
460
+ const index = dateStr.indexOf('T');
461
+ if (index > 0) {
462
+ dateStr = dateStr.substring(0, index);
463
+ }
464
+ const dateText = dateStr.split('-');
465
+ if (dateText.length === 3) {
466
+ const year = Number(dateText[0]);
467
+ const month = Number(dateText[1]) - 1;
468
+ const day = Number(dateText[2]);
469
+ retVal = new Date(year, month, day, 0, retVal.getTimezoneOffset() * -1);
470
+ }
471
+ }
472
+ else {
473
+ retVal = new Date(retVal.getFullYear(), retVal.getMonth(), retVal.getDate(), retVal.getHours(), retVal.getMinutes() + retVal.getTimezoneOffset() * -1, retVal.getSeconds());
454
474
  }
455
475
  }
456
- return res;
476
+ if (retVal && isNaN(retVal.getTime())) {
477
+ retVal = null;
478
+ }
479
+ return retVal;
457
480
  }
458
- }
459
- PepDateFormatterPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateFormatterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
460
- PepDateFormatterPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepDateFormatterPipe, name: "pepDateFormatter" });
461
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateFormatterPipe, decorators: [{
462
- type: Pipe,
463
- args: [{ name: 'pepDateFormatter' }]
464
- }] });
465
- class PepDateStringFormatterPipe {
466
- transform(value, culture, showTime = false) {
467
- let res = '';
468
- const tmpDate = new Date(value);
469
- if (value) {
470
- res = tmpDate.toLocaleDateString(culture || 'en-US');
481
+ stringifyDate(date, showTime = false) {
482
+ if (date) {
471
483
  if (showTime) {
472
- res += ' ' + tmpDate.toLocaleTimeString(culture || 'en-US');
484
+ return date.toISOString(); // include - offset
485
+ }
486
+ else {
487
+ const dateText = [];
488
+ dateText.push(date.getFullYear(), '-', date.getMonth() + 1, '-', date.getDate());
489
+ return dateText.join('');
473
490
  }
474
491
  }
475
- return res;
492
+ else {
493
+ return '';
494
+ }
476
495
  }
477
- }
478
- PepDateStringFormatterPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateStringFormatterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
479
- PepDateStringFormatterPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepDateStringFormatterPipe, name: "pepDateStringFormatter" });
480
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateStringFormatterPipe, decorators: [{
481
- type: Pipe,
482
- args: [{ name: 'pepDateStringFormatter' }]
483
- }] });
484
- class PepSafeHtmlPipe {
485
- constructor(sanitizer) {
486
- this.sanitizer = sanitizer;
496
+ isValueHtml(value) {
497
+ let res = false;
498
+ const REGEXP = /<\/?[a-z][\s\S]*>/i;
499
+ res = REGEXP.test(value);
500
+ return res;
487
501
  }
488
- transform(html) {
489
- return this.sanitizer.bypassSecurityTrustHtml(html);
502
+ isJsonString(str) {
503
+ try {
504
+ JSON.parse(str);
505
+ }
506
+ catch (e) {
507
+ return false;
508
+ }
509
+ return true;
490
510
  }
491
- }
492
- PepSafeHtmlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafeHtmlPipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
493
- PepSafeHtmlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepSafeHtmlPipe, name: "pepSafeHtml" });
494
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafeHtmlPipe, decorators: [{
495
- type: Pipe,
496
- args: [{ name: 'pepSafeHtml' }]
497
- }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
498
- class PepSafePipe {
499
- constructor(sanitizer) {
500
- this.sanitizer = sanitizer;
511
+ getSvgElementFromString(document, svgContent) {
512
+ const div = document.createElement('DIV');
513
+ // div.className = 'svg-icon';
514
+ // Add class svg-icon
515
+ if (svgContent?.length > 0) {
516
+ div.innerHTML = svgContent.replace('<svg ', '<svg class="svg-icon" ');
517
+ }
518
+ return (div.querySelector('svg') ||
519
+ document.createElementNS('http://www.w3.org/2000/svg', 'path'));
501
520
  }
502
- transform(value, type) {
503
- switch (type) {
504
- case 'html':
505
- return this.sanitizer.bypassSecurityTrustHtml(value);
506
- case 'style':
507
- return this.sanitizer.bypassSecurityTrustStyle(value);
508
- case 'script':
509
- return this.sanitizer.bypassSecurityTrustScript(value);
510
- case 'url':
511
- return this.sanitizer.bypassSecurityTrustUrl(value);
512
- case 'resourceUrl':
513
- return this.sanitizer.bypassSecurityTrustResourceUrl(value);
514
- default:
515
- throw new Error(`Invalid safe type specified: ${type}`);
521
+ // formatPercent(value: any, digitsInfo = '1.0-2') {
522
+ formatPercent(value, minFractionDigits = 0, maxFractionDigits = 2) {
523
+ minFractionDigits = coerceNumberProperty(minFractionDigits, null);
524
+ maxFractionDigits = coerceNumberProperty(maxFractionDigits, null);
525
+ value = this.cutValueByFractionDigits(value?.toString(), Math.max(minFractionDigits, maxFractionDigits));
526
+ const number = this.prepareNumberToFormat(value);
527
+ if (number === 0) {
528
+ return '0%';
529
+ }
530
+ else {
531
+ // return formatPercent(number / 100, this.culture, digitsInfo);
532
+ return new Intl.NumberFormat(this.culture, {
533
+ style: 'percent',
534
+ minimumFractionDigits: minFractionDigits || 0,
535
+ maximumFractionDigits: maxFractionDigits || Math.max(2, minFractionDigits),
536
+ }).format(number / 100);
516
537
  }
517
538
  }
518
- }
519
- PepSafePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafePipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
520
- PepSafePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepSafePipe, name: "pepSafe" });
521
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafePipe, decorators: [{
522
- type: Pipe,
523
- args: [{ name: 'pepSafe' }]
524
- }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
525
- class PepSplitUppercasePipe {
526
- transform(value) {
527
- const newValue = value.replace(/([a-z])([A-Z])/g, '$1 $2');
528
- return newValue;
529
- }
530
- }
531
- PepSplitUppercasePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSplitUppercasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
532
- PepSplitUppercasePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepSplitUppercasePipe, name: "pepSplitUppercase" });
533
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSplitUppercasePipe, decorators: [{
534
- type: Pipe,
535
- args: [{ name: 'pepSplitUppercase' }]
536
- }] });
537
- class PepToNumberPipe {
538
- transform(value) {
539
- return parseInt(value);
540
- }
541
- }
542
- PepToNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepToNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
543
- PepToNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepToNumberPipe, name: "pepToNumber" });
544
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepToNumberPipe, decorators: [{
545
- type: Pipe,
546
- args: [{ name: 'pepToNumber' }]
547
- }] });
548
-
549
- class DateAgoPipe {
550
- constructor(translateService) {
551
- this.translateService = translateService;
552
- }
553
- getCounterTranslation(counter, key) {
554
- const intervalText = this.translateService.get(`DATE_AGO.${key.toUpperCase()}`) || key;
555
- const agoText = this.translateService.get(counter === 1 ? 'DATE_AGO.SINGULAR' : 'DATE_AGO.PLURAL') || counter === 1 ? ' ago' : 's ago';
556
- return `${intervalText}${agoText}`;
557
- }
558
- transform(value, args) {
559
- if (value) {
560
- const seconds = Math.floor((+new Date() - +new Date(value)) / 1000);
561
- if (seconds < 29) // less than 30 seconds ago will show as 'Just now'
562
- return this.translateService.get('DATE_AGO.JUST_NOW') || 'Just now';
563
- const intervals = {
564
- 'year': 31536000,
565
- 'month': 2592000,
566
- 'week': 604800,
567
- 'day': 86400,
568
- 'hour': 3600,
569
- 'minute': 60,
570
- 'second': 1
571
- };
572
- let counter;
573
- for (const i in intervals) {
574
- counter = Math.floor(seconds / intervals[i]);
575
- if (counter > 0) {
576
- this.getCounterTranslation(counter, i);
577
- }
578
- }
539
+ // formatCurrency(value: any, currencySign = '', digitsInfo = '1.2-2') {
540
+ formatCurrency(value, currencySign = '', minFractionDigits = 2, maxFractionDigits = 2, useGrouping = true) {
541
+ minFractionDigits = coerceNumberProperty(minFractionDigits, null);
542
+ maxFractionDigits = coerceNumberProperty(maxFractionDigits, null);
543
+ let res = '';
544
+ // If the decimal separator is the last digit
545
+ // if (value.length > 0 && value.indexOf(this.getDecimalSeparator()) === value.length -1) {
546
+ // res = value;
547
+ // } else {
548
+ value = this.cutValueByFractionDigits(value?.toString(), Math.max(minFractionDigits, maxFractionDigits));
549
+ const number = this.prepareNumberToFormat(value);
550
+ const styleOptions = {
551
+ // style: 'currency',
552
+ // currencySign: currencySign,
553
+ useGrouping: useGrouping,
554
+ minimumFractionDigits: minFractionDigits || Math.min(2, maxFractionDigits || 2),
555
+ maximumFractionDigits: maxFractionDigits || Math.max(2, minFractionDigits),
556
+ };
557
+ if (number === 0) {
558
+ // return formatCurrency(0, this.culture, currencySign, undefined, digitsInfo);
559
+ res = new Intl.NumberFormat(this.culture, styleOptions).format(0);
579
560
  }
580
- return value;
581
- }
582
- }
583
- DateAgoPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: DateAgoPipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
584
- DateAgoPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: DateAgoPipe, name: "dateAgo" });
585
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: DateAgoPipe, decorators: [{
586
- type: Pipe,
587
- args: [{
588
- name: 'dateAgo'
589
- }]
590
- }], ctorParameters: function () { return [{ type: i1.TranslateService }]; } });
591
-
592
- class PepInputAutoWidthDirective {
593
- constructor(renderer, el) {
594
- this.renderer = renderer;
595
- this.el = el;
596
- this.includePadding = true;
597
- this.input = null;
561
+ else {
562
+ // return formatCurrency(value, this.culture, currencySign, undefined, digitsInfo);
563
+ res = new Intl.NumberFormat(this.culture, styleOptions).format(number);
564
+ }
565
+ if (currencySign.length > 0) {
566
+ res = this.isCurrencyShouldBeOnRight(currencySign) ? `${res} ${currencySign}` : `${currencySign} ${res}`;
567
+ }
568
+ // }
569
+ return res;
598
570
  }
599
- ngAfterViewInit() {
600
- if (this.el.nativeElement.tagName.toLowerCase() === 'input') {
601
- this.input = this.el;
571
+ // formatDecimal(value: any, digitsInfo = '1.2-2') {
572
+ formatDecimal(value, minFractionDigits = 2, maxFractionDigits = 2, useGrouping = true) {
573
+ minFractionDigits = coerceNumberProperty(minFractionDigits, null);
574
+ // console.log('formatDecimal minFractionDigits value is', minFractionDigits);
575
+ maxFractionDigits = coerceNumberProperty(maxFractionDigits, null);
576
+ // console.log('formatDecimal minFractionDigits value is', maxFractionDigits);
577
+ value = this.cutValueByFractionDigits(value?.toString(), Math.max(minFractionDigits, maxFractionDigits));
578
+ const number = this.prepareNumberToFormat(value);
579
+ // console.log('number value is', number);
580
+ if (number === 0) {
581
+ return '0';
602
582
  }
603
583
  else {
604
- const list = this.el.nativeElement.querySelectorAll('input');
605
- this.input = list.length > 0 ? list[0] : null;
584
+ // return formatNumber(value, this.culture, digitsInfo);
585
+ const res = new Intl.NumberFormat(this.culture, {
586
+ useGrouping: useGrouping,
587
+ minimumFractionDigits: minFractionDigits || Math.min(2, maxFractionDigits || 2),
588
+ maximumFractionDigits: maxFractionDigits || Math.max(2, minFractionDigits),
589
+ }).format(number);
590
+ // console.log('Intl.NumberFormat value is', res);
591
+ return res;
606
592
  }
607
- if (this.input) {
608
- this.input.addEventListener('blur', this.setWidthUsingText.bind(this));
609
- this.input.addEventListener('keyup', this.setWidthUsingText.bind(this));
593
+ }
594
+ // formatNumber(value: any, digitsInfo = '1.0-0'): string {
595
+ formatNumber(value, useGrouping = true) {
596
+ const number = this.prepareNumberToFormat(value);
597
+ if (number === 0) {
598
+ return '0';
599
+ }
600
+ else {
601
+ // return formatNumber(value, this.culture, digitsInfo);
602
+ return new Intl.NumberFormat(this.culture, {
603
+ useGrouping: useGrouping,
604
+ minimumFractionDigits: 0,
605
+ maximumFractionDigits: 0,
606
+ }).format(number);
610
607
  }
611
- this.setWidthUsingText();
612
608
  }
613
- ngOnDestroy() {
614
- this.input.removeEventListener('blur', this.setWidthUsingText.bind(this));
615
- this.input.removeEventListener('keyup', this.setWidthUsingText.bind(this));
609
+ /**
610
+ * Convert a number in milliseconds to a standard duration string.
611
+ * @param {number} value - duration in milliseconds
612
+ * @param {object} options - formatDuration options object
613
+ * @param {boolean} [options.leading=false] - add leading zero
614
+ * @returns string - formatted duration string
615
+ */
616
+ formatDuration(value, options = {}) {
617
+ const isNumber = _isNumberValue(value);
618
+ if (!isNumber) {
619
+ return value;
620
+ }
621
+ else {
622
+ let number = this.prepareNumberToFormat(value);
623
+ const leading = options?.leading || true;
624
+ const duration = options?.duration || 'milliseconds';
625
+ if (duration === 'seconds') {
626
+ number = number * 1000;
627
+ }
628
+ const unsignedMs = number < 0 ? -number : number;
629
+ const sign = number <= -1000 ? '-' : '';
630
+ const t = this.parseMs(unsignedMs);
631
+ const seconds = this.addZero(t.seconds);
632
+ if (t.days) {
633
+ return sign + t.days + ':' + this.addZero(t.hours) + ':' + this.addZero(t.minutes) + ':' + seconds;
634
+ }
635
+ if (t.hours) {
636
+ return sign + (leading ? this.addZero(t.hours) : t.hours) + ':' + this.addZero(t.minutes) + ':' + seconds;
637
+ }
638
+ return sign + (leading ? this.addZero(t.minutes) : t.minutes) + ':' + seconds;
639
+ }
616
640
  }
617
- get paddingWidth() {
618
- return this.includePadding
619
- ? this._sumPropertyValues(['padding-left', 'padding-right'])
620
- : 0;
641
+ incrementNumber(value) {
642
+ let numberValue = coerceNumberProperty(value, 0);
643
+ return (++numberValue).toString();
621
644
  }
622
- get style() {
623
- return getComputedStyle(this.input, '');
645
+ decrementNumber(value) {
646
+ let numberValue = coerceNumberProperty(value, 0);
647
+ return (--numberValue).toString();
624
648
  }
625
- setWidth(width) {
626
- this.renderer.setStyle(this.input, 'width', width + 'px');
649
+ getDecimalSeparator() {
650
+ const numberWithDecimalSeparator = 1.1;
651
+ return numberWithDecimalSeparator
652
+ .toLocaleString(this.culture)
653
+ .substring(1, 2);
627
654
  }
628
- setWidthUsingText() {
629
- if (this.input) {
630
- const text = this.input.value;
631
- this.setWidth(this.textWidth(text) + this.paddingWidth);
655
+ changeDecimalSeparatorWhenItsComma(value, reverse = false) {
656
+ // If the decimal separator is ','
657
+ if (this.getDecimalSeparator() === ',') {
658
+ // In case that the value isn't string.
659
+ value = value?.toString() || '';
660
+ // If reverse change the number from '.' to ',' else do the opposite.
661
+ value = reverse ? value.replace('.', ',') : value.replace(',', '.');
632
662
  }
663
+ return value;
633
664
  }
634
- _sumPropertyValues(properties) {
635
- return properties
636
- .map((property) => parseInt(this.style.getPropertyValue(property), 10))
637
- .reduce((a, b) => a + b, 0);
638
- }
639
- textWidth(value) {
640
- const ctx = this.renderer.createElement('canvas').getContext('2d');
641
- const { fontStyle, fontVariant, fontWeight, fontSize, fontFamily, } = this.style;
642
- // font string format: {normal, normal, 700, 20px, Roboto, "Helvetica Neue", sans-serif}
643
- ctx.font =
644
- fontStyle +
645
- ' ' +
646
- fontVariant +
647
- ' ' +
648
- fontWeight +
649
- ' ' +
650
- fontSize +
651
- ' ' +
652
- fontFamily;
653
- return ctx ? ctx.measureText(value).width : 0;
665
+ isEqualNumber(numberAsString, numberAsString2) {
666
+ const number = this.prepareNumberToFormat(numberAsString);
667
+ const number2 = this.prepareNumberToFormat(numberAsString2);
668
+ return number === number2;
654
669
  }
655
670
  }
656
- PepInputAutoWidthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepInputAutoWidthDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
657
- PepInputAutoWidthDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: PepInputAutoWidthDirective, selector: "[pepAutoWidth]", inputs: { includePadding: "includePadding" }, ngImport: i0 });
658
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepInputAutoWidthDirective, decorators: [{
659
- type: Directive,
671
+ PepUtilitiesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepUtilitiesService, deps: [{ token: i1.TranslateService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
672
+ PepUtilitiesServiceprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepUtilitiesService, providedIn: 'root' });
673
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepUtilitiesService, decorators: [{
674
+ type: Injectable,
660
675
  args: [{
661
- selector: '[pepAutoWidth]',
676
+ providedIn: 'root',
662
677
  }]
663
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { includePadding: [{
664
- type: Input
665
- }] } });
678
+ }], ctorParameters: function () { return [{ type: i1.TranslateService, decorators: [{
679
+ type: Optional
680
+ }] }]; } });
666
681
 
667
- class PepButtonBlurDirective {
668
- constructor(element) {
669
- this.element = element;
670
- }
671
- onClick() {
672
- setTimeout(() => {
673
- this.element.nativeElement.blur();
674
- }, 0);
682
+ class PepCapitalizePipe {
683
+ transform(value) {
684
+ if (value) {
685
+ return value.charAt(0).toUpperCase() + value.slice(1);
686
+ }
687
+ return value;
675
688
  }
676
689
  }
677
- PepButtonBlurDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepButtonBlurDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
678
- PepButtonBlurDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: PepButtonBlurDirective, selector: "[pepButtonBlur]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
679
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepButtonBlurDirective, decorators: [{
680
- type: Directive,
681
- args: [{
682
- selector: '[pepButtonBlur]',
683
- }]
684
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { onClick: [{
685
- type: HostListener,
686
- args: ['click']
687
- }] } });
688
-
689
- class PepUtilitiesService {
690
- constructor(translate = null) {
691
- this.translate = translate;
692
- this.culture = 'en-US';
693
- this.culture = this.translate?.getBrowserCultureLang() || 'en-US';
694
- // try {
695
- // import(`@angular/common/locales/global/${this.culture}`);
696
- // } catch {}
697
- }
698
- prepareNumberToFormat(value, fallbackValue = 0) {
699
- // If the decimal separator is ',' change it to '.'
700
- if (value?.length > 0) {
701
- // If the decimal separator is ',' change it to '.' for let the formatting works.
702
- value = this.changeDecimalSeparatorWhenItsComma(value);
703
- // console.log('coerceNumberProperty after change decimal separator value is', value);
690
+ PepCapitalizePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepCapitalizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
691
+ PepCapitalizePipepipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepCapitalizePipe, name: "pepCapitalize" });
692
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepCapitalizePipe, decorators: [{
693
+ type: Pipe,
694
+ args: [{ name: 'pepCapitalize' }]
695
+ }] });
696
+ class PepEncodePipe {
697
+ transform(value) {
698
+ if (value) {
699
+ const v = btoa(value);
700
+ return v;
704
701
  }
705
- return coerceNumberProperty(value, fallbackValue);
702
+ return value;
706
703
  }
707
- // adapted from https://github.com/sindresorhus/parse-ms.
708
- // moved to internal function because parse-ms is now pure ESM.
709
- parseMs(milliseconds) {
710
- if (typeof milliseconds !== 'number') {
711
- throw new TypeError('Expected a number');
704
+ }
705
+ PepEncodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEncodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
706
+ PepEncodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepEncodePipe, name: "pepEncode" });
707
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEncodePipe, decorators: [{
708
+ type: Pipe,
709
+ args: [{ name: 'pepEncode' }]
710
+ }] });
711
+ class PepEscapePipe {
712
+ transform(value) {
713
+ if (value) {
714
+ const v = escape(value);
715
+ return v;
712
716
  }
713
- return {
714
- days: Math.trunc(milliseconds / 86400000),
715
- hours: Math.trunc(milliseconds / 3600000) % 24,
716
- minutes: Math.trunc(milliseconds / 60000) % 60,
717
- seconds: Math.trunc(milliseconds / 1000) % 60,
718
- milliseconds: Math.trunc(milliseconds) % 1000
719
- };
717
+ return value;
720
718
  }
721
- // adapted from https://github.com/rafaelrinaldi/add-zero.
722
- // moved to internal function b/c addZero is unmaintained (7+ years).
723
- // stripped out negative sign logic since we're already doing it elsewhere.
724
- addZero(value, digits = 2) {
725
- digits = digits || 2;
726
- let str = value.toString();
727
- let size = 0;
728
- size = digits - str.length + 1;
729
- str = new Array(size).join('0').concat(str);
730
- return str;
719
+ }
720
+ PepEscapePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEscapePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
721
+ PepEscapePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepEscapePipe, name: "pepEscape" });
722
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepEscapePipe, decorators: [{
723
+ type: Pipe,
724
+ args: [{ name: 'pepEscape' }]
725
+ }] });
726
+ class PepReplaceLineBreaksPipe {
727
+ transform(value) {
728
+ const newValue = value.replace(/(<br\ ?\/?>)/g, ' ');
729
+ return newValue;
731
730
  }
732
- isCurrencyShouldBeOnRight(currencySymbol) {
733
- let res = false;
734
- if (currencySymbol == "" ||
735
- currencySymbol == "" ||
736
- currencySymbol == "Ft" ||
737
- currencySymbol == "Kč" ||
738
- currencySymbol == "руб" ||
739
- currencySymbol == "zł" ||
740
- currencySymbol == "kr.") {
741
- res = true;
731
+ }
732
+ PepReplaceLineBreaksPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepReplaceLineBreaksPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
733
+ PepReplaceLineBreaksPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepReplaceLineBreaksPipe, name: "pepReplaceLineBreaks" });
734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepReplaceLineBreaksPipe, decorators: [{
735
+ type: Pipe,
736
+ args: [{ name: 'pepReplaceLineBreaks' }]
737
+ }] });
738
+ class PepDateFormatterPipe {
739
+ transform(value, culture, showTime = false) {
740
+ let res = '';
741
+ value = new Date(value);
742
+ if (value) {
743
+ res = value.toLocaleDateString(culture || 'en-US');
744
+ if (showTime) {
745
+ res +=
746
+ ' ' +
747
+ value.toLocaleTimeString(culture || 'en-US', {
748
+ hour: '2-digit',
749
+ minute: '2-digit',
750
+ });
751
+ }
742
752
  }
743
753
  return res;
744
754
  }
745
- cutValueByFractionDigits(value, maxFractionDigits) {
746
- let res = value;
747
- maxFractionDigits = maxFractionDigits || 2;
748
- const decimalSeparator = this.getDecimalSeparator();
749
- if (value.includes(decimalSeparator)) {
750
- const valueArr = value.split(decimalSeparator);
751
- // if (valueArr[1].length < maxFractionDigits) {
752
- valueArr[1] = valueArr[1].padEnd(maxFractionDigits, '0');
753
- // }
754
- res = `${valueArr[0]}${decimalSeparator}${valueArr[1].slice(0, maxFractionDigits)}`;
755
+ }
756
+ PepDateFormatterPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateFormatterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
757
+ PepDateFormatterPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepDateFormatterPipe, name: "pepDateFormatter" });
758
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateFormatterPipe, decorators: [{
759
+ type: Pipe,
760
+ args: [{ name: 'pepDateFormatter' }]
761
+ }] });
762
+ class PepDateStringFormatterPipe {
763
+ transform(value, culture, showTime = false) {
764
+ let res = '';
765
+ const tmpDate = new Date(value);
766
+ if (value) {
767
+ res = tmpDate.toLocaleDateString(culture || 'en-US');
768
+ if (showTime) {
769
+ res += ' ' + tmpDate.toLocaleTimeString(culture || 'en-US');
770
+ }
755
771
  }
756
772
  return res;
757
773
  }
758
- parseDate(dateStr, showTime = false) {
759
- let retVal = null;
760
- if (dateStr !== '') {
761
- retVal = new Date(dateStr);
762
- // Convert to date with no offset.
763
- if (!showTime) {
764
- const index = dateStr.indexOf('T');
765
- if (index > 0) {
766
- dateStr = dateStr.substring(0, index);
767
- }
768
- const dateText = dateStr.split('-');
769
- if (dateText.length === 3) {
770
- const year = Number(dateText[0]);
771
- const month = Number(dateText[1]) - 1;
772
- const day = Number(dateText[2]);
773
- retVal = new Date(year, month, day, 0, retVal.getTimezoneOffset() * -1);
774
- }
775
- }
776
- else {
777
- retVal = new Date(retVal.getFullYear(), retVal.getMonth(), retVal.getDate(), retVal.getHours(), retVal.getMinutes() + retVal.getTimezoneOffset() * -1, retVal.getSeconds());
778
- }
779
- }
780
- if (retVal && isNaN(retVal.getTime())) {
781
- retVal = null;
782
- }
783
- return retVal;
774
+ }
775
+ PepDateStringFormatterPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateStringFormatterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
776
+ PepDateStringFormatterPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepDateStringFormatterPipe, name: "pepDateStringFormatter" });
777
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepDateStringFormatterPipe, decorators: [{
778
+ type: Pipe,
779
+ args: [{ name: 'pepDateStringFormatter' }]
780
+ }] });
781
+ class PepSafeHtmlPipe {
782
+ constructor(sanitizer) {
783
+ this.sanitizer = sanitizer;
784
784
  }
785
- stringifyDate(date, showTime = false) {
786
- if (date) {
787
- if (showTime) {
788
- return date.toISOString(); // include - offset
789
- }
790
- else {
791
- const dateText = [];
792
- dateText.push(date.getFullYear(), '-', date.getMonth() + 1, '-', date.getDate());
793
- return dateText.join('');
794
- }
795
- }
796
- else {
797
- return '';
798
- }
785
+ transform(html) {
786
+ return this.sanitizer.bypassSecurityTrustHtml(html);
799
787
  }
800
- isValueHtml(value) {
801
- let res = false;
802
- const REGEXP = /<\/?[a-z][\s\S]*>/i;
803
- res = REGEXP.test(value);
804
- return res;
788
+ }
789
+ PepSafeHtmlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafeHtmlPipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
790
+ PepSafeHtmlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepSafeHtmlPipe, name: "pepSafeHtml" });
791
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafeHtmlPipe, decorators: [{
792
+ type: Pipe,
793
+ args: [{ name: 'pepSafeHtml' }]
794
+ }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
795
+ class PepSafePipe {
796
+ constructor(sanitizer) {
797
+ this.sanitizer = sanitizer;
805
798
  }
806
- isJsonString(str) {
807
- try {
808
- JSON.parse(str);
809
- }
810
- catch (e) {
811
- return false;
799
+ transform(value, type) {
800
+ switch (type) {
801
+ case 'html':
802
+ return this.sanitizer.bypassSecurityTrustHtml(value);
803
+ case 'style':
804
+ return this.sanitizer.bypassSecurityTrustStyle(value);
805
+ case 'script':
806
+ return this.sanitizer.bypassSecurityTrustScript(value);
807
+ case 'url':
808
+ return this.sanitizer.bypassSecurityTrustUrl(value);
809
+ case 'resourceUrl':
810
+ return this.sanitizer.bypassSecurityTrustResourceUrl(value);
811
+ default:
812
+ throw new Error(`Invalid safe type specified: ${type}`);
812
813
  }
813
- return true;
814
814
  }
815
- getSvgElementFromString(document, svgContent) {
816
- const div = document.createElement('DIV');
817
- // div.className = 'svg-icon';
818
- // Add class svg-icon
819
- if (svgContent?.length > 0) {
820
- div.innerHTML = svgContent.replace('<svg ', '<svg class="svg-icon" ');
821
- }
822
- return (div.querySelector('svg') ||
823
- document.createElementNS('http://www.w3.org/2000/svg', 'path'));
815
+ }
816
+ PepSafePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafePipe, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
817
+ PepSafePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepSafePipe, name: "pepSafe" });
818
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSafePipe, decorators: [{
819
+ type: Pipe,
820
+ args: [{ name: 'pepSafe' }]
821
+ }], ctorParameters: function () { return [{ type: i1$1.DomSanitizer }]; } });
822
+ class PepSplitUppercasePipe {
823
+ transform(value) {
824
+ const newValue = value.replace(/([a-z])([A-Z])/g, '$1 $2');
825
+ return newValue;
826
+ }
827
+ }
828
+ PepSplitUppercasePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSplitUppercasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
829
+ PepSplitUppercasePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepSplitUppercasePipe, name: "pepSplitUppercase" });
830
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepSplitUppercasePipe, decorators: [{
831
+ type: Pipe,
832
+ args: [{ name: 'pepSplitUppercase' }]
833
+ }] });
834
+ class PepToNumberPipe {
835
+ constructor(utilitiesService) {
836
+ this.utilitiesService = utilitiesService;
837
+ }
838
+ transform(value) {
839
+ const decimalSeparator = this.utilitiesService.getDecimalSeparator();
840
+ // We need to remove the thousands separator so - If the decimal separator is '.' we need to remove the ',' from the value else we remove the '.'.
841
+ value = decimalSeparator === '.' ? value.replace(/,/g, '') : value.replace(/./g, '');
842
+ const numberValue = coerceNumberProperty(value);
843
+ return numberValue;
844
+ // return parseInt(value);
845
+ }
846
+ }
847
+ PepToNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepToNumberPipe, deps: [{ token: PepUtilitiesService }], target: i0.ɵɵFactoryTarget.Pipe });
848
+ PepToNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: PepToNumberPipe, name: "pepToNumber" });
849
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepToNumberPipe, decorators: [{
850
+ type: Pipe,
851
+ args: [{ name: 'pepToNumber' }]
852
+ }], ctorParameters: function () { return [{ type: PepUtilitiesService }]; } });
853
+
854
+ class DateAgoPipe {
855
+ constructor(translateService) {
856
+ this.translateService = translateService;
857
+ }
858
+ getCounterTranslation(counter, key) {
859
+ const intervalText = this.translateService.get(`DATE_AGO.${key.toUpperCase()}`) || key;
860
+ const agoText = this.translateService.get(counter === 1 ? 'DATE_AGO.SINGULAR' : 'DATE_AGO.PLURAL') || counter === 1 ? ' ago' : 's ago';
861
+ return `${intervalText}${agoText}`;
824
862
  }
825
- // formatPercent(value: any, digitsInfo = '1.0-2') {
826
- formatPercent(value, minFractionDigits = 0, maxFractionDigits = 2) {
827
- minFractionDigits = coerceNumberProperty(minFractionDigits, null);
828
- maxFractionDigits = coerceNumberProperty(maxFractionDigits, null);
829
- value = this.cutValueByFractionDigits(value?.toString(), Math.max(minFractionDigits, maxFractionDigits));
830
- const number = this.prepareNumberToFormat(value);
831
- if (number === 0) {
832
- return '0%';
833
- }
834
- else {
835
- // return formatPercent(number / 100, this.culture, digitsInfo);
836
- return new Intl.NumberFormat(this.culture, {
837
- style: 'percent',
838
- minimumFractionDigits: minFractionDigits || 0,
839
- maximumFractionDigits: maxFractionDigits || Math.max(2, minFractionDigits),
840
- }).format(number / 100);
863
+ transform(value, args) {
864
+ if (value) {
865
+ const seconds = Math.floor((+new Date() - +new Date(value)) / 1000);
866
+ if (seconds < 29) // less than 30 seconds ago will show as 'Just now'
867
+ return this.translateService.get('DATE_AGO.JUST_NOW') || 'Just now';
868
+ const intervals = {
869
+ 'year': 31536000,
870
+ 'month': 2592000,
871
+ 'week': 604800,
872
+ 'day': 86400,
873
+ 'hour': 3600,
874
+ 'minute': 60,
875
+ 'second': 1
876
+ };
877
+ let counter;
878
+ for (const i in intervals) {
879
+ counter = Math.floor(seconds / intervals[i]);
880
+ if (counter > 0) {
881
+ this.getCounterTranslation(counter, i);
882
+ }
883
+ }
841
884
  }
885
+ return value;
842
886
  }
843
- // formatCurrency(value: any, currencySign = '', digitsInfo = '1.2-2') {
844
- formatCurrency(value, currencySign = '', minFractionDigits = 2, maxFractionDigits = 2, useGrouping = true) {
845
- minFractionDigits = coerceNumberProperty(minFractionDigits, null);
846
- maxFractionDigits = coerceNumberProperty(maxFractionDigits, null);
847
- let res = '';
848
- // If the decimal separator is the last digit
849
- // if (value.length > 0 && value.indexOf(this.getDecimalSeparator()) === value.length -1) {
850
- // res = value;
851
- // } else {
852
- value = this.cutValueByFractionDigits(value?.toString(), Math.max(minFractionDigits, maxFractionDigits));
853
- const number = this.prepareNumberToFormat(value);
854
- const styleOptions = {
855
- // style: 'currency',
856
- // currencySign: currencySign,
857
- useGrouping: useGrouping,
858
- minimumFractionDigits: minFractionDigits || Math.min(2, maxFractionDigits || 2),
859
- maximumFractionDigits: maxFractionDigits || Math.max(2, minFractionDigits),
860
- };
861
- if (number === 0) {
862
- // return formatCurrency(0, this.culture, currencySign, undefined, digitsInfo);
863
- res = new Intl.NumberFormat(this.culture, styleOptions).format(0);
864
- }
865
- else {
866
- // return formatCurrency(value, this.culture, currencySign, undefined, digitsInfo);
867
- res = new Intl.NumberFormat(this.culture, styleOptions).format(number);
868
- }
869
- if (currencySign.length > 0) {
870
- res = this.isCurrencyShouldBeOnRight(currencySign) ? `${res} ${currencySign}` : `${currencySign} ${res}`;
871
- }
872
- // }
873
- return res;
887
+ }
888
+ DateAgoPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: DateAgoPipe, deps: [{ token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Pipe });
889
+ DateAgoPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.0.2", ngImport: i0, type: DateAgoPipe, name: "dateAgo" });
890
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: DateAgoPipe, decorators: [{
891
+ type: Pipe,
892
+ args: [{
893
+ name: 'dateAgo'
894
+ }]
895
+ }], ctorParameters: function () { return [{ type: i1.TranslateService }]; } });
896
+
897
+ class PepInputAutoWidthDirective {
898
+ constructor(renderer, el) {
899
+ this.renderer = renderer;
900
+ this.el = el;
901
+ this.includePadding = true;
902
+ this.input = null;
874
903
  }
875
- // formatDecimal(value: any, digitsInfo = '1.2-2') {
876
- formatDecimal(value, minFractionDigits = 2, maxFractionDigits = 2, useGrouping = true) {
877
- minFractionDigits = coerceNumberProperty(minFractionDigits, null);
878
- // console.log('formatDecimal minFractionDigits value is', minFractionDigits);
879
- maxFractionDigits = coerceNumberProperty(maxFractionDigits, null);
880
- // console.log('formatDecimal minFractionDigits value is', maxFractionDigits);
881
- value = this.cutValueByFractionDigits(value?.toString(), Math.max(minFractionDigits, maxFractionDigits));
882
- const number = this.prepareNumberToFormat(value);
883
- // console.log('number value is', number);
884
- if (number === 0) {
885
- return '0';
904
+ ngAfterViewInit() {
905
+ if (this.el.nativeElement.tagName.toLowerCase() === 'input') {
906
+ this.input = this.el;
886
907
  }
887
908
  else {
888
- // return formatNumber(value, this.culture, digitsInfo);
889
- const res = new Intl.NumberFormat(this.culture, {
890
- useGrouping: useGrouping,
891
- minimumFractionDigits: minFractionDigits || Math.min(2, maxFractionDigits || 2),
892
- maximumFractionDigits: maxFractionDigits || Math.max(2, minFractionDigits),
893
- }).format(number);
894
- // console.log('Intl.NumberFormat value is', res);
895
- return res;
896
- }
897
- }
898
- // formatNumber(value: any, digitsInfo = '1.0-0'): string {
899
- formatNumber(value, useGrouping = true) {
900
- const number = this.prepareNumberToFormat(value);
901
- if (number === 0) {
902
- return '0';
909
+ const list = this.el.nativeElement.querySelectorAll('input');
910
+ this.input = list.length > 0 ? list[0] : null;
903
911
  }
904
- else {
905
- // return formatNumber(value, this.culture, digitsInfo);
906
- return new Intl.NumberFormat(this.culture, {
907
- useGrouping: useGrouping,
908
- minimumFractionDigits: 0,
909
- maximumFractionDigits: 0,
910
- }).format(number);
912
+ if (this.input) {
913
+ this.input.addEventListener('blur', this.setWidthUsingText.bind(this));
914
+ this.input.addEventListener('keyup', this.setWidthUsingText.bind(this));
911
915
  }
916
+ this.setWidthUsingText();
912
917
  }
913
- /**
914
- * Convert a number in milliseconds to a standard duration string.
915
- * @param {number} value - duration in milliseconds
916
- * @param {object} options - formatDuration options object
917
- * @param {boolean} [options.leading=false] - add leading zero
918
- * @returns string - formatted duration string
919
- */
920
- formatDuration(value, options = {}) {
921
- const isNumber = _isNumberValue(value);
922
- if (!isNumber) {
923
- return value;
924
- }
925
- else {
926
- let number = this.prepareNumberToFormat(value);
927
- const leading = options?.leading || true;
928
- const duration = options?.duration || 'milliseconds';
929
- if (duration === 'seconds') {
930
- number = number * 1000;
931
- }
932
- const unsignedMs = number < 0 ? -number : number;
933
- const sign = number <= -1000 ? '-' : '';
934
- const t = this.parseMs(unsignedMs);
935
- const seconds = this.addZero(t.seconds);
936
- if (t.days) {
937
- return sign + t.days + ':' + this.addZero(t.hours) + ':' + this.addZero(t.minutes) + ':' + seconds;
938
- }
939
- if (t.hours) {
940
- return sign + (leading ? this.addZero(t.hours) : t.hours) + ':' + this.addZero(t.minutes) + ':' + seconds;
941
- }
942
- return sign + (leading ? this.addZero(t.minutes) : t.minutes) + ':' + seconds;
943
- }
918
+ ngOnDestroy() {
919
+ this.input.removeEventListener('blur', this.setWidthUsingText.bind(this));
920
+ this.input.removeEventListener('keyup', this.setWidthUsingText.bind(this));
944
921
  }
945
- incrementNumber(value) {
946
- let numberValue = coerceNumberProperty(value, 0);
947
- return (++numberValue).toString();
922
+ get paddingWidth() {
923
+ return this.includePadding
924
+ ? this._sumPropertyValues(['padding-left', 'padding-right'])
925
+ : 0;
948
926
  }
949
- decrementNumber(value) {
950
- let numberValue = coerceNumberProperty(value, 0);
951
- return (--numberValue).toString();
927
+ get style() {
928
+ return getComputedStyle(this.input, '');
952
929
  }
953
- getDecimalSeparator() {
954
- const numberWithDecimalSeparator = 1.1;
955
- return numberWithDecimalSeparator
956
- .toLocaleString(this.culture)
957
- .substring(1, 2);
930
+ setWidth(width) {
931
+ this.renderer.setStyle(this.input, 'width', width + 'px');
958
932
  }
959
- changeDecimalSeparatorWhenItsComma(value, reverse = false) {
960
- // If the decimal separator is ','
961
- if (this.getDecimalSeparator() === ',') {
962
- // In case that the value isn't string.
963
- value = value?.toString() || '';
964
- // If reverse change the number from '.' to ',' else do the opposite.
965
- value = reverse ? value.replace('.', ',') : value.replace(',', '.');
933
+ setWidthUsingText() {
934
+ if (this.input) {
935
+ const text = this.input.value;
936
+ this.setWidth(this.textWidth(text) + this.paddingWidth);
966
937
  }
967
- return value;
968
938
  }
969
- isEqualNumber(numberAsString, numberAsString2) {
970
- const number = this.prepareNumberToFormat(numberAsString);
971
- const number2 = this.prepareNumberToFormat(numberAsString2);
972
- return number === number2;
939
+ _sumPropertyValues(properties) {
940
+ return properties
941
+ .map((property) => parseInt(this.style.getPropertyValue(property), 10))
942
+ .reduce((a, b) => a + b, 0);
943
+ }
944
+ textWidth(value) {
945
+ const ctx = this.renderer.createElement('canvas').getContext('2d');
946
+ const { fontStyle, fontVariant, fontWeight, fontSize, fontFamily, } = this.style;
947
+ // font string format: {normal, normal, 700, 20px, Roboto, "Helvetica Neue", sans-serif}
948
+ ctx.font =
949
+ fontStyle +
950
+ ' ' +
951
+ fontVariant +
952
+ ' ' +
953
+ fontWeight +
954
+ ' ' +
955
+ fontSize +
956
+ ' ' +
957
+ fontFamily;
958
+ return ctx ? ctx.measureText(value).width : 0;
973
959
  }
974
960
  }
975
- PepUtilitiesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepUtilitiesService, deps: [{ token: i1.TranslateService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
976
- PepUtilitiesServiceprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepUtilitiesService, providedIn: 'root' });
977
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepUtilitiesService, decorators: [{
978
- type: Injectable,
961
+ PepInputAutoWidthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepInputAutoWidthDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
962
+ PepInputAutoWidthDirectivedir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: PepInputAutoWidthDirective, selector: "[pepAutoWidth]", inputs: { includePadding: "includePadding" }, ngImport: i0 });
963
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepInputAutoWidthDirective, decorators: [{
964
+ type: Directive,
979
965
  args: [{
980
- providedIn: 'root',
966
+ selector: '[pepAutoWidth]',
981
967
  }]
982
- }], ctorParameters: function () { return [{ type: i1.TranslateService, decorators: [{
983
- type: Optional
984
- }] }]; } });
968
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { includePadding: [{
969
+ type: Input
970
+ }] } });
971
+
972
+ class PepButtonBlurDirective {
973
+ constructor(element) {
974
+ this.element = element;
975
+ }
976
+ onClick() {
977
+ setTimeout(() => {
978
+ this.element.nativeElement.blur();
979
+ }, 0);
980
+ }
981
+ }
982
+ PepButtonBlurDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepButtonBlurDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
983
+ PepButtonBlurDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: PepButtonBlurDirective, selector: "[pepButtonBlur]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
984
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: PepButtonBlurDirective, decorators: [{
985
+ type: Directive,
986
+ args: [{
987
+ selector: '[pepButtonBlur]',
988
+ }]
989
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { onClick: [{
990
+ type: HostListener,
991
+ args: ['click']
992
+ }] } });
985
993
 
986
994
  class PepButtonLoaderDirective {
987
995
  constructor(renderer, element, utilitiesService, document) {
@@ -1806,6 +1814,7 @@ class PepCustomizationService {
1806
1814
  field.disabled ? formControl.disable() : formControl.enable();
1807
1815
  const validators = field.getValidators();
1808
1816
  formControl.setValidators(validators);
1817
+ formControl.updateValueAndValidity();
1809
1818
  }
1810
1819
  }
1811
1820
  }
@@ -4318,6 +4327,12 @@ class PepFieldBase {
4318
4327
  if (this.maxFieldCharacters > 0) {
4319
4328
  validators.push(Validators.maxLength(this.maxFieldCharacters));
4320
4329
  }
4330
+ if (this.minValue) {
4331
+ validators.push(Validators.min(this.minValue));
4332
+ }
4333
+ if (this.maxValue) {
4334
+ validators.push(Validators.max(this.maxValue));
4335
+ }
4321
4336
  return validators;
4322
4337
  }
4323
4338
  getValidators() {