@po-ui/ng-components 5.14.0 → 5.18.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 (69) hide show
  1. package/bundles/po-ui-ng-components.umd.js +1017 -561
  2. package/bundles/po-ui-ng-components.umd.js.map +1 -1
  3. package/esm2015/lib/components/po-avatar/po-avatar-base.component.js +16 -1
  4. package/esm2015/lib/components/po-avatar/po-avatar.component.js +2 -2
  5. package/esm2015/lib/components/po-dynamic/po-dynamic-form/po-dynamic-form-field.interface.js +1 -1
  6. package/esm2015/lib/components/po-dynamic/po-dynamic-form/po-dynamic-form-fields/po-dynamic-form-fields-base.component.js +2 -2
  7. package/esm2015/lib/components/po-dynamic/po-dynamic-form/po-dynamic-form-fields/po-dynamic-form-fields.component.js +2 -2
  8. package/esm2015/lib/components/po-field/po-datepicker/po-datepicker.component.js +2 -1
  9. package/esm2015/lib/components/po-field/po-datepicker-range/interfaces/po-datepicker-range-literals.interface.js +1 -1
  10. package/esm2015/lib/components/po-field/po-datepicker-range/po-datepicker-range-base.component.js +103 -6
  11. package/esm2015/lib/components/po-field/po-datepicker-range/po-datepicker-range.component.js +8 -3
  12. package/esm2015/lib/components/po-field/po-datepicker-range/po-datepicker-range.literals.js +13 -5
  13. package/esm2015/lib/components/po-field/po-email/po-email.component.js +7 -5
  14. package/esm2015/lib/components/po-field/po-field.model.js +75 -0
  15. package/esm2015/lib/components/po-field/po-login/po-login.component.js +7 -5
  16. package/esm2015/lib/components/po-field/po-lookup/interfaces/po-lookup-filter.interface.js +1 -1
  17. package/esm2015/lib/components/po-field/po-lookup/po-lookup-base.component.js +89 -26
  18. package/esm2015/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal-base.component.js +40 -10
  19. package/esm2015/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.js +45 -7
  20. package/esm2015/lib/components/po-field/po-lookup/po-lookup.component.js +136 -13
  21. package/esm2015/lib/components/po-field/po-lookup/services/po-lookup-filter.service.js +19 -4
  22. package/esm2015/lib/components/po-field/po-lookup/services/po-lookup-modal.service.js +9 -2
  23. package/esm2015/lib/components/po-field/po-password/po-password.component.js +7 -5
  24. package/esm2015/lib/components/po-field/po-switch/po-switch.component.js +85 -9
  25. package/esm2015/lib/components/po-field/po-url/po-url.component.js +7 -5
  26. package/esm2015/lib/components/po-page/po-page-header/po-page-header.component.js +2 -2
  27. package/esm2015/lib/components/po-stepper/po-stepper-circle/po-stepper-circle.component.js +2 -2
  28. package/esm2015/lib/components/po-stepper/po-stepper-step/po-stepper-step.component.js +5 -4
  29. package/esm2015/lib/components/po-stepper/po-stepper.component.js +15 -14
  30. package/esm2015/lib/components/po-table/po-table-base.component.js +2 -2
  31. package/esm2015/lib/components/po-table/po-table-column-label/po-table-column-label.interface.js +1 -1
  32. package/esm2015/lib/components/po-table/po-table.component.js +41 -1
  33. package/esm2015/po-ui-ng-components.js +2 -2
  34. package/fesm2015/po-ui-ng-components.js +955 -512
  35. package/fesm2015/po-ui-ng-components.js.map +1 -1
  36. package/lib/components/po-avatar/po-avatar-base.component.d.ts +14 -0
  37. package/lib/components/po-dynamic/po-dynamic-form/po-dynamic-form-field.interface.d.ts +6 -0
  38. package/lib/components/po-field/po-datepicker-range/interfaces/po-datepicker-range-literals.interface.d.ts +4 -0
  39. package/lib/components/po-field/po-datepicker-range/po-datepicker-range-base.component.d.ts +26 -3
  40. package/lib/components/po-field/po-datepicker-range/po-datepicker-range.component.d.ts +3 -2
  41. package/lib/components/po-field/po-email/po-email.component.d.ts +2 -2
  42. package/lib/components/po-field/po-field.model.d.ts +50 -0
  43. package/lib/components/po-field/po-login/po-login.component.d.ts +2 -2
  44. package/lib/components/po-field/po-lookup/interfaces/po-lookup-filter.interface.d.ts +5 -2
  45. package/lib/components/po-field/po-lookup/po-lookup-base.component.d.ts +53 -7
  46. package/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal-base.component.d.ts +22 -2
  47. package/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.d.ts +10 -3
  48. package/lib/components/po-field/po-lookup/po-lookup.component.d.ts +25 -2
  49. package/lib/components/po-field/po-lookup/services/po-lookup-filter.service.d.ts +6 -2
  50. package/lib/components/po-field/po-lookup/services/po-lookup-modal.service.d.ts +7 -0
  51. package/lib/components/po-field/po-password/po-password.component.d.ts +2 -2
  52. package/lib/components/po-field/po-switch/po-switch.component.d.ts +49 -3
  53. package/lib/components/po-field/po-url/po-url.component.d.ts +2 -2
  54. package/lib/components/po-stepper/po-stepper-step/po-stepper-step.component.d.ts +1 -0
  55. package/lib/components/po-stepper/po-stepper.component.d.ts +6 -2
  56. package/lib/components/po-table/po-table-column-label/po-table-column-label.interface.d.ts +1 -1
  57. package/lib/components/po-table/po-table.component.d.ts +13 -0
  58. package/package.json +4 -4
  59. package/po-ui-ng-components-5.18.0.tgz +0 -0
  60. package/po-ui-ng-components.d.ts +1 -1
  61. package/po-ui-ng-components.metadata.json +1 -1
  62. package/schematics/ng-add/index.js +1 -1
  63. package/schematics/ng-update/v2/index.js +1 -1
  64. package/schematics/ng-update/v3/index.js +1 -1
  65. package/schematics/ng-update/v4/index.js +1 -1
  66. package/schematics/ng-update/v5/index.js +1 -1
  67. package/esm2015/lib/components/po-field/po-switch/po-switch-base.component.js +0 -158
  68. package/lib/components/po-field/po-switch/po-switch-base.component.d.ts +0 -100
  69. package/po-ui-ng-components-5.14.0.tgz +0 -0
@@ -646,6 +646,20 @@
646
646
  */
647
647
  var PoAvatarBaseComponent = /** @class */ (function () {
648
648
  function PoAvatarBaseComponent() {
649
+ /**
650
+ * @optional
651
+ *
652
+ * @description
653
+ *
654
+ * Indica como o navegador deve carregar a imagem.
655
+ *
656
+ * Valores válidos:
657
+ * - `eager` (a imagem é carregada imediatamente, independente de estar visível ou não)
658
+ * - `lazy` (a imagem só é carregada quando estiver próxima de ser renderizada)
659
+ *
660
+ * @default `eager`
661
+ */
662
+ this.loading = 'eager';
649
663
  /** Evento disparado ao clicar na imagem do *avatar*. */
650
664
  this.click = new i0.EventEmitter();
651
665
  this._size = 'md';
@@ -690,6 +704,7 @@
690
704
  ];
691
705
  PoAvatarBaseComponent.propDecorators = {
692
706
  src: [{ type: i0.Input, args: ['p-src',] }],
707
+ loading: [{ type: i0.Input, args: ['p-loading',] }],
693
708
  click: [{ type: i0.Output, args: ['p-click',] }],
694
709
  size: [{ type: i0.Input, args: ['p-size',] }]
695
710
  };
@@ -734,7 +749,7 @@
734
749
  PoAvatarComponent.decorators = [
735
750
  { type: i0.Component, args: [{
736
751
  selector: 'po-avatar',
737
- template: "<div class=\"po-avatar po-avatar-{{ size }}\" [class.po-clickable]=\"hasClickEvent\" (click)=\"click.emit()\">\n <ng-container *ngIf=\"src; then sourceImage; else defaultIcon\"></ng-container>\n</div>\n\n<ng-template #sourceImage>\n <img class=\"po-avatar-image\" [src]=\"src\" alt=\"\" (error)=\"onError()\" />\n</ng-template>\n\n<ng-template #defaultIcon>\n <span class=\"po-icon po-icon-user po-avatar-default-icon\"></span>\n</ng-template>\n",
752
+ template: "<div class=\"po-avatar po-avatar-{{ size }}\" [class.po-clickable]=\"hasClickEvent\" (click)=\"click.emit()\">\n <ng-container *ngIf=\"src; then sourceImage; else defaultIcon\"></ng-container>\n</div>\n\n<ng-template #sourceImage>\n <img class=\"po-avatar-image\" [src]=\"src\" alt=\"\" [attr.loading]=\"loading\" (error)=\"onError()\" />\n</ng-template>\n\n<ng-template #defaultIcon>\n <span class=\"po-icon po-icon-user po-avatar-default-icon\"></span>\n</ng-template>\n",
738
753
  changeDetection: i0.ChangeDetectionStrategy.OnPush
739
754
  },] }
740
755
  ];
@@ -10962,6 +10977,7 @@
10962
10977
  else if (this.inputEl) {
10963
10978
  this.inputEl.nativeElement.value = '';
10964
10979
  this.date = undefined;
10980
+ this.callOnChange(this.date, false);
10965
10981
  }
10966
10982
  this.valueBeforeChange = this.formatToDate(this.date);
10967
10983
  };
@@ -13719,7 +13735,7 @@
13719
13735
  this.items.forEach(function (item) {
13720
13736
  item.$selected = _this.selectAll;
13721
13737
  });
13722
- this.emitSelectAllEvents(this.selectAll, this.items);
13738
+ this.emitSelectAllEvents(this.selectAll, __spreadArray([], __read(this.items)));
13723
13739
  }
13724
13740
  };
13725
13741
  PoTableBaseComponent.prototype.selectRow = function (row) {
@@ -14607,6 +14623,30 @@
14607
14623
  this.toggleRowAction(row);
14608
14624
  }
14609
14625
  };
14626
+ /**
14627
+ * Desmarca uma linha que está selecionada.
14628
+ */
14629
+ PoTableComponent.prototype.unselectRowItem = function (itemfn) {
14630
+ this.toggleSelect(itemfn, false);
14631
+ if (this.items.every(function (item) { return !item.$selected; })) {
14632
+ this.selectAll = false;
14633
+ }
14634
+ else {
14635
+ this.selectAll = null;
14636
+ }
14637
+ };
14638
+ /**
14639
+ * Seleciona uma linha do 'po-table'.
14640
+ */
14641
+ PoTableComponent.prototype.selectRowItem = function (itemfn) {
14642
+ this.toggleSelect(itemfn, true);
14643
+ if (this.items.every(function (item) { return item.$selected; })) {
14644
+ this.selectAll = true;
14645
+ }
14646
+ else {
14647
+ this.selectAll = null;
14648
+ }
14649
+ };
14610
14650
  PoTableComponent.prototype.formatNumber = function (value, format) {
14611
14651
  if (!format) {
14612
14652
  return value;
@@ -14845,6 +14885,22 @@
14845
14885
  this.calculateHeightTableContainer(this.height);
14846
14886
  }
14847
14887
  };
14888
+ PoTableComponent.prototype.toggleSelect = function (compare, selectValue) {
14889
+ if (typeof compare !== 'function') {
14890
+ this.items.forEach(function (item) {
14891
+ if (item === compare) {
14892
+ item.$selected = selectValue;
14893
+ }
14894
+ });
14895
+ }
14896
+ else {
14897
+ this.items.forEach(function (item) {
14898
+ if (compare(item)) {
14899
+ item.$selected = selectValue;
14900
+ }
14901
+ });
14902
+ }
14903
+ };
14848
14904
  return PoTableComponent;
14849
14905
  }(PoTableBaseComponent));
14850
14906
  PoTableComponent.decorators = [
@@ -16966,19 +17022,27 @@
16966
17022
  var poDatepickerRangeLiteralsDefault = {
16967
17023
  en: {
16968
17024
  invalidFormat: 'Date in invalid format',
16969
- startDateGreaterThanEndDate: 'Start date greater than end date'
17025
+ startDateGreaterThanEndDate: 'Start date greater than end date',
17026
+ invalidDate: 'Invalid date',
17027
+ dateOutOfPeriod: 'Date out of period'
16970
17028
  },
16971
17029
  es: {
16972
17030
  invalidFormat: 'Fecha en formato no válido',
16973
- startDateGreaterThanEndDate: 'Fecha de inicio mayor que fecha final'
17031
+ startDateGreaterThanEndDate: 'Fecha de inicio mayor que fecha final',
17032
+ invalidDate: 'Fecha invalida',
17033
+ dateOutOfPeriod: 'Fecha fuera de período'
16974
17034
  },
16975
17035
  pt: {
16976
17036
  invalidFormat: 'Data no formato inválido',
16977
- startDateGreaterThanEndDate: 'Data inicial maior que data final'
17037
+ startDateGreaterThanEndDate: 'Data inicial maior que data final',
17038
+ invalidDate: 'Data inválida',
17039
+ dateOutOfPeriod: 'Data fora do período'
16978
17040
  },
16979
17041
  ru: {
16980
17042
  invalidFormat: 'Дата в неверном формате',
16981
- startDateGreaterThanEndDate: 'Дата начала больше даты окончания'
17043
+ startDateGreaterThanEndDate: 'Дата начала больше даты окончания',
17044
+ invalidDate: 'Недействительная дата',
17045
+ dateOutOfPeriod: 'дата вне периода'
16982
17046
  }
16983
17047
  };
16984
17048
 
@@ -17173,6 +17237,56 @@
17173
17237
  enumerable: false,
17174
17238
  configurable: true
17175
17239
  });
17240
+ Object.defineProperty(PoDatepickerRangeBaseComponent.prototype, "minDate", {
17241
+ get: function () {
17242
+ return this._minDate;
17243
+ },
17244
+ /**
17245
+ * @optional
17246
+ *
17247
+ * @description
17248
+ *
17249
+ * Define uma data mínima para o `po-datepicker-range`.
17250
+ */
17251
+ set: function (value) {
17252
+ if (value instanceof Date) {
17253
+ var year = value.getFullYear();
17254
+ var date = new Date(year, value.getMonth(), value.getDate(), 0, 0, 0);
17255
+ setYearFrom0To100(date, year);
17256
+ this._minDate = date;
17257
+ }
17258
+ else {
17259
+ this._minDate = convertIsoToDate(value, true, false);
17260
+ }
17261
+ },
17262
+ enumerable: false,
17263
+ configurable: true
17264
+ });
17265
+ Object.defineProperty(PoDatepickerRangeBaseComponent.prototype, "maxDate", {
17266
+ get: function () {
17267
+ return this._maxDate;
17268
+ },
17269
+ /**
17270
+ * @optional
17271
+ *
17272
+ * @description
17273
+ *
17274
+ * Define uma data máxima para o `po-datepicker-range`.
17275
+ */
17276
+ set: function (value) {
17277
+ if (value instanceof Date) {
17278
+ var year = value.getFullYear();
17279
+ var date = new Date(year, value.getMonth(), value.getDate(), 23, 59, 59);
17280
+ setYearFrom0To100(date, year);
17281
+ this._maxDate = date;
17282
+ }
17283
+ else {
17284
+ this._maxDate = convertIsoToDate(value, false, true);
17285
+ }
17286
+ },
17287
+ enumerable: false,
17288
+ configurable: true
17289
+ });
17176
17290
  Object.defineProperty(PoDatepickerRangeBaseComponent.prototype, "noAutocomplete", {
17177
17291
  get: function () {
17178
17292
  return this._noAutocomplete;
@@ -17282,6 +17396,14 @@
17282
17396
  }
17283
17397
  };
17284
17398
  }
17399
+ if (!this.verifyValidDate(startDate, endDate)) {
17400
+ this.errorMessage = this.literals.invalidDate;
17401
+ return {
17402
+ date: {
17403
+ valid: false
17404
+ }
17405
+ };
17406
+ }
17285
17407
  if (this.dateRangeObjectFailed(control.value) || this.dateRangeFormatFailed(startDate, endDate)) {
17286
17408
  this.errorMessage = this.literals.invalidFormat;
17287
17409
  return {
@@ -17298,8 +17420,19 @@
17298
17420
  }
17299
17421
  };
17300
17422
  }
17423
+ if ((startDate && !this.validateDateInRange(startDate)) || (endDate && !this.validateDateInRange(endDate))) {
17424
+ this.errorMessage = this.literals.dateOutOfPeriod;
17425
+ return {
17426
+ date: {
17427
+ valid: false
17428
+ }
17429
+ };
17430
+ }
17301
17431
  return null;
17302
17432
  };
17433
+ PoDatepickerRangeBaseComponent.prototype.validateDateInRange = function (startDate) {
17434
+ return validateDateRange(convertIsoToDate(startDate, false, false), this._minDate, this._maxDate);
17435
+ };
17303
17436
  PoDatepickerRangeBaseComponent.prototype.writeValue = function (dateRange) {
17304
17437
  this.resetDateRangeInputValidation();
17305
17438
  if (!dateRange || this.dateRangeObjectFailed(dateRange)) {
@@ -17337,6 +17470,17 @@
17337
17470
  this.validatorChange(model);
17338
17471
  }
17339
17472
  };
17473
+ PoDatepickerRangeBaseComponent.prototype.verifyValidDate = function (startDate, endDate) {
17474
+ if (startDate !== '' && endDate !== '') {
17475
+ return this.dateIsValid(startDate) && this.dateIsValid(endDate);
17476
+ }
17477
+ else if (startDate !== '') {
17478
+ return this.dateIsValid(startDate);
17479
+ }
17480
+ else {
17481
+ return this.dateIsValid(endDate);
17482
+ }
17483
+ };
17340
17484
  PoDatepickerRangeBaseComponent.prototype.convertPatternDateFormat = function (value) {
17341
17485
  if (value instanceof Date) {
17342
17486
  return this.poDateService.convertDateToISO(value);
@@ -17360,6 +17504,29 @@
17360
17504
  requiredFailed(this.required, this.disabled, startDate) &&
17361
17505
  requiredFailed(this.required, this.disabled, endDate));
17362
17506
  };
17507
+ PoDatepickerRangeBaseComponent.prototype.dateIsValid = function (date) {
17508
+ var _a = __read(date.split('-'), 3), strYear = _a[0], strMonth = _a[1], strDay = _a[2];
17509
+ var year = Number(strYear);
17510
+ var month = Number(strMonth);
17511
+ var day = Number(strDay);
17512
+ //verificação dos meses com 31 dias
17513
+ if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) {
17514
+ return day < 1 || day > 31 ? false : true;
17515
+ }
17516
+ else if (month === 4 || month === 6 || month === 9 || month === 11) {
17517
+ //verificação dos meses com 30 dias
17518
+ return day < 1 || day > 30 ? false : true;
17519
+ }
17520
+ else {
17521
+ //verificacao de ano bissexto para verificar até qual dia irá o mês de fevereiro
17522
+ if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
17523
+ return day < 1 || day > 29 ? false : true;
17524
+ }
17525
+ else {
17526
+ return day < 1 || day > 28 ? false : true;
17527
+ }
17528
+ }
17529
+ };
17363
17530
  return PoDatepickerRangeBaseComponent;
17364
17531
  }());
17365
17532
  PoDatepickerRangeBaseComponent.decorators = [
@@ -17379,6 +17546,8 @@
17379
17546
  disabled: [{ type: i0.Input, args: ['p-disabled',] }],
17380
17547
  endDate: [{ type: i0.Input, args: ['p-end-date',] }],
17381
17548
  literals: [{ type: i0.Input, args: ['p-literals',] }],
17549
+ minDate: [{ type: i0.Input, args: ['p-min-date',] }],
17550
+ maxDate: [{ type: i0.Input, args: ['p-max-date',] }],
17382
17551
  noAutocomplete: [{ type: i0.Input, args: ['p-no-autocomplete',] }],
17383
17552
  readonly: [{ type: i0.Input, args: ['p-readonly',] }],
17384
17553
  required: [{ type: i0.Input, args: ['p-required',] }],
@@ -17537,6 +17706,11 @@
17537
17706
  // Classe de máscara
17538
17707
  this.poMaskObject = this.buildMask();
17539
17708
  };
17709
+ PoDatepickerRangeComponent.prototype.ngOnChanges = function (changes) {
17710
+ if (changes.minDate || changes.maxDate) {
17711
+ this.validateModel(this.dateRange);
17712
+ }
17713
+ };
17540
17714
  PoDatepickerRangeComponent.prototype.ngOnDestroy = function () {
17541
17715
  this.removeListeners();
17542
17716
  };
@@ -17677,7 +17851,7 @@
17677
17851
  PoDatepickerRangeComponent.prototype.getDateRangeFormatValidation = function (startDate, endDate, isStartDateTargetEvent) {
17678
17852
  this.setDateRangeInputValidation(startDate, endDate);
17679
17853
  return {
17680
- isValid: this.isDateRangeInputFormatValid && this.isStartDateRangeInputValid,
17854
+ isValid: this.isDateRangeInputFormatValid && this.isStartDateRangeInputValid && this.verifyValidDate(startDate, endDate),
17681
17855
  dateRangeModel: this.getValidatedModel(startDate, endDate, isStartDateTargetEvent)
17682
17856
  };
17683
17857
  };
@@ -17841,7 +18015,7 @@
17841
18015
  PoDatepickerRangeComponent.decorators = [
17842
18016
  { type: i0.Component, args: [{
17843
18017
  selector: 'po-datepicker-range',
17844
- template: "<po-field-container [p-help]=\"help\" [p-label]=\"label\" [p-optional]=\"!required && optional\">\n <div #dateRangeField class=\"po-datepicker-range-field po-input\" [class.po-datepicker-range-field-disabled]=\"disabled\">\n <div class=\"po-datepicker-range-start-date\">\n <input\n #startDateInput\n class=\"po-datepicker-range-input\"\n maxlength=\"10\"\n type=\"text\"\n [autocomplete]=\"autocomplete\"\n [disabled]=\"disabled\"\n [name]=\"startDateInputName\"\n [readonly]=\"readonly\"\n (blur)=\"onBlur($event)\"\n (focus)=\"onFocus($event)\"\n (keydown)=\"onKeydown($event)\"\n (keyup)=\"onKeyup($event)\"\n (click)=\"eventOnClick($event)\"\n />\n </div>\n\n <div class=\"po-datepicker-range-separator\">-</div>\n\n <div class=\"po-datepicker-range-end-date\">\n <input\n #endDateInput\n class=\"po-datepicker-range-input\"\n maxlength=\"10\"\n type=\"text\"\n [autocomplete]=\"autocomplete\"\n [disabled]=\"disabled\"\n [name]=\"endDateInputName\"\n [readonly]=\"readonly\"\n (blur)=\"onBlur($event)\"\n (focus)=\"onFocus($event)\"\n (keydown)=\"onKeydown($event)\"\n (keyup)=\"onKeyup($event)\"\n (click)=\"eventOnClick($event)\"\n />\n </div>\n\n <div class=\"po-datepicker-range-icon\">\n <po-clean *ngIf=\"enableCleaner\" (p-change-event)=\"clear()\"></po-clean>\n </div>\n\n <div class=\"po-datepicker-range-icon\">\n <span\n #iconCalendar\n class=\"po-icon po-field-icon po-icon-calendar\"\n [class.po-clickable]=\"!disabled && !readonly\"\n [class.po-field-icon-disabled]=\"disabled || readonly\"\n (click)=\"toggleCalendar()\"\n >\n </span>\n </div>\n </div>\n\n <po-field-container-bottom [p-error-pattern]=\"getErrorMessage\"></po-field-container-bottom>\n</po-field-container>\n\n<ng-container *ngIf=\"isCalendarVisible\">\n <div #calendarPicker class=\"po-calendar-range-picker\">\n <po-calendar p-mode=\"range\" [ngModel]=\"dateRange\" (ngModelChange)=\"onCalendarChange($event)\"></po-calendar>\n </div>\n</ng-container>\n",
18018
+ template: "<po-field-container [p-help]=\"help\" [p-label]=\"label\" [p-optional]=\"!required && optional\">\n <div #dateRangeField class=\"po-datepicker-range-field po-input\" [class.po-datepicker-range-field-disabled]=\"disabled\">\n <div class=\"po-datepicker-range-start-date\">\n <input\n #startDateInput\n class=\"po-datepicker-range-input\"\n maxlength=\"10\"\n type=\"text\"\n [autocomplete]=\"autocomplete\"\n [disabled]=\"disabled\"\n [name]=\"startDateInputName\"\n [readonly]=\"readonly\"\n (blur)=\"onBlur($event)\"\n (focus)=\"onFocus($event)\"\n (keydown)=\"onKeydown($event)\"\n (keyup)=\"onKeyup($event)\"\n (click)=\"eventOnClick($event)\"\n />\n </div>\n\n <div class=\"po-datepicker-range-separator\">-</div>\n\n <div class=\"po-datepicker-range-end-date\">\n <input\n #endDateInput\n class=\"po-datepicker-range-input\"\n maxlength=\"10\"\n type=\"text\"\n [autocomplete]=\"autocomplete\"\n [disabled]=\"disabled\"\n [name]=\"endDateInputName\"\n [readonly]=\"readonly\"\n (blur)=\"onBlur($event)\"\n (focus)=\"onFocus($event)\"\n (keydown)=\"onKeydown($event)\"\n (keyup)=\"onKeyup($event)\"\n (click)=\"eventOnClick($event)\"\n />\n </div>\n\n <div class=\"po-datepicker-range-icon\">\n <po-clean *ngIf=\"enableCleaner\" (p-change-event)=\"clear()\"></po-clean>\n </div>\n\n <div class=\"po-datepicker-range-icon\">\n <span\n #iconCalendar\n class=\"po-icon po-field-icon po-icon-calendar\"\n [class.po-clickable]=\"!disabled && !readonly\"\n [class.po-field-icon-disabled]=\"disabled || readonly\"\n (click)=\"toggleCalendar()\"\n >\n </span>\n </div>\n </div>\n\n <po-field-container-bottom [p-error-pattern]=\"getErrorMessage\"></po-field-container-bottom>\n</po-field-container>\n\n<ng-container *ngIf=\"isCalendarVisible\">\n <div #calendarPicker class=\"po-calendar-range-picker\">\n <po-calendar\n p-mode=\"range\"\n [ngModel]=\"dateRange\"\n [p-max-date]=\"maxDate\"\n [p-min-date]=\"minDate\"\n (ngModelChange)=\"onCalendarChange($event)\"\n ></po-calendar>\n </div>\n</ng-container>\n",
17845
18019
  providers: providers$5
17846
18020
  },] }
17847
18021
  ];
@@ -19122,8 +19296,8 @@
19122
19296
  var PoEmailComponent = /** @class */ (function (_super) {
19123
19297
  __extends(PoEmailComponent, _super);
19124
19298
  /* istanbul ignore next */
19125
- function PoEmailComponent(el) {
19126
- var _this = _super.call(this, el) || this;
19299
+ function PoEmailComponent(el, cd) {
19300
+ var _this = _super.call(this, el, cd) || this;
19127
19301
  _this.icon = 'po-icon-mail';
19128
19302
  _this.type = 'email';
19129
19303
  // Consideramos o uso do nosso pattern com a seguinte expressão.
@@ -19176,11 +19350,13 @@
19176
19350
  { type: i0.Component, args: [{
19177
19351
  selector: 'po-email',
19178
19352
  template: "<po-field-container [p-help]=\"help\" [p-label]=\"label\" [p-optional]=\"!required && optional\">\n <div class=\"po-field-container-content\">\n <div *ngIf=\"icon\" class=\"po-field-icon-container-left\">\n <po-icon class=\"po-field-icon\" [class.po-field-icon-disabled]=\"disabled\" [p-icon]=\"icon\"></po-icon>\n </div>\n\n <input\n #inp\n class=\"po-input\"\n [attr.name]=\"name\"\n [autocomplete]=\"autocomplete\"\n [class.po-input-icon-left]=\"icon\"\n [class.po-input-icon-right]=\"clean\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n [type]=\"type\"\n (blur)=\"eventOnBlur($event)\"\n (click)=\"eventOnClick($event)\"\n (focus)=\"eventOnFocus($event)\"\n (input)=\"eventOnInput($event)\"\n />\n\n <div class=\"po-field-icon-container-right\">\n <po-clean *ngIf=\"clean && !disabled && !readonly\" [p-element-ref]=\"inputEl\" (p-change-event)=\"clear($event)\">\n </po-clean>\n </div>\n </div>\n\n <po-field-container-bottom [p-error-pattern]=\"getErrorPattern()\"> </po-field-container-bottom>\n</po-field-container>\n",
19353
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
19179
19354
  providers: providers$4
19180
19355
  },] }
19181
19356
  ];
19182
19357
  PoEmailComponent.ctorParameters = function () { return [
19183
- { type: i0.ElementRef }
19358
+ { type: i0.ElementRef },
19359
+ { type: i0.ChangeDetectorRef }
19184
19360
  ]; };
19185
19361
 
19186
19362
  /* istanbul ignore next */
@@ -19225,8 +19401,8 @@
19225
19401
  var PoLoginComponent = /** @class */ (function (_super) {
19226
19402
  __extends(PoLoginComponent, _super);
19227
19403
  /* istanbul ignore next */
19228
- function PoLoginComponent(el) {
19229
- var _this = _super.call(this, el) || this;
19404
+ function PoLoginComponent(el, cd) {
19405
+ var _this = _super.call(this, el, cd) || this;
19230
19406
  _this.type = 'text';
19231
19407
  return _this;
19232
19408
  }
@@ -19239,11 +19415,13 @@
19239
19415
  { type: i0.Component, args: [{
19240
19416
  selector: 'po-login',
19241
19417
  template: "<po-field-container [p-label]=\"label\" [p-help]=\"help\" [p-optional]=\"!required && optional\">\n <div class=\"po-field-container-content\">\n <div class=\"po-field-icon-container-left\">\n <span class=\"po-icon po-field-icon po-icon-user\" [class.po-field-icon-disabled]=\"disabled\"></span>\n </div>\n\n <input\n #inp\n class=\"po-input po-input-icon-left\"\n [attr.name]=\"name\"\n [autocomplete]=\"autocomplete\"\n [class.po-input-icon-right]=\"clean\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n [type]=\"type\"\n (blur)=\"eventOnBlur($event)\"\n (click)=\"eventOnClick($event)\"\n (focus)=\"eventOnFocus($event)\"\n (input)=\"eventOnInput($event)\"\n />\n\n <div class=\"po-field-icon-container-right\">\n <po-clean *ngIf=\"clean && !disabled && !readonly\" [p-element-ref]=\"inputEl\" (p-change-event)=\"clear($event)\">\n </po-clean>\n </div>\n </div>\n\n <po-field-container-bottom [p-error-pattern]=\"getErrorPattern()\"> </po-field-container-bottom>\n</po-field-container>\n",
19418
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
19242
19419
  providers: providers$3
19243
19420
  },] }
19244
19421
  ];
19245
19422
  PoLoginComponent.ctorParameters = function () { return [
19246
- { type: i0.ElementRef }
19423
+ { type: i0.ElementRef },
19424
+ { type: i0.ChangeDetectorRef }
19247
19425
  ]; };
19248
19426
 
19249
19427
  /**
@@ -19259,6 +19437,7 @@
19259
19437
  this.headers = new i1.HttpHeaders({
19260
19438
  'X-PO-No-Message': 'true'
19261
19439
  });
19440
+ this.multiple = false;
19262
19441
  }
19263
19442
  PoLookupFilterService.prototype.getFilteredItems = function (filteredItemsParams) {
19264
19443
  var filterParams = filteredItemsParams.filterParams, advancedFilters = filteredItemsParams.advancedFilters, restFilteredItemsParams = __rest(filteredItemsParams, ["filterParams", "advancedFilters"]);
@@ -19268,12 +19447,25 @@
19268
19447
  return this.httpClient.get(this.url, { headers: this.headers, params: params });
19269
19448
  };
19270
19449
  PoLookupFilterService.prototype.getObjectByValue = function (value, filterParams) {
19271
- var encodedValue = encodeURIComponent(value);
19272
19450
  var validatedFilterParams = this.validateParams(filterParams);
19273
- return this.httpClient.get(this.url + "/" + encodedValue, { headers: this.headers, params: validatedFilterParams });
19451
+ var newURL;
19452
+ var encodedValue;
19453
+ if (this.multiple) {
19454
+ encodedValue = encodeURIComponent(Array.isArray(value) ? value.join(',') : value);
19455
+ newURL = this.url + "?" + this.fieldValue + "=" + encodedValue;
19456
+ }
19457
+ else {
19458
+ encodedValue = encodeURIComponent(value);
19459
+ newURL = this.url + "/" + encodedValue;
19460
+ }
19461
+ return this.httpClient
19462
+ .get(newURL, { headers: this.headers, params: validatedFilterParams })
19463
+ .pipe(operators.map(function (response) { return ('items' in response ? response.items : response); }));
19274
19464
  };
19275
- PoLookupFilterService.prototype.setUrl = function (url) {
19465
+ PoLookupFilterService.prototype.setConfig = function (url, fieldValue, multiple) {
19276
19466
  this.url = url;
19467
+ this.fieldValue = fieldValue;
19468
+ this.multiple = multiple;
19277
19469
  };
19278
19470
  PoLookupFilterService.prototype.validateParams = function (params) {
19279
19471
  return isTypeof(params, 'object') && !Array.isArray(params) ? params : undefined;
@@ -19291,7 +19483,7 @@
19291
19483
  * @description
19292
19484
  *
19293
19485
  * Componente utilizado para abrir uma janela de busca com uma tabela que lista dados de um serviço. Nesta janela é possível buscar e
19294
- * selecionar o registro que será enviado para o campo. O `po-lookup` permite que o usuário digite um valor e pressione a tecla *TAB* para
19486
+ * selecionar um ou mais registros que serão enviados para o campo. O `po-lookup` permite que o usuário digite um valor e pressione a tecla *TAB* para
19295
19487
  * buscar um registro.
19296
19488
  *
19297
19489
  * > Caso o campo seja iniciado ou preenchido com um valor inexistente na busca, o mesmo será limpado.
@@ -19329,6 +19521,31 @@
19329
19521
  * @default `false`
19330
19522
  */
19331
19523
  this.infiniteScroll = false;
19524
+ /** Exibe um ícone que permite limpar o campo. */
19525
+ this.clean = false;
19526
+ /**
19527
+ * @optional
19528
+ *
19529
+ * @description
19530
+ *
19531
+ * Permite a seleção de múltiplos itens.
19532
+ *
19533
+ * > Quando habilitado o valor do campo passará a ser uma lista de valores, por exemplo: `[ 12345, 67890 ]`
19534
+ *
19535
+ * @default `false`
19536
+ */
19537
+ this.multiple = false;
19538
+ /**
19539
+ * @optional
19540
+ *
19541
+ * @description
19542
+ *
19543
+ * Define que a altura do componente será auto ajustável, possuindo uma altura minima porém a altura máxima será de acordo
19544
+ * com o número de itens selecionados e a extensão dos mesmos, mantendo-os sempre visíveis.
19545
+ *
19546
+ * @default `false`
19547
+ */
19548
+ this.autoHeight = false;
19332
19549
  /**
19333
19550
  * Evento será disparado quando ocorrer algum erro na requisição de busca do item.
19334
19551
  * Será passado por parâmetro o objeto de erro retornado.
@@ -19352,6 +19569,7 @@
19352
19569
  * Por parâmetro será passado o novo valor.
19353
19570
  */
19354
19571
  this.change = new i0.EventEmitter();
19572
+ this.selectedOptions = [];
19355
19573
  this.oldValue = '';
19356
19574
  this.oldValueToModel = null;
19357
19575
  // eslint-disable-next-line
@@ -19359,6 +19577,7 @@
19359
19577
  this._disabled = false;
19360
19578
  this._placeholder = '';
19361
19579
  this._required = false;
19580
+ this._autoHeight = false;
19362
19581
  this.onChangePropagate = null;
19363
19582
  }
19364
19583
  Object.defineProperty(PoLookupBaseComponent.prototype, "placeholder", {
@@ -19416,6 +19635,20 @@
19416
19635
  * url + ?page=1&pageSize=20&age=23&filter=Peter
19417
19636
  * ```
19418
19637
  *
19638
+ * Ao iniciar o campo com valor, os registros serão buscados da seguinte forma:
19639
+ * ```
19640
+ * model = 1234;
19641
+ *
19642
+ * GET url/1234
19643
+ * ```
19644
+ *
19645
+ * Caso estiver com múltipla seleção habilitada:
19646
+ * ```
19647
+ * model = [1234, 5678]
19648
+ *
19649
+ * GET url?${fieldValue}=1234,5678
19650
+ * ```
19651
+ *
19419
19652
  * > Esta URL deve retornar e receber os dados no padrão de [API do PO UI](https://po-ui.io/guides/api) e utiliza os valores
19420
19653
  * definidos nas propriedades `p-field-label` e `p-field-value` para a construção do `po-lookup`.
19421
19654
  *
@@ -19504,6 +19737,15 @@
19504
19737
  PoLookupBaseComponent.prototype.ngAfterViewInit = function () {
19505
19738
  this.setControl();
19506
19739
  };
19740
+ PoLookupBaseComponent.prototype.cleanModel = function () {
19741
+ this.cleanViewValue();
19742
+ this.callOnChange(undefined);
19743
+ };
19744
+ PoLookupBaseComponent.prototype.ngOnChanges = function (changes) {
19745
+ if (changes.multiple && isTypeof(this.filterService, 'string')) {
19746
+ this.service.setConfig(this.filterService, this.fieldValue, this.multiple);
19747
+ }
19748
+ };
19507
19749
  // Função implementada do ControlValueAccessor
19508
19750
  // Usada para interceptar os estados de habilitado via forms api
19509
19751
  PoLookupBaseComponent.prototype.setDisabledState = function (isDisabled) {
@@ -19524,7 +19766,7 @@
19524
19766
  };
19525
19767
  // Seleciona o valor do model.
19526
19768
  PoLookupBaseComponent.prototype.selectValue = function (valueSelected) {
19527
- this.valueToModel = valueSelected[this.fieldValue];
19769
+ this.valueToModel = valueSelected;
19528
19770
  this.callOnChange(this.valueToModel);
19529
19771
  this.selected.emit(valueSelected);
19530
19772
  };
@@ -19563,10 +19805,12 @@
19563
19805
  }
19564
19806
  }))
19565
19807
  .subscribe(function (element) {
19566
- if (element) {
19567
- _this.oldValue = element[_this.fieldLabel];
19568
- _this.selectValue(element);
19569
- _this.setViewValue(_this.getFormattedLabel(element), element);
19808
+ if ((element === null || element === void 0 ? void 0 : element.length) || (!Array.isArray(element) && element)) {
19809
+ if (Array.isArray(element) && element.length > 1) {
19810
+ _this.setDisclaimers(element);
19811
+ _this.updateVisibleItems();
19812
+ }
19813
+ _this.selectModel(_this.multiple ? element : [element]);
19570
19814
  }
19571
19815
  else {
19572
19816
  _this.cleanModel();
@@ -19590,13 +19834,7 @@
19590
19834
  }
19591
19835
  };
19592
19836
  PoLookupBaseComponent.prototype.writeValue = function (value) {
19593
- if (value && value instanceof Object) {
19594
- // Esta condição é executada quando é retornado o objeto selecionado do componente Po Lookup Modal.
19595
- this.oldValue = value[this.fieldLabel];
19596
- this.valueToModel = value[this.fieldValue];
19597
- this.setViewValue(this.getFormattedLabel(value), value);
19598
- }
19599
- else if (value) {
19837
+ if ((value === null || value === void 0 ? void 0 : value.length) || (!Array.isArray(value) && value)) {
19600
19838
  // Esta condição é executada somente quando é passado o ID para realizar a busca pelo ID.
19601
19839
  this.searchById(value);
19602
19840
  }
@@ -19604,10 +19842,6 @@
19604
19842
  this.cleanViewValue();
19605
19843
  }
19606
19844
  };
19607
- PoLookupBaseComponent.prototype.cleanModel = function () {
19608
- this.cleanViewValue();
19609
- this.callOnChange(undefined);
19610
- };
19611
19845
  PoLookupBaseComponent.prototype.cleanViewValue = function () {
19612
19846
  this.setViewValue('', {});
19613
19847
  this.oldValue = '';
@@ -19618,10 +19852,20 @@
19618
19852
  return value ? this.keysDescription.map(function (column) { return value[column]; }).join(' - ') : '';
19619
19853
  };
19620
19854
  // Chama o método writeValue e preenche o model.
19621
- PoLookupBaseComponent.prototype.selectModel = function (value) {
19622
- this.writeValue(value);
19623
- if (value && value instanceof Object) {
19624
- this.selectValue(value);
19855
+ PoLookupBaseComponent.prototype.selectModel = function (options) {
19856
+ var _this = this;
19857
+ if (options.length) {
19858
+ this.selectedOptions = __spreadArray([], __read(options));
19859
+ var newModel = this.multiple ? options.map(function (option) { return option[_this.fieldValue]; }) : options[0][this.fieldValue];
19860
+ this.selectValue(newModel);
19861
+ if (options.length === 1) {
19862
+ this.oldValue = options[0][this.fieldLabel];
19863
+ this.setViewValue(this.getFormattedLabel(options[0]), options[0]);
19864
+ }
19865
+ }
19866
+ else {
19867
+ this.selectValue(undefined);
19868
+ this.cleanViewValue();
19625
19869
  }
19626
19870
  };
19627
19871
  PoLookupBaseComponent.prototype.validateModel = function (model) {
@@ -19635,7 +19879,7 @@
19635
19879
  }
19636
19880
  if (service && isTypeof(service, 'string')) {
19637
19881
  this.service = this.defaultService;
19638
- this.service.setUrl(service);
19882
+ this.service.setConfig(service, this.fieldValue, this.multiple);
19639
19883
  }
19640
19884
  };
19641
19885
  PoLookupBaseComponent.prototype.setControl = function () {
@@ -19677,6 +19921,9 @@
19677
19921
  optional: [{ type: i0.Input, args: ['p-optional',] }],
19678
19922
  advancedFilters: [{ type: i0.Input, args: ['p-advanced-filters',] }],
19679
19923
  infiniteScroll: [{ type: i0.Input, args: ['p-infinite-scroll',] }],
19924
+ clean: [{ type: i0.Input, args: ['p-clean',] }],
19925
+ multiple: [{ type: i0.Input, args: ['p-multiple',] }],
19926
+ autoHeight: [{ type: i0.Input, args: ['p-auto-height',] }],
19680
19927
  onError: [{ type: i0.Output, args: ['p-error',] }],
19681
19928
  selected: [{ type: i0.Output, args: ['p-selected',] }],
19682
19929
  change: [{ type: i0.Output, args: ['p-change',] }],
@@ -19691,6 +19938,377 @@
19691
19938
  __decorate([
19692
19939
  InputBoolean()
19693
19940
  ], PoLookupBaseComponent.prototype, "infiniteScroll", void 0);
19941
+ __decorate([
19942
+ InputBoolean()
19943
+ ], PoLookupBaseComponent.prototype, "clean", void 0);
19944
+ __decorate([
19945
+ InputBoolean()
19946
+ ], PoLookupBaseComponent.prototype, "multiple", void 0);
19947
+ __decorate([
19948
+ InputBoolean()
19949
+ ], PoLookupBaseComponent.prototype, "autoHeight", void 0);
19950
+
19951
+ var poLookupLiteralsDefault = {
19952
+ en: {
19953
+ modalPrimaryActionLabel: 'Select',
19954
+ modalSecondaryActionLabel: 'Cancel',
19955
+ modalPlaceholder: 'Search',
19956
+ modalTitle: 'Select a record',
19957
+ modalTableNoColumns: poTableLiteralsDefault.en.noColumns,
19958
+ modalTableNoData: poTableLiteralsDefault.en.noData,
19959
+ modalTableLoadingData: poTableLiteralsDefault.en.loadingData,
19960
+ modalTableLoadMoreData: poTableLiteralsDefault.en.loadMoreData,
19961
+ modalAdvancedSearch: 'Advanced search',
19962
+ modalAdvancedSearchTitle: 'Advanced search',
19963
+ modalAdvancedSearchPrimaryActionLabel: 'Filter',
19964
+ modalAdvancedSearchSecondaryActionLabel: 'Return',
19965
+ modalDisclaimerGroupTitle: 'Presenting results filtered by:'
19966
+ },
19967
+ es: {
19968
+ modalPrimaryActionLabel: 'Seleccionar',
19969
+ modalSecondaryActionLabel: 'Cancelar',
19970
+ modalPlaceholder: 'Buscar',
19971
+ modalTitle: 'Seleccione un registro',
19972
+ modalTableNoColumns: poTableLiteralsDefault.es.noColumns,
19973
+ modalTableNoData: poTableLiteralsDefault.es.noData,
19974
+ modalTableLoadingData: poTableLiteralsDefault.es.loadingData,
19975
+ modalTableLoadMoreData: poTableLiteralsDefault.es.loadMoreData,
19976
+ modalAdvancedSearch: 'Búsqueda Avanzada',
19977
+ modalAdvancedSearchTitle: 'Búsqueda Avanzada',
19978
+ modalAdvancedSearchPrimaryActionLabel: 'Filtrar',
19979
+ modalAdvancedSearchSecondaryActionLabel: 'Vuelve',
19980
+ modalDisclaimerGroupTitle: 'Presentar resultados filtrados por:'
19981
+ },
19982
+ pt: {
19983
+ modalPrimaryActionLabel: 'Selecionar',
19984
+ modalSecondaryActionLabel: 'Cancelar',
19985
+ modalPlaceholder: 'Pesquisar',
19986
+ modalTitle: 'Selecione um registro',
19987
+ modalTableNoColumns: poTableLiteralsDefault.pt.noColumns,
19988
+ modalTableNoData: poTableLiteralsDefault.pt.noData,
19989
+ modalTableLoadingData: poTableLiteralsDefault.pt.loadingData,
19990
+ modalTableLoadMoreData: poTableLiteralsDefault.pt.loadMoreData,
19991
+ modalAdvancedSearch: 'Busca avançada',
19992
+ modalAdvancedSearchTitle: 'Busca Avançada',
19993
+ modalAdvancedSearchPrimaryActionLabel: 'Filtrar',
19994
+ modalAdvancedSearchSecondaryActionLabel: 'Voltar',
19995
+ modalDisclaimerGroupTitle: 'Apresentando resultados filtrados por:'
19996
+ },
19997
+ ru: {
19998
+ modalPrimaryActionLabel: 'выбирать',
19999
+ modalSecondaryActionLabel: 'отменить',
20000
+ modalPlaceholder: 'поиск',
20001
+ modalTitle: 'Выберите запись',
20002
+ modalTableNoColumns: poTableLiteralsDefault.ru.noColumns,
20003
+ modalTableNoData: poTableLiteralsDefault.ru.noData,
20004
+ modalTableLoadingData: poTableLiteralsDefault.ru.loadingData,
20005
+ modalTableLoadMoreData: poTableLiteralsDefault.ru.loadMoreData,
20006
+ modalAdvancedSearch: 'Расширенный поиск',
20007
+ modalAdvancedSearchTitle: 'Расширенный поиск',
20008
+ modalAdvancedSearchPrimaryActionLabel: 'Фильтр',
20009
+ modalAdvancedSearchSecondaryActionLabel: 'Вернись',
20010
+ modalDisclaimerGroupTitle: 'Представление результатов отфильтровано по:'
20011
+ }
20012
+ };
20013
+ /**
20014
+ * @docsPrivate
20015
+ *
20016
+ * Classe base do componente Po Lookup Modal.
20017
+ */
20018
+ var PoLookupModalBaseComponent = /** @class */ (function () {
20019
+ function PoLookupModalBaseComponent(languageService, changeDetector) {
20020
+ var _this = this;
20021
+ this.changeDetector = changeDetector;
20022
+ /** Se verdadeiro, ativa a funcionalidade de scroll infinito para a tabela exibida no retorno da consulta. */
20023
+ this.infiniteScroll = false;
20024
+ /** Se verdadeiro, ativa a funcionalidade de multipla seleção. */
20025
+ this.multiple = false;
20026
+ /** Evento utilizado ao selecionar um registro da tabela. */
20027
+ this.model = new i0.EventEmitter();
20028
+ this.hasNext = true;
20029
+ this.isLoading = false;
20030
+ this.page = 1;
20031
+ this.pageSize = 10;
20032
+ this.searchValue = '';
20033
+ // Propriedade da modal de busca avançada:
20034
+ this.advancedFilterModalTitle = '';
20035
+ this.dynamicFormValue = {};
20036
+ this.isAdvancedFilter = false;
20037
+ this.selecteds = [];
20038
+ this.language = poLocaleDefault;
20039
+ // eslint-disable-next-line @typescript-eslint/member-ordering
20040
+ this.primaryAction = {
20041
+ action: function () {
20042
+ var selectedsItems = _this.selecteds;
20043
+ _this.model.emit(selectedsItems);
20044
+ _this.poModal.close();
20045
+ },
20046
+ label: this.literals.modalPrimaryActionLabel
20047
+ };
20048
+ // eslint-disable-next-line @typescript-eslint/member-ordering
20049
+ this.secondaryAction = {
20050
+ action: function () {
20051
+ _this.model.emit(null);
20052
+ _this.poModal.close();
20053
+ },
20054
+ label: this.literals.modalSecondaryActionLabel
20055
+ };
20056
+ this.language = languageService.getShortLanguage();
20057
+ }
20058
+ Object.defineProperty(PoLookupModalBaseComponent.prototype, "literals", {
20059
+ get: function () {
20060
+ return this._literals || poLookupLiteralsDefault[this.language];
20061
+ },
20062
+ /** Objeto com as literais usadas no `po-lookup-modal`. */
20063
+ set: function (value) {
20064
+ if (value instanceof Object && !(value instanceof Array)) {
20065
+ this._literals = Object.assign(Object.assign(Object.assign({}, poLookupLiteralsDefault[poLocaleDefault]), poLookupLiteralsDefault[this.language]), value);
20066
+ if (value.modalTitle) {
20067
+ this.title = this.literals.modalTitle;
20068
+ }
20069
+ }
20070
+ else {
20071
+ this._literals = poLookupLiteralsDefault[this.language];
20072
+ }
20073
+ this.primaryAction.label = this.literals.modalPrimaryActionLabel;
20074
+ this.secondaryAction.label = this.literals.modalSecondaryActionLabel;
20075
+ this.setTableLiterals();
20076
+ },
20077
+ enumerable: false,
20078
+ configurable: true
20079
+ });
20080
+ Object.defineProperty(PoLookupModalBaseComponent.prototype, "title", {
20081
+ get: function () {
20082
+ return this._title;
20083
+ },
20084
+ /** Título da modal. */
20085
+ set: function (value) {
20086
+ this._title = isTypeof(value, 'string') ? value : this.literals.modalTitle;
20087
+ },
20088
+ enumerable: false,
20089
+ configurable: true
20090
+ });
20091
+ PoLookupModalBaseComponent.prototype.ngOnDestroy = function () {
20092
+ if (this.filterSubscription) {
20093
+ this.filterSubscription.unsubscribe();
20094
+ }
20095
+ if (this.searchSubscription) {
20096
+ this.searchSubscription.unsubscribe();
20097
+ }
20098
+ if (this.showMoreSubscription) {
20099
+ this.showMoreSubscription.unsubscribe();
20100
+ }
20101
+ };
20102
+ PoLookupModalBaseComponent.prototype.ngOnInit = function () {
20103
+ this.setAdvancedFilterModalProperties();
20104
+ this.initializeData();
20105
+ this.setTableLiterals();
20106
+ };
20107
+ PoLookupModalBaseComponent.prototype.createDisclaimer = function () {
20108
+ var e_1, _c;
20109
+ this.disclaimerGroup.disclaimers = [];
20110
+ this.searchValue = '';
20111
+ try {
20112
+ for (var _d = __values(Object.entries(this.dynamicFormValue)), _e = _d.next(); !_e.done; _e = _d.next()) {
20113
+ var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
20114
+ this.addDisclaimer(value, key);
20115
+ }
20116
+ }
20117
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20118
+ finally {
20119
+ try {
20120
+ if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
20121
+ }
20122
+ finally { if (e_1) throw e_1.error; }
20123
+ }
20124
+ if (!Object.values(this.dynamicFormValue).some(function (v) { return v !== null && typeof v !== 'undefined'; })) {
20125
+ this.initializeData();
20126
+ }
20127
+ };
20128
+ PoLookupModalBaseComponent.prototype.addDisclaimer = function (value, property) {
20129
+ this.disclaimer = { property: property };
20130
+ this.disclaimer.value = value;
20131
+ this.disclaimerGroup.disclaimers = __spreadArray(__spreadArray([], __read(this.disclaimerGroup.disclaimers)), [this.disclaimer]);
20132
+ };
20133
+ PoLookupModalBaseComponent.prototype.onChangeDisclaimerGroup = function () {
20134
+ if (!this.searchValue) {
20135
+ this.isLoading = true;
20136
+ this.searchValue = '';
20137
+ this.searchFilteredItems();
20138
+ }
20139
+ };
20140
+ PoLookupModalBaseComponent.prototype.search = function () {
20141
+ this.page = 1;
20142
+ if (this.searchValue) {
20143
+ this.isLoading = true;
20144
+ this.disclaimerGroup.disclaimers = [];
20145
+ this.searchFilteredItems();
20146
+ }
20147
+ else {
20148
+ this.initializeData();
20149
+ }
20150
+ };
20151
+ PoLookupModalBaseComponent.prototype.searchFilteredItems = function () {
20152
+ var _this = this;
20153
+ this.searchSubscription = this.getFilteredItems(this.searchValue)
20154
+ .pipe(operators.catchError(function (error) {
20155
+ _this.setLookupResponseProperties();
20156
+ return rxjs.throwError(error);
20157
+ }))
20158
+ .subscribe(function (data) { return _this.setLookupResponseProperties(data); }, function () { });
20159
+ };
20160
+ PoLookupModalBaseComponent.prototype.showMoreEvent = function () {
20161
+ var _this = this;
20162
+ this.page++;
20163
+ this.isLoading = true;
20164
+ this.showMoreSubscription = this.getFilteredItems(this.searchValue)
20165
+ .pipe(operators.catchError(function (error) {
20166
+ _this.hasNext = false;
20167
+ _this.isLoading = false;
20168
+ return rxjs.throwError(error);
20169
+ }))
20170
+ .subscribe(function (data) {
20171
+ _this.items = __spreadArray(__spreadArray([], __read(_this.items)), __read(data.items));
20172
+ _this.hasNext = data.hasNext;
20173
+ _this.isLoading = false;
20174
+ _this.changeDetector.detectChanges();
20175
+ _this.setSelectedItems();
20176
+ }, function () { });
20177
+ };
20178
+ //Método responsável por selecionar as linhas quando abre o modal.
20179
+ PoLookupModalBaseComponent.prototype.setSelectedItems = function () {
20180
+ var _this = this;
20181
+ this.selecteds.forEach(function (selectedItem) { return _this.poTable.selectRowItem(function (item) { return item[_this.fieldValue] === selectedItem.value; }); });
20182
+ };
20183
+ //Método responsável por criar os disclaimers quando abre o modal.
20184
+ PoLookupModalBaseComponent.prototype.setDisclaimersItems = function () {
20185
+ if (this.selectedItems && !Array.isArray(this.selectedItems)) {
20186
+ this.selecteds = [{ value: this.selectedItems }];
20187
+ return;
20188
+ }
20189
+ if (this.selectedItems && this.selectedItems.length) {
20190
+ this.selecteds = __spreadArray([], __read(this.selectedItems));
20191
+ }
20192
+ };
20193
+ PoLookupModalBaseComponent.prototype.setAdvancedFilterModalProperties = function () {
20194
+ var _this = this;
20195
+ this.advancedFilterModalTitle = this.literals.modalAdvancedSearchTitle;
20196
+ this.disclaimerGroup = {
20197
+ title: this.literals.modalDisclaimerGroupTitle,
20198
+ disclaimers: []
20199
+ };
20200
+ this.primaryActionAdvancedFilter = {
20201
+ action: function () {
20202
+ _this.destroyDynamicForm();
20203
+ _this.isAdvancedFilter = false;
20204
+ _this.createDisclaimer();
20205
+ },
20206
+ label: this.literals.modalAdvancedSearchPrimaryActionLabel
20207
+ };
20208
+ this.secondaryActionAdvancedFilter = {
20209
+ action: function () {
20210
+ _this.destroyDynamicForm();
20211
+ _this.isAdvancedFilter = false;
20212
+ },
20213
+ label: this.literals.modalAdvancedSearchSecondaryActionLabel
20214
+ };
20215
+ };
20216
+ PoLookupModalBaseComponent.prototype.getAdvancedFilters = function (advancedParams) {
20217
+ if (advancedParams && advancedParams.length > 0) {
20218
+ var filters_1 = {};
20219
+ var validatedAdvacendFilters_1;
20220
+ advancedParams.forEach(function (filter) {
20221
+ filters_1[filter.property] = filter.value instanceof Array ? filter.value.join() : filter.value;
20222
+ validatedAdvacendFilters_1 = Object.assign(Object.assign({}, validatedAdvacendFilters_1), filters_1);
20223
+ });
20224
+ return validatedAdvacendFilters_1;
20225
+ }
20226
+ return undefined;
20227
+ };
20228
+ PoLookupModalBaseComponent.prototype.getFilteredItems = function (filter) {
20229
+ var filteredParams = this.getFilteredParams(filter);
20230
+ return this.filterService.getFilteredItems(filteredParams);
20231
+ };
20232
+ PoLookupModalBaseComponent.prototype.getFilteredParams = function (filter) {
20233
+ var _c = this, page = _c.page, pageSize = _c.pageSize, filterParams = _c.filterParams, sort = _c.sort;
20234
+ var filteredParams = {};
20235
+ var order = this.getOrderParam(sort);
20236
+ var advancedFilters = this.getAdvancedFilters(this.disclaimerGroup.disclaimers);
20237
+ var params = { filter: filter, page: page, pageSize: pageSize, order: order, filterParams: filterParams, advancedFilters: advancedFilters };
20238
+ for (var key in params) {
20239
+ if (params.hasOwnProperty(key) && params[key] !== undefined) {
20240
+ filteredParams[key] = params[key];
20241
+ }
20242
+ }
20243
+ return filteredParams;
20244
+ };
20245
+ PoLookupModalBaseComponent.prototype.getOrderParam = function (sort) {
20246
+ if (sort === void 0) { sort = { type: undefined }; }
20247
+ var column = sort.column, type = sort.type;
20248
+ if (!column) {
20249
+ return;
20250
+ }
20251
+ if (type === exports.PoTableColumnSortType.Descending) {
20252
+ return "-" + column.property;
20253
+ }
20254
+ return "" + column.property;
20255
+ };
20256
+ PoLookupModalBaseComponent.prototype.initializeData = function () {
20257
+ var _this = this;
20258
+ this.isLoading = true;
20259
+ this.filterSubscription = this.getFilteredItems('').subscribe(function (data) {
20260
+ _this.setLookupResponseProperties(data);
20261
+ });
20262
+ };
20263
+ PoLookupModalBaseComponent.prototype.setLookupResponseProperties = function (data) {
20264
+ var _a, _b;
20265
+ this.items = (_a = data === null || data === void 0 ? void 0 : data.items) !== null && _a !== void 0 ? _a : [];
20266
+ this.hasNext = (_b = data === null || data === void 0 ? void 0 : data.hasNext) !== null && _b !== void 0 ? _b : false;
20267
+ this.isLoading = false;
20268
+ this.changeDetector.detectChanges();
20269
+ this.setDisclaimersItems();
20270
+ this.setSelectedItems();
20271
+ };
20272
+ PoLookupModalBaseComponent.prototype.setTableLiterals = function () {
20273
+ this.tableLiterals = {
20274
+ 'noColumns': this.literals.modalTableNoColumns,
20275
+ 'noData': this.literals.modalTableNoData,
20276
+ 'loadingData': this.literals.modalTableLoadingData,
20277
+ 'loadMoreData': this.literals.modalTableLoadMoreData
20278
+ };
20279
+ };
20280
+ return PoLookupModalBaseComponent;
20281
+ }());
20282
+ PoLookupModalBaseComponent.decorators = [
20283
+ { type: i0.Directive }
20284
+ ];
20285
+ PoLookupModalBaseComponent.ctorParameters = function () { return [
20286
+ { type: PoLanguageService },
20287
+ { type: i0.ChangeDetectorRef }
20288
+ ]; };
20289
+ PoLookupModalBaseComponent.propDecorators = {
20290
+ poModal: [{ type: i0.ViewChild, args: [PoModalComponent, { static: true },] }],
20291
+ poTable: [{ type: i0.ViewChild, args: [PoTableComponent, { static: true },] }],
20292
+ advancedFilters: [{ type: i0.Input, args: ['p-advanced-filters',] }],
20293
+ columns: [{ type: i0.Input, args: ['p-columns',] }],
20294
+ items: [{ type: i0.Input, args: ['p-items',] }],
20295
+ filterService: [{ type: i0.Input, args: ['p-filter-service',] }],
20296
+ filterParams: [{ type: i0.Input, args: ['p-filter-params',] }],
20297
+ infiniteScroll: [{ type: i0.Input, args: ['p-infinite-scroll',] }],
20298
+ multiple: [{ type: i0.Input, args: ['p-multiple',] }],
20299
+ model: [{ type: i0.Output, args: ['p-change-model',] }],
20300
+ selectedItems: [{ type: i0.Input, args: ['p-selected-items',] }],
20301
+ fieldLabel: [{ type: i0.Input, args: ['p-field-label',] }],
20302
+ fieldValue: [{ type: i0.Input, args: ['p-field-value',] }],
20303
+ literals: [{ type: i0.Input, args: ['p-literals',] }],
20304
+ title: [{ type: i0.Input, args: ['p-title',] }]
20305
+ };
20306
+ __decorate([
20307
+ InputBoolean()
20308
+ ], PoLookupModalBaseComponent.prototype, "infiniteScroll", void 0);
20309
+ __decorate([
20310
+ InputBoolean()
20311
+ ], PoLookupModalBaseComponent.prototype, "multiple", void 0);
19694
20312
 
19695
20313
  /**
19696
20314
  *
@@ -20068,338 +20686,6 @@
20068
20686
  form: [{ type: i0.ViewChild, args: ['dynamicForm',] }]
20069
20687
  };
20070
20688
 
20071
- var poLookupLiteralsDefault = {
20072
- en: {
20073
- modalPrimaryActionLabel: 'Select',
20074
- modalSecondaryActionLabel: 'Cancel',
20075
- modalPlaceholder: 'Search',
20076
- modalTitle: 'Select a record',
20077
- modalTableNoColumns: poTableLiteralsDefault.en.noColumns,
20078
- modalTableNoData: poTableLiteralsDefault.en.noData,
20079
- modalTableLoadingData: poTableLiteralsDefault.en.loadingData,
20080
- modalTableLoadMoreData: poTableLiteralsDefault.en.loadMoreData,
20081
- modalAdvancedSearch: 'Advanced search',
20082
- modalAdvancedSearchTitle: 'Advanced search',
20083
- modalAdvancedSearchPrimaryActionLabel: 'Filter',
20084
- modalAdvancedSearchSecondaryActionLabel: 'Return',
20085
- modalDisclaimerGroupTitle: 'Presenting results filtered by:'
20086
- },
20087
- es: {
20088
- modalPrimaryActionLabel: 'Seleccionar',
20089
- modalSecondaryActionLabel: 'Cancelar',
20090
- modalPlaceholder: 'Buscar',
20091
- modalTitle: 'Seleccione un registro',
20092
- modalTableNoColumns: poTableLiteralsDefault.es.noColumns,
20093
- modalTableNoData: poTableLiteralsDefault.es.noData,
20094
- modalTableLoadingData: poTableLiteralsDefault.es.loadingData,
20095
- modalTableLoadMoreData: poTableLiteralsDefault.es.loadMoreData,
20096
- modalAdvancedSearch: 'Búsqueda Avanzada',
20097
- modalAdvancedSearchTitle: 'Búsqueda Avanzada',
20098
- modalAdvancedSearchPrimaryActionLabel: 'Filtrar',
20099
- modalAdvancedSearchSecondaryActionLabel: 'Vuelve',
20100
- modalDisclaimerGroupTitle: 'Presentar resultados filtrados por:'
20101
- },
20102
- pt: {
20103
- modalPrimaryActionLabel: 'Selecionar',
20104
- modalSecondaryActionLabel: 'Cancelar',
20105
- modalPlaceholder: 'Pesquisar',
20106
- modalTitle: 'Selecione um registro',
20107
- modalTableNoColumns: poTableLiteralsDefault.pt.noColumns,
20108
- modalTableNoData: poTableLiteralsDefault.pt.noData,
20109
- modalTableLoadingData: poTableLiteralsDefault.pt.loadingData,
20110
- modalTableLoadMoreData: poTableLiteralsDefault.pt.loadMoreData,
20111
- modalAdvancedSearch: 'Busca avançada',
20112
- modalAdvancedSearchTitle: 'Busca Avançada',
20113
- modalAdvancedSearchPrimaryActionLabel: 'Filtrar',
20114
- modalAdvancedSearchSecondaryActionLabel: 'Voltar',
20115
- modalDisclaimerGroupTitle: 'Apresentando resultados filtrados por:'
20116
- },
20117
- ru: {
20118
- modalPrimaryActionLabel: 'выбирать',
20119
- modalSecondaryActionLabel: 'отменить',
20120
- modalPlaceholder: 'поиск',
20121
- modalTitle: 'Выберите запись',
20122
- modalTableNoColumns: poTableLiteralsDefault.ru.noColumns,
20123
- modalTableNoData: poTableLiteralsDefault.ru.noData,
20124
- modalTableLoadingData: poTableLiteralsDefault.ru.loadingData,
20125
- modalTableLoadMoreData: poTableLiteralsDefault.ru.loadMoreData,
20126
- modalAdvancedSearch: 'Расширенный поиск',
20127
- modalAdvancedSearchTitle: 'Расширенный поиск',
20128
- modalAdvancedSearchPrimaryActionLabel: 'Фильтр',
20129
- modalAdvancedSearchSecondaryActionLabel: 'Вернись',
20130
- modalDisclaimerGroupTitle: 'Представление результатов отфильтровано по:'
20131
- }
20132
- };
20133
- /**
20134
- * @docsPrivate
20135
- *
20136
- * Classe base do componente Po Lookup Modal.
20137
- */
20138
- var PoLookupModalBaseComponent = /** @class */ (function () {
20139
- function PoLookupModalBaseComponent(languageService) {
20140
- var _this = this;
20141
- /** Se verdadeiro, ativa a funcionalidade de scroll infinito para a tabela exibida no retorno da consulta. */
20142
- this.infiniteScroll = false;
20143
- /** Evento utilizado ao selecionar um registro da tabela. */
20144
- this.model = new i0.EventEmitter();
20145
- this.hasNext = true;
20146
- this.isLoading = false;
20147
- this.page = 1;
20148
- this.pageSize = 10;
20149
- this.searchValue = '';
20150
- // Propriedade da modal de busca avançada:
20151
- this.advancedFilterModalTitle = '';
20152
- this.dynamicFormValue = {};
20153
- this.isAdvancedFilter = false;
20154
- this.language = poLocaleDefault;
20155
- // eslint-disable-next-line @typescript-eslint/member-ordering
20156
- this.primaryAction = {
20157
- action: function () {
20158
- _this.items.forEach(function (element) {
20159
- if (element['$selected']) {
20160
- _this.model.emit(element);
20161
- _this.poModal.close();
20162
- }
20163
- });
20164
- },
20165
- label: this.literals.modalPrimaryActionLabel
20166
- };
20167
- // eslint-disable-next-line @typescript-eslint/member-ordering
20168
- this.secondaryAction = {
20169
- action: function () {
20170
- _this.model.emit(null);
20171
- _this.poModal.close();
20172
- },
20173
- label: this.literals.modalSecondaryActionLabel
20174
- };
20175
- this.language = languageService.getShortLanguage();
20176
- }
20177
- Object.defineProperty(PoLookupModalBaseComponent.prototype, "literals", {
20178
- get: function () {
20179
- return this._literals || poLookupLiteralsDefault[this.language];
20180
- },
20181
- /** Objeto com as literais usadas no `po-lookup-modal`. */
20182
- set: function (value) {
20183
- if (value instanceof Object && !(value instanceof Array)) {
20184
- this._literals = Object.assign(Object.assign(Object.assign({}, poLookupLiteralsDefault[poLocaleDefault]), poLookupLiteralsDefault[this.language]), value);
20185
- if (value.modalTitle) {
20186
- this.title = this.literals.modalTitle;
20187
- }
20188
- }
20189
- else {
20190
- this._literals = poLookupLiteralsDefault[this.language];
20191
- }
20192
- this.primaryAction.label = this.literals.modalPrimaryActionLabel;
20193
- this.secondaryAction.label = this.literals.modalSecondaryActionLabel;
20194
- this.setTableLiterals();
20195
- },
20196
- enumerable: false,
20197
- configurable: true
20198
- });
20199
- Object.defineProperty(PoLookupModalBaseComponent.prototype, "title", {
20200
- get: function () {
20201
- return this._title;
20202
- },
20203
- /** Título da modal. */
20204
- set: function (value) {
20205
- this._title = isTypeof(value, 'string') ? value : this.literals.modalTitle;
20206
- },
20207
- enumerable: false,
20208
- configurable: true
20209
- });
20210
- PoLookupModalBaseComponent.prototype.ngOnDestroy = function () {
20211
- if (this.filterSubscription) {
20212
- this.filterSubscription.unsubscribe();
20213
- }
20214
- if (this.searchSubscription) {
20215
- this.searchSubscription.unsubscribe();
20216
- }
20217
- if (this.showMoreSubscription) {
20218
- this.showMoreSubscription.unsubscribe();
20219
- }
20220
- };
20221
- PoLookupModalBaseComponent.prototype.ngOnInit = function () {
20222
- this.setAdvancedFilterModalProperties();
20223
- this.initializeData();
20224
- this.setTableLiterals();
20225
- };
20226
- PoLookupModalBaseComponent.prototype.createDisclaimer = function () {
20227
- var e_1, _c;
20228
- this.disclaimerGroup.disclaimers = [];
20229
- this.searchValue = '';
20230
- try {
20231
- for (var _d = __values(Object.entries(this.dynamicFormValue)), _e = _d.next(); !_e.done; _e = _d.next()) {
20232
- var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
20233
- this.addDisclaimer(value, key);
20234
- }
20235
- }
20236
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
20237
- finally {
20238
- try {
20239
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
20240
- }
20241
- finally { if (e_1) throw e_1.error; }
20242
- }
20243
- if (!Object.values(this.dynamicFormValue).some(function (v) { return v !== null && typeof v !== 'undefined'; })) {
20244
- this.initializeData();
20245
- }
20246
- };
20247
- PoLookupModalBaseComponent.prototype.addDisclaimer = function (value, property) {
20248
- this.disclaimer = { property: property };
20249
- this.disclaimer.value = value;
20250
- this.disclaimerGroup.disclaimers = __spreadArray(__spreadArray([], __read(this.disclaimerGroup.disclaimers)), [this.disclaimer]);
20251
- };
20252
- PoLookupModalBaseComponent.prototype.onChangeDisclaimerGroup = function () {
20253
- if (!this.searchValue) {
20254
- this.isLoading = true;
20255
- this.searchValue = '';
20256
- this.searchFilteredItems();
20257
- }
20258
- };
20259
- PoLookupModalBaseComponent.prototype.search = function () {
20260
- this.page = 1;
20261
- if (this.searchValue) {
20262
- this.isLoading = true;
20263
- this.disclaimerGroup.disclaimers = [];
20264
- this.searchFilteredItems();
20265
- }
20266
- else {
20267
- this.initializeData();
20268
- }
20269
- };
20270
- PoLookupModalBaseComponent.prototype.searchFilteredItems = function () {
20271
- var _this = this;
20272
- this.searchSubscription = this.getFilteredItems(this.searchValue)
20273
- .pipe(operators.catchError(function (error) {
20274
- _this.setLookupResponseProperties();
20275
- return rxjs.throwError(error);
20276
- }))
20277
- .subscribe(function (data) { return _this.setLookupResponseProperties(data); }, function () { });
20278
- };
20279
- PoLookupModalBaseComponent.prototype.showMoreEvent = function () {
20280
- var _this = this;
20281
- this.page++;
20282
- this.isLoading = true;
20283
- this.showMoreSubscription = this.getFilteredItems(this.searchValue)
20284
- .pipe(operators.catchError(function (error) {
20285
- _this.hasNext = false;
20286
- _this.isLoading = false;
20287
- return rxjs.throwError(error);
20288
- }))
20289
- .subscribe(function (data) {
20290
- _this.items = __spreadArray(__spreadArray([], __read(_this.items)), __read(data.items));
20291
- _this.hasNext = data.hasNext;
20292
- _this.isLoading = false;
20293
- }, function () { });
20294
- };
20295
- PoLookupModalBaseComponent.prototype.setAdvancedFilterModalProperties = function () {
20296
- var _this = this;
20297
- this.advancedFilterModalTitle = this.literals.modalAdvancedSearchTitle;
20298
- this.disclaimerGroup = {
20299
- title: this.literals.modalDisclaimerGroupTitle,
20300
- disclaimers: []
20301
- };
20302
- this.primaryActionAdvancedFilter = {
20303
- action: function () {
20304
- _this.destroyDynamicForm();
20305
- _this.isAdvancedFilter = false;
20306
- _this.createDisclaimer();
20307
- },
20308
- label: this.literals.modalAdvancedSearchPrimaryActionLabel
20309
- };
20310
- this.secondaryActionAdvancedFilter = {
20311
- action: function () {
20312
- _this.destroyDynamicForm();
20313
- _this.isAdvancedFilter = false;
20314
- },
20315
- label: this.literals.modalAdvancedSearchSecondaryActionLabel
20316
- };
20317
- };
20318
- PoLookupModalBaseComponent.prototype.getAdvancedFilters = function (advancedParams) {
20319
- if (advancedParams && advancedParams.length > 0) {
20320
- var filters_1 = {};
20321
- var validatedAdvacendFilters_1;
20322
- advancedParams.forEach(function (filter) {
20323
- filters_1[filter.property] = filter.value instanceof Array ? filter.value.join() : filter.value;
20324
- validatedAdvacendFilters_1 = Object.assign(Object.assign({}, validatedAdvacendFilters_1), filters_1);
20325
- });
20326
- return validatedAdvacendFilters_1;
20327
- }
20328
- return undefined;
20329
- };
20330
- PoLookupModalBaseComponent.prototype.getFilteredItems = function (filter) {
20331
- var filteredParams = this.getFilteredParams(filter);
20332
- return this.filterService.getFilteredItems(filteredParams);
20333
- };
20334
- PoLookupModalBaseComponent.prototype.getFilteredParams = function (filter) {
20335
- var _c = this, page = _c.page, pageSize = _c.pageSize, filterParams = _c.filterParams, sort = _c.sort;
20336
- var filteredParams = {};
20337
- var order = this.getOrderParam(sort);
20338
- var advancedFilters = this.getAdvancedFilters(this.disclaimerGroup.disclaimers);
20339
- var params = { filter: filter, page: page, pageSize: pageSize, order: order, filterParams: filterParams, advancedFilters: advancedFilters };
20340
- for (var key in params) {
20341
- if (params.hasOwnProperty(key) && params[key] !== undefined) {
20342
- filteredParams[key] = params[key];
20343
- }
20344
- }
20345
- return filteredParams;
20346
- };
20347
- PoLookupModalBaseComponent.prototype.getOrderParam = function (sort) {
20348
- if (sort === void 0) { sort = { type: undefined }; }
20349
- var column = sort.column, type = sort.type;
20350
- if (!column) {
20351
- return;
20352
- }
20353
- if (type === exports.PoTableColumnSortType.Descending) {
20354
- return "-" + column.property;
20355
- }
20356
- return "" + column.property;
20357
- };
20358
- PoLookupModalBaseComponent.prototype.initializeData = function () {
20359
- var _this = this;
20360
- this.isLoading = true;
20361
- this.filterSubscription = this.getFilteredItems('').subscribe(function (data) {
20362
- _this.setLookupResponseProperties(data);
20363
- });
20364
- };
20365
- PoLookupModalBaseComponent.prototype.setLookupResponseProperties = function (data) {
20366
- var _a, _b;
20367
- this.items = (_a = data === null || data === void 0 ? void 0 : data.items) !== null && _a !== void 0 ? _a : [];
20368
- this.hasNext = (_b = data === null || data === void 0 ? void 0 : data.hasNext) !== null && _b !== void 0 ? _b : false;
20369
- this.isLoading = false;
20370
- };
20371
- PoLookupModalBaseComponent.prototype.setTableLiterals = function () {
20372
- this.tableLiterals = {
20373
- 'noColumns': this.literals.modalTableNoColumns,
20374
- 'noData': this.literals.modalTableNoData,
20375
- 'loadingData': this.literals.modalTableLoadingData,
20376
- 'loadMoreData': this.literals.modalTableLoadMoreData
20377
- };
20378
- };
20379
- return PoLookupModalBaseComponent;
20380
- }());
20381
- PoLookupModalBaseComponent.decorators = [
20382
- { type: i0.Directive }
20383
- ];
20384
- PoLookupModalBaseComponent.ctorParameters = function () { return [
20385
- { type: PoLanguageService }
20386
- ]; };
20387
- PoLookupModalBaseComponent.propDecorators = {
20388
- poModal: [{ type: i0.ViewChild, args: [PoModalComponent, { static: true },] }],
20389
- advancedFilters: [{ type: i0.Input, args: ['p-advanced-filters',] }],
20390
- columns: [{ type: i0.Input, args: ['p-columns',] }],
20391
- items: [{ type: i0.Input, args: ['p-items',] }],
20392
- filterService: [{ type: i0.Input, args: ['p-filter-service',] }],
20393
- filterParams: [{ type: i0.Input, args: ['p-filter-params',] }],
20394
- infiniteScroll: [{ type: i0.Input, args: ['p-infinite-scroll',] }],
20395
- model: [{ type: i0.Output, args: ['p-change-model',] }],
20396
- literals: [{ type: i0.Input, args: ['p-literals',] }],
20397
- title: [{ type: i0.Input, args: ['p-title',] }]
20398
- };
20399
- __decorate([
20400
- InputBoolean()
20401
- ], PoLookupModalBaseComponent.prototype, "infiniteScroll", void 0);
20402
-
20403
20689
  /**
20404
20690
  * @docsPrivate
20405
20691
  *
@@ -20407,8 +20693,8 @@
20407
20693
  */
20408
20694
  var PoLookupModalComponent = /** @class */ (function (_super) {
20409
20695
  __extends(PoLookupModalComponent, _super);
20410
- function PoLookupModalComponent(componentFactory, poLanguage) {
20411
- var _this = _super.call(this, poLanguage) || this;
20696
+ function PoLookupModalComponent(componentFactory, poLanguage, changeDetector) {
20697
+ var _this = _super.call(this, poLanguage, changeDetector) || this;
20412
20698
  _this.componentFactory = componentFactory;
20413
20699
  _this.keyUpObservable = null;
20414
20700
  _this.containerHeight = 375;
@@ -20421,6 +20707,34 @@
20421
20707
  PoLookupModalComponent.prototype.ngAfterViewInit = function () {
20422
20708
  this.initializeEventInput();
20423
20709
  };
20710
+ // Seleciona um item na tabela
20711
+ PoLookupModalComponent.prototype.onSelect = function (item) {
20712
+ if (this.multiple) {
20713
+ this.selecteds = __spreadArray(__spreadArray([], __read(this.selecteds)), [Object.assign({ value: item[this.fieldValue], label: item[this.fieldLabel] }, item)]);
20714
+ }
20715
+ else {
20716
+ this.selecteds = [Object.assign({ value: item[this.fieldValue], label: item[this.fieldLabel] }, item)];
20717
+ }
20718
+ };
20719
+ // Remove a seleção de um item na tabela
20720
+ PoLookupModalComponent.prototype.onUnselect = function (unselectedItem) {
20721
+ var _this = this;
20722
+ this.selecteds = this.selecteds.filter(function (itemSelected) { return itemSelected.value !== unselectedItem[_this.fieldValue]; });
20723
+ };
20724
+ PoLookupModalComponent.prototype.onUnselectFromDisclaimer = function (removedDisclaimer) {
20725
+ var _this = this;
20726
+ this.poTable.unselectRowItem(function (item) { return item[_this.fieldValue] === removedDisclaimer.value; });
20727
+ };
20728
+ // Seleciona todos os itens visíveis na tabela
20729
+ PoLookupModalComponent.prototype.onAllSelected = function (items) {
20730
+ var _this = this;
20731
+ this.selecteds = items.map(function (item) { return (Object.assign({ value: item[_this.fieldValue], label: item[_this.fieldLabel] }, item)); });
20732
+ };
20733
+ // Remove a seleção de todos os itens visíveis na tabela
20734
+ PoLookupModalComponent.prototype.onAllUnselected = function (items) {
20735
+ this.poTable.unselectRows();
20736
+ this.selecteds = [];
20737
+ };
20424
20738
  PoLookupModalComponent.prototype.initializeEventInput = function () {
20425
20739
  var _this = this;
20426
20740
  this.keyUpObservable = rxjs.fromEvent(this.inputSearchEl.nativeElement, 'keyup').pipe(operators.filter(function (e) { return _this.validateEnterPressed(e); }), operators.debounceTime(400));
@@ -20444,6 +20758,16 @@
20444
20758
  this.createDynamicForm();
20445
20759
  };
20446
20760
  PoLookupModalComponent.prototype.setTableHeight = function () {
20761
+ var _a;
20762
+ if (this.multiple) {
20763
+ if (((_a = this.selecteds) === null || _a === void 0 ? void 0 : _a.length) !== 0) {
20764
+ this.tableHeight = 300;
20765
+ }
20766
+ else {
20767
+ this.tableHeight = 370;
20768
+ this.containerHeight = 375;
20769
+ }
20770
+ }
20447
20771
  // precisa ser 315 por as linhas terem altura de 32px (quando tela menor que 1366px).
20448
20772
  // O retorno padrão é 10 itens fazendo com que gere scroll caso houver paginação, 370 não gerava.
20449
20773
  this.tableHeight = this.infiniteScroll ? 315 : 370;
@@ -20479,14 +20803,16 @@
20479
20803
  PoLookupModalComponent.decorators = [
20480
20804
  { type: i0.Component, args: [{
20481
20805
  selector: 'po-lookup-modal',
20482
- template: "<po-modal\n p-click-out=\"false\"\n p-hide-close=\"false\"\n p-size=\"lg\"\n [p-primary-action]=\"isAdvancedFilter ? primaryActionAdvancedFilter : primaryAction\"\n [p-secondary-action]=\"isAdvancedFilter ? secondaryActionAdvancedFilter : secondaryAction\"\n [p-title]=\"isAdvancedFilter ? advancedFilterModalTitle : title\"\n>\n <div [hidden]=\"isAdvancedFilter\">\n <po-field-container class=\"po-lookup-header po-pull-right\" [p-optional]=\"false\">\n <div class=\"po-lookup-filter-content\">\n <div class=\"po-field-icon-container-right\">\n <span #iconLookup class=\"po-icon po-field-icon po-icon-search\" (click)=\"search()\"> </span>\n </div>\n\n <input\n #inpsearch\n class=\"po-input po-input-icon-right\"\n name=\"contentSearch\"\n [(ngModel)]=\"searchValue\"\n [placeholder]=\"literals.modalPlaceholder\"\n type=\"text\"\n />\n </div>\n\n <div *ngIf=\"advancedFilters && advancedFilters.length > 0\" class=\"po-lookup-advanced-search\">\n <span\n class=\"po-lookup-advanced-search-link\"\n tabindex=\"0\"\n (click)=\"onAdvancedFilter()\"\n (keydown.enter)=\"onAdvancedFilter()\"\n tabindex=\"0\"\n >\n {{ literals.modalAdvancedSearch }}\n </span>\n </div>\n </po-field-container>\n\n <!-- DISCLAIMER -->\n <po-disclaimer-group\n class=\"po-md-12\"\n *ngIf=\"!!disclaimerGroup\"\n [p-disclaimers]=\"disclaimerGroup?.disclaimers\"\n [p-title]=\"disclaimerGroup?.title\"\n (p-change)=\"onChangeDisclaimerGroup()\"\n >\n </po-disclaimer-group>\n\n <div class=\"po-row po-lookup-container-table\" [style.height.px]=\"containerHeight\">\n <po-table\n class=\"po-md-12\"\n [p-selectable]=\"true\"\n [p-hide-detail]=\"true\"\n [p-single-select]=\"true\"\n [p-sort]=\"true\"\n [p-columns]=\"columns\"\n [p-height]=\"tableHeight\"\n [p-items]=\"items\"\n [p-literals]=\"tableLiterals\"\n [p-loading]=\"isLoading\"\n [p-show-more-disabled]=\"!hasNext\"\n [p-infinite-scroll]=\"infiniteScroll\"\n (p-show-more)=\"showMoreEvent()\"\n (p-sort-by)=\"sortBy($event)\"\n >\n </po-table>\n </div>\n </div>\n <div [hidden]=\"!isAdvancedFilter\">\n <ng-container #container> </ng-container>\n </div>\n</po-modal>\n"
20806
+ template: "<po-modal\n p-click-out=\"false\"\n p-hide-close=\"false\"\n p-size=\"lg\"\n [p-primary-action]=\"isAdvancedFilter ? primaryActionAdvancedFilter : primaryAction\"\n [p-secondary-action]=\"isAdvancedFilter ? secondaryActionAdvancedFilter : secondaryAction\"\n [p-title]=\"isAdvancedFilter ? advancedFilterModalTitle : title\"\n>\n <div [hidden]=\"isAdvancedFilter\">\n <po-field-container class=\"po-lookup-header po-pull-right\" [p-optional]=\"false\">\n <div class=\"po-lookup-filter-content\">\n <div class=\"po-field-icon-container-right\">\n <span #iconLookup class=\"po-icon po-field-icon po-icon-search\" (click)=\"search()\"> </span>\n </div>\n\n <input\n #inpsearch\n class=\"po-input po-input-icon-right\"\n name=\"contentSearch\"\n [(ngModel)]=\"searchValue\"\n [placeholder]=\"literals.modalPlaceholder\"\n type=\"text\"\n />\n </div>\n\n <div *ngIf=\"advancedFilters && advancedFilters.length > 0\" class=\"po-lookup-advanced-search\">\n <span\n class=\"po-lookup-advanced-search-link\"\n tabindex=\"0\"\n (click)=\"onAdvancedFilter()\"\n (keydown.enter)=\"onAdvancedFilter()\"\n tabindex=\"0\"\n >\n {{ literals.modalAdvancedSearch }}\n </span>\n </div>\n </po-field-container>\n\n <!-- DISCLAIMER -->\n <po-disclaimer-group\n *ngIf=\"!!disclaimerGroup\"\n class=\"po-md-12\"\n [p-disclaimers]=\"disclaimerGroup?.disclaimers\"\n [p-title]=\"disclaimerGroup?.title\"\n (p-change)=\"onChangeDisclaimerGroup()\"\n >\n </po-disclaimer-group>\n\n <div class=\"po-row po-lookup-container-table\" [style.height.px]=\"containerHeight\">\n <po-table\n #poTable\n class=\"po-md-12\"\n [p-selectable]=\"true\"\n [p-hide-detail]=\"true\"\n [p-single-select]=\"!multiple\"\n [p-sort]=\"true\"\n [p-columns]=\"columns\"\n [p-height]=\"tableHeight\"\n [p-items]=\"items\"\n [p-literals]=\"tableLiterals\"\n [p-loading]=\"isLoading\"\n [p-show-more-disabled]=\"!hasNext\"\n [p-infinite-scroll]=\"infiniteScroll\"\n (p-selected)=\"onSelect($event)\"\n (p-unselected)=\"onUnselect($event)\"\n (p-all-selected)=\"onAllSelected($event)\"\n (p-all-unselected)=\"onAllUnselected($event)\"\n (p-show-more)=\"showMoreEvent()\"\n (p-sort-by)=\"sortBy($event)\"\n >\n </po-table>\n </div>\n\n <!-- DISCLAIMER -->\n <po-disclaimer-group\n *ngIf=\"multiple\"\n class=\"po-md-12\"\n [p-disclaimers]=\"selecteds\"\n (p-remove)=\"onUnselectFromDisclaimer($event.removedDisclaimer)\"\n (p-remove-all)=\"onAllUnselected($event)\"\n >\n </po-disclaimer-group>\n </div>\n <div [hidden]=\"!isAdvancedFilter\">\n <ng-container #container> </ng-container>\n </div>\n</po-modal>\n"
20483
20807
  },] }
20484
20808
  ];
20485
20809
  PoLookupModalComponent.ctorParameters = function () { return [
20486
20810
  { type: i0.ComponentFactoryResolver },
20487
- { type: PoLanguageService }
20811
+ { type: PoLanguageService },
20812
+ { type: i0.ChangeDetectorRef }
20488
20813
  ]; };
20489
20814
  PoLookupModalComponent.propDecorators = {
20815
+ poTable: [{ type: i0.ViewChild, args: [PoTableComponent, { static: true },] }],
20490
20816
  inputSearchEl: [{ type: i0.ViewChild, args: ['inpsearch',] }],
20491
20817
  container: [{ type: i0.ViewChild, args: ['container', { read: i0.ViewContainerRef },] }]
20492
20818
  };
@@ -20511,10 +20837,13 @@
20511
20837
  * @param filterParams {any} Valor que será repassado aos métodos do serviço para auxiliar no filtro dos dados.
20512
20838
  * @param title {string} Definição do título da modal.
20513
20839
  * @param literals {PoLookupLiterals} Literais utilizadas no componente.
20840
+ * @param selectedItems {any} Valor que está selecionado que será repassado para o modal para apresentar na tabela.
20841
+ * @param fieldLabel {string} Valor que será utilizado como descrição do campo.
20842
+ * @param fieldValue {string} Valor que será utilizado como valor do campo.
20514
20843
  */
20515
20844
  PoLookupModalService.prototype.openModal = function (params) {
20516
20845
  var _this = this;
20517
- var advancedFilters = params.advancedFilters, service = params.service, columns = params.columns, filterParams = params.filterParams, title = params.title, literals = params.literals, infiniteScroll = params.infiniteScroll;
20846
+ var advancedFilters = params.advancedFilters, service = params.service, columns = params.columns, filterParams = params.filterParams, title = params.title, literals = params.literals, infiniteScroll = params.infiniteScroll, multiple = params.multiple, selectedItems = params.selectedItems, fieldLabel = params.fieldLabel, fieldValue = params.fieldValue;
20518
20847
  this.componentRef = this.poComponentInjector.createComponentInApplication(PoLookupModalComponent);
20519
20848
  this.componentRef.instance.advancedFilters = advancedFilters;
20520
20849
  this.componentRef.instance.title = title;
@@ -20526,6 +20855,10 @@
20526
20855
  _this.selectValue($event);
20527
20856
  });
20528
20857
  this.componentRef.instance.infiniteScroll = infiniteScroll;
20858
+ this.componentRef.instance.multiple = multiple;
20859
+ this.componentRef.instance.selectedItems = selectedItems;
20860
+ this.componentRef.instance.fieldLabel = fieldLabel;
20861
+ this.componentRef.instance.fieldValue = fieldValue;
20529
20862
  this.componentRef.changeDetectorRef.detectChanges();
20530
20863
  this.componentRef.instance.openModal();
20531
20864
  };
@@ -20612,12 +20945,24 @@
20612
20945
  * <file name="sample-po-lookup-sw-films/sample-po-lookup-sw-films.component.ts"> </file>
20613
20946
  * <file name="sample-po-lookup-sw-films/sample-po-lookup-sw-films.service.ts"> </file>
20614
20947
  * </example>
20948
+ *
20949
+ * <example name="po-lookup-multiple" title="PO Lookup - Multiple">
20950
+ * <file name="sample-po-lookup-multiple/sample-po-lookup-multiple.component.html"> </file>
20951
+ * <file name="sample-po-lookup-multiple/sample-po-lookup-multiple.component.ts"> </file>
20952
+ * <file name="sample-po-lookup-multiple/sample-po-lookup-multiple.service.ts"> </file>
20953
+ * </example>
20615
20954
  */
20616
20955
  var PoLookupComponent = /** @class */ (function (_super) {
20617
20956
  __extends(PoLookupComponent, _super);
20618
- function PoLookupComponent(poLookupFilterService, poLookupModalService, injector) {
20957
+ function PoLookupComponent(renderer, poLookupFilterService, poLookupModalService, injector) {
20619
20958
  var _this = _super.call(this, poLookupFilterService, injector) || this;
20959
+ _this.renderer = renderer;
20620
20960
  _this.poLookupModalService = poLookupModalService;
20961
+ _this.initialized = false;
20962
+ _this.visibleElement = false;
20963
+ _this.disclaimers = [];
20964
+ _this.visibleDisclaimers = [];
20965
+ _this.isCalculateVisibleItems = true;
20621
20966
  return _this;
20622
20967
  }
20623
20968
  Object.defineProperty(PoLookupComponent.prototype, "autocomplete", {
@@ -20632,6 +20977,17 @@
20632
20977
  if (this.autoFocus) {
20633
20978
  this.focus();
20634
20979
  }
20980
+ this.initialized = true;
20981
+ };
20982
+ PoLookupComponent.prototype.ngDoCheck = function () {
20983
+ var _a;
20984
+ var inputWidth = (_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.nativeElement.offsetWidth;
20985
+ // Permite que os disclaimers sejam calculados na primeira vez que o componente torna-se visível,
20986
+ // evitando com isso, problemas com Tabs ou Divs que iniciem escondidas.
20987
+ if ((inputWidth && !this.visibleElement && this.initialized) || (inputWidth && this.isCalculateVisibleItems)) {
20988
+ this.debounceResize();
20989
+ this.visibleElement = true;
20990
+ }
20635
20991
  };
20636
20992
  PoLookupComponent.prototype.ngOnDestroy = function () {
20637
20993
  if (this.modalSubscription) {
@@ -20640,6 +20996,7 @@
20640
20996
  };
20641
20997
  PoLookupComponent.prototype.ngOnInit = function () {
20642
20998
  _super.prototype.ngOnInit.call(this);
20999
+ this.initializeListeners();
20643
21000
  };
20644
21001
  /**
20645
21002
  * Função que atribui foco ao componente.
@@ -20666,7 +21023,8 @@
20666
21023
  PoLookupComponent.prototype.openLookup = function () {
20667
21024
  var _this = this;
20668
21025
  if (this.isAllowedOpenModal()) {
20669
- var _b = this, advancedFilters = _b.advancedFilters, service = _b.service, columns = _b.columns, filterParams = _b.filterParams, literals = _b.literals, infiniteScroll = _b.infiniteScroll;
21026
+ var _c = this, advancedFilters = _c.advancedFilters, service = _c.service, columns = _c.columns, filterParams = _c.filterParams, literals = _c.literals, infiniteScroll = _c.infiniteScroll, multiple = _c.multiple, fieldLabel = _c.fieldLabel, fieldValue = _c.fieldValue;
21027
+ var selectedItems = this.checkSelectedItems();
20670
21028
  this.poLookupModalService.openModal({
20671
21029
  advancedFilters: advancedFilters,
20672
21030
  service: service,
@@ -20674,20 +21032,45 @@
20674
21032
  filterParams: filterParams,
20675
21033
  title: this.label,
20676
21034
  literals: literals,
20677
- infiniteScroll: infiniteScroll
21035
+ infiniteScroll: infiniteScroll,
21036
+ multiple: multiple,
21037
+ selectedItems: selectedItems,
21038
+ fieldLabel: fieldLabel,
21039
+ fieldValue: fieldValue
20678
21040
  });
20679
21041
  if (!this.modalSubscription) {
20680
- this.modalSubscription = this.poLookupModalService.selectValueEvent.subscribe(function (element) {
20681
- _this.selectModel(element);
21042
+ this.modalSubscription = this.poLookupModalService.selectValueEvent.subscribe(function (selectedOptions) {
21043
+ if (selectedOptions.length > 1 || _this.disclaimers.length) {
21044
+ _this.setDisclaimers(selectedOptions);
21045
+ _this.updateVisibleItems();
21046
+ }
21047
+ _this.selectModel(selectedOptions);
20682
21048
  });
20683
21049
  }
20684
21050
  }
20685
21051
  };
21052
+ PoLookupComponent.prototype.checkSelectedItems = function () {
21053
+ var _a;
21054
+ if (this.multiple) {
21055
+ if (!this.disclaimers.length && ((_a = this.valueToModel) === null || _a === void 0 ? void 0 : _a.length)) {
21056
+ return [Object.assign({ value: this.valueToModel[0], label: this.oldValue }, this.selectedOptions[0])];
21057
+ }
21058
+ return this.disclaimers;
21059
+ }
21060
+ else {
21061
+ return this.valueToModel;
21062
+ }
21063
+ };
21064
+ PoLookupComponent.prototype.setDisclaimers = function (selectedOptions) {
21065
+ var _this = this;
21066
+ this.disclaimers = selectedOptions.map(function (selectedOption) { return (Object.assign({ value: selectedOption[_this.fieldValue], label: selectedOption[_this.fieldLabel] }, selectedOption)); });
21067
+ this.visibleDisclaimers = __spreadArray([], __read(this.disclaimers));
21068
+ };
20686
21069
  PoLookupComponent.prototype.setViewValue = function (value, object) {
20687
- if (this.fieldFormat) {
21070
+ if (this.inputEl && this.fieldFormat) {
20688
21071
  this.setInputValueWipoieldFormat(object);
20689
21072
  }
20690
- else {
21073
+ else if (this.inputEl) {
20691
21074
  this.inputEl.nativeElement.value = this.valueToModel || this.valueToModel === 0 ? value : '';
20692
21075
  }
20693
21076
  };
@@ -20695,13 +21078,82 @@
20695
21078
  return this.inputEl.nativeElement.value;
20696
21079
  };
20697
21080
  PoLookupComponent.prototype.searchEvent = function () {
20698
- var _a;
21081
+ var _a, _b;
20699
21082
  (_a = this.onTouched) === null || _a === void 0 ? void 0 : _a.call(this);
20700
21083
  var value = this.getViewValue();
20701
- if (this.oldValue.toString() !== value) {
21084
+ if (((_b = this.oldValue) === null || _b === void 0 ? void 0 : _b.toString()) !== value) {
20702
21085
  this.searchById(value);
20703
21086
  }
20704
21087
  };
21088
+ PoLookupComponent.prototype.closeDisclaimer = function (value) {
21089
+ this.disclaimers = this.disclaimers.filter(function (disclaimer) { return disclaimer.value !== value; });
21090
+ this.valueToModel = this.valueToModel.filter(function (model) { return model !== value; });
21091
+ this.updateVisibleItems();
21092
+ this.callOnChange(this.valueToModel.length ? this.valueToModel : undefined);
21093
+ };
21094
+ PoLookupComponent.prototype.updateVisibleItems = function () {
21095
+ if (this.disclaimers && this.disclaimers.length > 0) {
21096
+ this.visibleDisclaimers = [].concat(this.disclaimers);
21097
+ }
21098
+ this.debounceResize();
21099
+ if (!this.inputEl.nativeElement.offsetWidth) {
21100
+ this.isCalculateVisibleItems = true;
21101
+ }
21102
+ };
21103
+ PoLookupComponent.prototype.debounceResize = function () {
21104
+ var _this = this;
21105
+ if (!this.autoHeight) {
21106
+ clearTimeout(this.timeoutResize);
21107
+ this.timeoutResize = setTimeout(function () {
21108
+ _this.calculateVisibleItems();
21109
+ }, 200);
21110
+ }
21111
+ };
21112
+ PoLookupComponent.prototype.getInputWidth = function () {
21113
+ return this.inputEl.nativeElement.offsetWidth - 40;
21114
+ };
21115
+ PoLookupComponent.prototype.getDisclaimersWidth = function () {
21116
+ var disclaimers = this.inputEl.nativeElement.querySelectorAll('po-disclaimer');
21117
+ return Array.from(disclaimers).map(function (disclaimer) { return disclaimer['offsetWidth']; });
21118
+ };
21119
+ PoLookupComponent.prototype.calculateVisibleItems = function () {
21120
+ var disclaimersWidth = this.getDisclaimersWidth();
21121
+ var inputWidth = this.getInputWidth();
21122
+ var extraDisclaimerSize = 38;
21123
+ var disclaimersVisible = disclaimersWidth[0];
21124
+ var newDisclaimers = [];
21125
+ var disclaimers = this.disclaimers;
21126
+ if (inputWidth > 0) {
21127
+ var sum = 0;
21128
+ var i = 0;
21129
+ for (i = 0; i < disclaimers.length; i++) {
21130
+ sum += disclaimersWidth[i];
21131
+ newDisclaimers.push(disclaimers[i]);
21132
+ if (sum > inputWidth) {
21133
+ sum -= disclaimersWidth[i];
21134
+ this.isCalculateVisibleItems = false;
21135
+ break;
21136
+ }
21137
+ }
21138
+ if (disclaimersVisible || !disclaimers.length) {
21139
+ if (i === disclaimers.length) {
21140
+ this.isCalculateVisibleItems = false;
21141
+ return;
21142
+ }
21143
+ if (sum + extraDisclaimerSize > inputWidth) {
21144
+ newDisclaimers.splice(-2, 2);
21145
+ var label = '+' + (disclaimers.length + 1 - i).toString();
21146
+ newDisclaimers.push({ value: '', label: label });
21147
+ }
21148
+ else {
21149
+ newDisclaimers.splice(-1, 1);
21150
+ var label = '+' + (disclaimers.length - i).toString();
21151
+ newDisclaimers.push({ value: '', label: label });
21152
+ }
21153
+ }
21154
+ }
21155
+ this.visibleDisclaimers = __spreadArray([], __read(newDisclaimers));
21156
+ };
20705
21157
  PoLookupComponent.prototype.isAllowedOpenModal = function () {
20706
21158
  if (!this.service) {
20707
21159
  console.warn('No service informed');
@@ -20709,7 +21161,7 @@
20709
21161
  return !!(this.service && !this.disabled);
20710
21162
  };
20711
21163
  PoLookupComponent.prototype.formatFields = function (objectSelected, properties) {
20712
- var e_1, _b;
21164
+ var e_1, _c;
20713
21165
  var formatedField;
20714
21166
  if (Array.isArray(properties)) {
20715
21167
  try {
@@ -20728,7 +21180,7 @@
20728
21180
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
20729
21181
  finally {
20730
21182
  try {
20731
- if (properties_1_1 && !properties_1_1.done && (_b = properties_1.return)) _b.call(properties_1);
21183
+ if (properties_1_1 && !properties_1_1.done && (_c = properties_1.return)) _c.call(properties_1);
20732
21184
  }
20733
21185
  finally { if (e_1) throw e_1.error; }
20734
21186
  }
@@ -20750,22 +21202,29 @@
20750
21202
  this.oldValue = isEmpty ? '' : fieldFormated;
20751
21203
  this.inputEl.nativeElement.value = isEmpty ? '' : fieldFormated;
20752
21204
  };
21205
+ PoLookupComponent.prototype.initializeListeners = function () {
21206
+ var _this = this;
21207
+ this.resizeListener = this.renderer.listen('window', 'resize', function () {
21208
+ _this.updateVisibleItems();
21209
+ });
21210
+ };
20753
21211
  return PoLookupComponent;
20754
21212
  }(PoLookupBaseComponent));
20755
21213
  PoLookupComponent.decorators = [
20756
21214
  { type: i0.Component, args: [{
20757
21215
  selector: 'po-lookup',
20758
- template: "<po-field-container [p-label]=\"label\" [p-help]=\"help\" [p-optional]=\"!required && optional\">\n <div class=\"po-field-container-content\">\n <input\n #inp\n class=\"po-input po-input-icon-right\"\n type=\"text\"\n [autocomplete]=\"autocomplete\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [required]=\"required\"\n (blur)=\"searchEvent()\"\n />\n\n <div class=\"po-field-icon-container-right\">\n <span\n #iconLookup\n class=\"po-icon po-field-icon po-icon-search\"\n tabindex=\"-1\"\n [class.po-field-icon]=\"!disabled\"\n [class.po-field-icon-disabled]=\"disabled\"\n (click)=\"openLookup()\"\n (focus)=\"inp.focus()\"\n >\n </span>\n </div>\n </div>\n\n <po-field-container-bottom></po-field-container-bottom>\n</po-field-container>\n",
21216
+ template: "<po-field-container [p-label]=\"label\" [p-help]=\"help\" [p-optional]=\"!required && optional\">\n <div class=\"po-field-container-content\" *ngIf=\"!disclaimers.length; else disclaimersTemplate\">\n <input\n #inp\n class=\"po-input\"\n type=\"text\"\n [ngClass]=\"clean && inp.value ? 'po-input-double-icon-right' : 'po-input-icon-right'\"\n [autocomplete]=\"autocomplete\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [required]=\"required\"\n (blur)=\"searchEvent()\"\n />\n\n <div class=\"po-field-icon-container-right\">\n <po-clean *ngIf=\"clean && !disabled\" [p-element-ref]=\"inputEl\" (p-change-event)=\"cleanModel()\"> </po-clean>\n\n <span\n #iconLookup\n class=\"po-icon po-field-icon po-icon-search\"\n tabindex=\"-1\"\n [class.po-field-icon]=\"!disabled\"\n [class.po-field-icon-disabled]=\"disabled\"\n (click)=\"openLookup()\"\n (focus)=\"inp.focus()\"\n >\n </span>\n </div>\n </div>\n <po-field-container-bottom></po-field-container-bottom>\n</po-field-container>\n\n<ng-template #disclaimersTemplate>\n <div class=\"po-field-container-content\">\n <div\n #inp\n [tabindex]=\"disabled ? -1 : 0\"\n class=\"po-input po-input-icon-right po-lookup-input\"\n [class.po-lookup-input-auto]=\"autoHeight\"\n [class.po-lookup-input-static]=\"!autoHeight\"\n [class.po-lookup-input-disabled]=\"disabled\"\n >\n <span *ngIf=\"placeholder && !disclaimers?.length\" class=\"po-lookup-input-placeholder\">\n {{ placeholder }}\n </span>\n\n <po-disclaimer\n *ngFor=\"let disclaimer of visibleDisclaimers\"\n class=\"po-lookup-input-disclaimer\"\n [p-label]=\"disclaimer.label\"\n [p-value]=\"disclaimer.value\"\n [p-hide-close]=\"disclaimer.value === '' || disabled\"\n [class.po-clickable]=\"disclaimer.value === '' && !disabled\"\n (p-close-action)=\"closeDisclaimer(disclaimer.value)\"\n >\n </po-disclaimer>\n </div>\n\n <div class=\"po-field-icon-container-right\">\n <span\n #iconLookup\n class=\"po-icon po-field-icon po-icon-search\"\n tabindex=\"-1\"\n [class.po-field-icon]=\"!disabled\"\n [class.po-field-icon-disabled]=\"disabled\"\n (click)=\"openLookup()\"\n (focus)=\"inp.focus()\"\n >\n </span>\n </div>\n </div>\n</ng-template>\n",
20759
21217
  providers: providers$2
20760
21218
  },] }
20761
21219
  ];
20762
21220
  PoLookupComponent.ctorParameters = function () { return [
21221
+ { type: i0.Renderer2 },
20763
21222
  { type: PoLookupFilterService },
20764
21223
  { type: PoLookupModalService },
20765
21224
  { type: i0.Injector }
20766
21225
  ]; };
20767
21226
  PoLookupComponent.propDecorators = {
20768
- inputEl: [{ type: i0.ViewChild, args: ['inp', { read: i0.ElementRef, static: true },] }]
21227
+ inputEl: [{ type: i0.ViewChild, args: ['inp', { read: i0.ElementRef, static: false },] }]
20769
21228
  };
20770
21229
 
20771
21230
  /**
@@ -23572,8 +24031,8 @@
23572
24031
  var PoPasswordComponent = /** @class */ (function (_super) {
23573
24032
  __extends(PoPasswordComponent, _super);
23574
24033
  /* istanbul ignore next */
23575
- function PoPasswordComponent(el) {
23576
- var _this = _super.call(this, el) || this;
24034
+ function PoPasswordComponent(el, cd) {
24035
+ var _this = _super.call(this, el, cd) || this;
23577
24036
  _this.type = 'password';
23578
24037
  _this.visiblePassword = false;
23579
24038
  _this._hidePasswordPeek = false;
@@ -23622,6 +24081,7 @@
23622
24081
  { type: i0.Component, args: [{
23623
24082
  selector: 'po-password',
23624
24083
  template: "<po-field-container [p-label]=\"label\" [p-help]=\"help\" [p-optional]=\"!required && optional\">\n <div class=\"po-field-container-content\">\n <div class=\"po-field-icon-container-left\">\n <span class=\"po-icon po-field-icon po-icon-lock\" [class.po-field-icon-disabled]=\"disabled\"> </span>\n </div>\n\n <input\n #inp\n class=\"po-input po-input-icon-left\"\n [attr.name]=\"name\"\n [autocomplete]=\"autocomplete\"\n [class.po-input-double-icon-right]=\"clean && inp.value && !hidePasswordPeek\"\n [class.po-input-icon-right]=\"clean || !hidePasswordPeek\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n [type]=\"disabled ? 'password' : type\"\n (blur)=\"eventOnBlur($event)\"\n (click)=\"eventOnClick($event)\"\n (focus)=\"eventOnFocus($event)\"\n (input)=\"eventOnInput($event)\"\n />\n\n <div class=\"po-field-icon-container-right\">\n <po-clean *ngIf=\"clean && !disabled && !readonly\" [p-element-ref]=\"inputEl\" (p-change-event)=\"clear($event)\">\n </po-clean>\n\n <span\n *ngIf=\"!hidePasswordPeek && !disabled\"\n class=\"po-icon po-field-icon\"\n [ngClass]=\"visiblePassword ? 'po-icon-eye' : 'po-icon-eye-off po-field-icon-disabled'\"\n (click)=\"showPassword()\"\n >\n </span>\n </div>\n </div>\n\n <po-field-container-bottom [p-error-pattern]=\"getErrorPattern()\"> </po-field-container-bottom>\n</po-field-container>\n",
24084
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
23625
24085
  providers: [
23626
24086
  {
23627
24087
  provide: forms.NG_VALUE_ACCESSOR,
@@ -23637,7 +24097,8 @@
23637
24097
  },] }
23638
24098
  ];
23639
24099
  PoPasswordComponent.ctorParameters = function () { return [
23640
- { type: i0.ElementRef }
24100
+ { type: i0.ElementRef },
24101
+ { type: i0.ChangeDetectorRef }
23641
24102
  ]; };
23642
24103
  PoPasswordComponent.propDecorators = {
23643
24104
  hidePasswordPeek: [{ type: i0.Input, args: ['p-hide-password-peek',] }]
@@ -24512,37 +24973,8 @@
24512
24973
  onKeydown: [{ type: i0.HostListener, args: ['keydown', ['$event'],] }]
24513
24974
  };
24514
24975
 
24515
- /**
24516
- * @usedBy PoSwitchComponent
24517
- *
24518
- * @description
24519
- *
24520
- * Enum para posicionar o label do valor do po-switch.
24521
- */
24522
- exports.PoSwitchLabelPosition = void 0;
24523
- (function (PoSwitchLabelPosition) {
24524
- /** Posiciona o label do lado esquerdo do switch. */
24525
- PoSwitchLabelPosition[PoSwitchLabelPosition["Right"] = 0] = "Right";
24526
- /** Posiciona o label do lado direito do switch. */
24527
- PoSwitchLabelPosition[PoSwitchLabelPosition["Left"] = 1] = "Left";
24528
- })(exports.PoSwitchLabelPosition || (exports.PoSwitchLabelPosition = {}));
24529
-
24530
- /**
24531
- * @description
24532
- *
24533
- * O componente `po-switch` é um [checkbox](/documentation/po-checkbox-group) mais intuitivo, pois faz analogia a um interruptor.
24534
- * Deve ser usado quando deseja-se transmitir a ideia de ligar / desligar uma funcionalidade específica.
24535
- *
24536
- * Pode-se ligar ou deligar o botão utilizando a tecla de espaço ou o clique do mouse.
24537
- *
24538
- * O texto exibido pode ser alterado de acordo com o valor setado aumentando as possibilidades de uso do componente,
24539
- * portanto, recomenda-se informar textos que contextualizem seu uso para que facilite a compreensão do usuário.
24540
- *
24541
- * > O componente não altera o valor incial informado no *model*, portanto indica-se inicializa-lo caso ter necessidade.
24542
- */
24543
- var PoSwitchBaseComponent = /** @class */ (function () {
24544
- function PoSwitchBaseComponent(changeDetector) {
24545
- this.changeDetector = changeDetector;
24976
+ var PoFieldModel = /** @class */ (function () {
24977
+ function PoFieldModel() {
24546
24978
  /**
24547
24979
  * @optional
24548
24980
  *
@@ -24560,145 +24992,89 @@
24560
24992
  *
24561
24993
  * @description
24562
24994
  *
24563
- * Evento disparado ao alterar valor do campo.
24564
- */
24565
- this.change = new i0.EventEmitter();
24566
- /**
24567
- * @optional
24568
- *
24569
- * @description
24570
- *
24571
- * Função para atualizar o ngModel do componente, necessário quando não for utilizado dentro da tag form.
24572
- */
24573
- this.ngModelChange = new i0.EventEmitter();
24574
- this.switchValue = false;
24575
- this._disabled = false;
24576
- /**
24577
- * Texto exibido quando o valor do componente for `true`.
24578
- *
24579
- * @default `true`
24580
- */
24581
- // eslint-disable-next-line @typescript-eslint/member-ordering
24582
- this.labelOn = 'true';
24583
- /**
24584
- * Texto exibido quando o valor do componente for `false`.
24995
+ * Indica se o campo será desabilitado.
24585
24996
  *
24586
24997
  * @default `false`
24587
24998
  */
24588
- // eslint-disable-next-line @typescript-eslint/member-ordering
24589
- this.labelOff = 'false';
24999
+ this.disabled = false;
24590
25000
  /**
24591
25001
  * @optional
24592
25002
  *
24593
25003
  * @description
24594
25004
  *
24595
- * Posição de exibição do rótulo.
24596
- *
24597
- * > Por padrão exibe à direita.
25005
+ * Evento disparado ao alterar valor do campo.
24598
25006
  */
24599
- // eslint-disable-next-line @typescript-eslint/member-ordering
24600
- this.labelPosition = exports.PoSwitchLabelPosition.Right;
25007
+ this.change = new i0.EventEmitter();
24601
25008
  }
24602
- Object.defineProperty(PoSwitchBaseComponent.prototype, "setLabelOn", {
24603
- set: function (label) {
24604
- this.labelOn = label || 'true';
24605
- },
24606
- enumerable: false,
24607
- configurable: true
24608
- });
24609
- Object.defineProperty(PoSwitchBaseComponent.prototype, "setLabelOff", {
24610
- set: function (label) {
24611
- this.labelOff = label || 'false';
24612
- },
24613
- enumerable: false,
24614
- configurable: true
24615
- });
24616
- Object.defineProperty(PoSwitchBaseComponent.prototype, "setLabelPosition", {
24617
- set: function (position) {
24618
- this.labelPosition = position in exports.PoSwitchLabelPosition ? parseInt(position, 10) : exports.PoSwitchLabelPosition.Right;
24619
- },
24620
- enumerable: false,
24621
- configurable: true
24622
- });
24623
- Object.defineProperty(PoSwitchBaseComponent.prototype, "disabled", {
24624
- get: function () {
24625
- return this._disabled;
24626
- },
24627
- /**
24628
- * @optional
24629
- *
24630
- * @description
24631
- *
24632
- * Indica se o campo será desabilitado.
24633
- *
24634
- * @default `false`
24635
- */
24636
- set: function (disabled) {
24637
- this._disabled = convertToBoolean(disabled);
24638
- },
24639
- enumerable: false,
24640
- configurable: true
24641
- });
24642
- PoSwitchBaseComponent.prototype.changeValue = function (value) {
24643
- if (this.switchValue !== value) {
24644
- this.switchValue = value;
24645
- if (this.propagateChange) {
24646
- this.propagateChange(value);
24647
- }
24648
- else {
24649
- this.ngModelChange.emit(value);
24650
- }
24651
- this.change.emit(this.switchValue);
24652
- }
24653
- };
24654
- PoSwitchBaseComponent.prototype.eventClick = function () {
24655
- if (!this.disabled) {
24656
- this.changeValue(!this.switchValue);
24657
- }
24658
- };
24659
25009
  // Função implementada do ControlValueAccessor
24660
25010
  // Usada para interceptar os estados de habilitado via forms api
24661
- PoSwitchBaseComponent.prototype.setDisabledState = function (isDisabled) {
25011
+ PoFieldModel.prototype.setDisabledState = function (isDisabled) {
24662
25012
  this.disabled = isDisabled;
24663
25013
  };
24664
- PoSwitchBaseComponent.prototype.registerOnChange = function (fn) {
25014
+ PoFieldModel.prototype.registerOnChange = function (fn) {
24665
25015
  this.propagateChange = fn;
24666
25016
  };
24667
- PoSwitchBaseComponent.prototype.registerOnTouched = function (fn) {
25017
+ PoFieldModel.prototype.registerOnTouched = function (fn) {
24668
25018
  this.onTouched = fn;
24669
25019
  };
24670
- PoSwitchBaseComponent.prototype.writeValue = function (value) {
24671
- if (value !== this.switchValue) {
24672
- this.switchValue = !!value;
24673
- this.changeDetector.markForCheck();
25020
+ PoFieldModel.prototype.writeValue = function (value) {
25021
+ this.onWriteValue(value);
25022
+ };
25023
+ PoFieldModel.prototype.updateModel = function (value) {
25024
+ if (this.propagateChange) {
25025
+ this.propagateChange(value);
24674
25026
  }
24675
25027
  };
24676
- return PoSwitchBaseComponent;
25028
+ return PoFieldModel;
24677
25029
  }());
24678
- PoSwitchBaseComponent.decorators = [
25030
+ PoFieldModel.decorators = [
24679
25031
  { type: i0.Directive }
24680
25032
  ];
24681
- PoSwitchBaseComponent.ctorParameters = function () { return [
24682
- { type: i0.ChangeDetectorRef }
24683
- ]; };
24684
- PoSwitchBaseComponent.propDecorators = {
24685
- name: [{ type: i0.Input, args: ['name',] }],
24686
- autoFocus: [{ type: i0.Input, args: ['p-auto-focus',] }],
25033
+ PoFieldModel.ctorParameters = function () { return []; };
25034
+ PoFieldModel.propDecorators = {
24687
25035
  label: [{ type: i0.Input, args: ['p-label',] }],
25036
+ name: [{ type: i0.Input, args: ['name',] }],
24688
25037
  help: [{ type: i0.Input, args: ['p-help',] }],
24689
- change: [{ type: i0.Output, args: ['p-change',] }],
24690
- ngModelChange: [{ type: i0.Output, args: ['ngModelChange',] }],
24691
- setLabelOn: [{ type: i0.Input, args: ['p-label-on',] }],
24692
- setLabelOff: [{ type: i0.Input, args: ['p-label-off',] }],
24693
- setLabelPosition: [{ type: i0.Input, args: ['p-label-position',] }],
24694
- disabled: [{ type: i0.Input, args: ['p-disabled',] }]
25038
+ autoFocus: [{ type: i0.Input, args: ['p-auto-focus',] }],
25039
+ disabled: [{ type: i0.Input, args: ['p-disabled',] }],
25040
+ change: [{ type: i0.Output, args: ['p-change',] }]
24695
25041
  };
24696
25042
  __decorate([
24697
25043
  InputBoolean()
24698
- ], PoSwitchBaseComponent.prototype, "autoFocus", void 0);
25044
+ ], PoFieldModel.prototype, "autoFocus", void 0);
25045
+ __decorate([
25046
+ InputBoolean()
25047
+ ], PoFieldModel.prototype, "disabled", void 0);
24699
25048
 
24700
25049
  /**
24701
- * @docsExtends PoSwitchBaseComponent
25050
+ * @usedBy PoSwitchComponent
25051
+ *
25052
+ * @description
25053
+ *
25054
+ * Enum para posicionar o label do valor do po-switch.
25055
+ */
25056
+ exports.PoSwitchLabelPosition = void 0;
25057
+ (function (PoSwitchLabelPosition) {
25058
+ /** Posiciona o label do lado esquerdo do switch. */
25059
+ PoSwitchLabelPosition[PoSwitchLabelPosition["Right"] = 0] = "Right";
25060
+ /** Posiciona o label do lado direito do switch. */
25061
+ PoSwitchLabelPosition[PoSwitchLabelPosition["Left"] = 1] = "Left";
25062
+ })(exports.PoSwitchLabelPosition || (exports.PoSwitchLabelPosition = {}));
25063
+
25064
+ /**
25065
+ * @docsExtends PoFieldModel
25066
+ *
25067
+ * @description
25068
+ *
25069
+ * O componente `po-switch` é um [checkbox](/documentation/po-checkbox-group) mais intuitivo, pois faz analogia a um interruptor.
25070
+ * Deve ser usado quando deseja-se transmitir a ideia de ligar / desligar uma funcionalidade específica.
25071
+ *
25072
+ * Pode-se ligar ou deligar o botão utilizando a tecla de espaço ou o clique do mouse.
25073
+ *
25074
+ * O texto exibido pode ser alterado de acordo com o valor setado aumentando as possibilidades de uso do componente,
25075
+ * portanto, recomenda-se informar textos que contextualizem seu uso para que facilite a compreensão do usuário.
25076
+ *
25077
+ * > O componente não altera o valor incial informado no *model*, portanto indica-se inicializa-lo caso ter necessidade.
24702
25078
  *
24703
25079
  * @example
24704
25080
  *
@@ -24727,8 +25103,63 @@
24727
25103
  var PoSwitchComponent = /** @class */ (function (_super) {
24728
25104
  __extends(PoSwitchComponent, _super);
24729
25105
  function PoSwitchComponent(changeDetector) {
24730
- return _super.call(this, changeDetector) || this;
25106
+ var _this = _super.call(this) || this;
25107
+ _this.changeDetector = changeDetector;
25108
+ _this.value = false;
25109
+ _this._labelOff = 'false';
25110
+ _this._labelOn = 'true';
25111
+ _this._labelPosition = exports.PoSwitchLabelPosition.Right;
25112
+ return _this;
24731
25113
  }
25114
+ Object.defineProperty(PoSwitchComponent.prototype, "labelPosition", {
25115
+ get: function () {
25116
+ return this._labelPosition;
25117
+ },
25118
+ /**
25119
+ * @optional
25120
+ *
25121
+ * @description
25122
+ *
25123
+ * Posição de exibição do rótulo.
25124
+ *
25125
+ * > Por padrão exibe à direita.
25126
+ */
25127
+ set: function (position) {
25128
+ this._labelPosition = position in exports.PoSwitchLabelPosition ? parseInt(position, 10) : exports.PoSwitchLabelPosition.Right;
25129
+ },
25130
+ enumerable: false,
25131
+ configurable: true
25132
+ });
25133
+ Object.defineProperty(PoSwitchComponent.prototype, "labelOff", {
25134
+ get: function () {
25135
+ return this._labelOff;
25136
+ },
25137
+ /**
25138
+ * Texto exibido quando o valor do componente for `false`.
25139
+ *
25140
+ * @default `false`
25141
+ */
25142
+ set: function (label) {
25143
+ this._labelOff = label || 'false';
25144
+ },
25145
+ enumerable: false,
25146
+ configurable: true
25147
+ });
25148
+ Object.defineProperty(PoSwitchComponent.prototype, "labelOn", {
25149
+ get: function () {
25150
+ return this._labelOn;
25151
+ },
25152
+ /**
25153
+ * Texto exibido quando o valor do componente for `true`.
25154
+ *
25155
+ * @default `true`
25156
+ */
25157
+ set: function (label) {
25158
+ this._labelOn = label || 'true';
25159
+ },
25160
+ enumerable: false,
25161
+ configurable: true
25162
+ });
24732
25163
  PoSwitchComponent.prototype.ngAfterViewInit = function () {
24733
25164
  if (this.autoFocus) {
24734
25165
  this.focus();
@@ -24781,17 +25212,35 @@
24781
25212
  }
24782
25213
  };
24783
25214
  PoSwitchComponent.prototype.onKeyDown = function (event) {
24784
- if (event.which === 32 || event.keyCode === 32) {
25215
+ if (event.which === PoKeyCodeEnum.space || event.keyCode === PoKeyCodeEnum.space) {
24785
25216
  event.preventDefault();
24786
25217
  this.eventClick();
24787
25218
  }
24788
25219
  };
25220
+ PoSwitchComponent.prototype.changeValue = function (value) {
25221
+ if (this.value !== value) {
25222
+ this.value = value;
25223
+ this.updateModel(value);
25224
+ this.change.emit(this.value);
25225
+ }
25226
+ };
25227
+ PoSwitchComponent.prototype.eventClick = function () {
25228
+ if (!this.disabled) {
25229
+ this.changeValue(!this.value);
25230
+ }
25231
+ };
25232
+ PoSwitchComponent.prototype.onWriteValue = function (value) {
25233
+ if (value !== this.value) {
25234
+ this.value = !!value;
25235
+ this.changeDetector.markForCheck();
25236
+ }
25237
+ };
24789
25238
  return PoSwitchComponent;
24790
- }(PoSwitchBaseComponent));
25239
+ }(PoFieldModel));
24791
25240
  PoSwitchComponent.decorators = [
24792
25241
  { type: i0.Component, args: [{
24793
25242
  selector: 'po-switch',
24794
- template: "<po-field-container [p-label]=\"label\" [p-help]=\"help\">\n <div class=\"po-field-container-content po-switch-content\" [attr.name]=\"name\">\n <div\n class=\"po-switch-container po-clickable\"\n #switchContainer\n [class.po-switch-container-disabled]=\"disabled\"\n [class.po-switch-container-off]=\"switchValue === false && !disabled\"\n [class.po-switch-container-on]=\"switchValue === true && !disabled\"\n [class.po-switch-container-right]=\"getSwitchPosition() === 'right'\"\n [tabindex]=\"disabled ? -1 : 0\"\n (click)=\"eventClick()\"\n (keydown)=\"onKeyDown($event)\"\n (blur)=\"onBlur()\"\n >\n <div\n class=\"po-switch-button\"\n [class.po-switch-button-on]=\"switchValue === true\"\n [class.po-switch-button-off]=\"switchValue === false\"\n [class.po-switch-button-disabled]=\"disabled\"\n >\n <span class=\"po-icon po-icon-{{ switchValue === true ? 'ok' : 'close' }}\"></span>\n </div>\n </div>\n\n <span class=\"po-switch-label po-clickable po-switch-label-{{ getLabelPosition() }}\" (click)=\"eventClick()\">\n {{ switchValue === true ? labelOn : labelOff }}\n </span>\n </div>\n\n <po-field-container-bottom></po-field-container-bottom>\n</po-field-container>\n",
25243
+ template: "<po-field-container [p-label]=\"label\" [p-help]=\"help\">\n <div class=\"po-field-container-content po-switch-content\" [attr.name]=\"name\">\n <div\n class=\"po-switch-container po-clickable\"\n #switchContainer\n [class.po-switch-container-disabled]=\"disabled\"\n [class.po-switch-container-off]=\"value === false && !disabled\"\n [class.po-switch-container-on]=\"value === true && !disabled\"\n [class.po-switch-container-right]=\"getSwitchPosition() === 'right'\"\n [tabindex]=\"disabled ? -1 : 0\"\n (click)=\"eventClick()\"\n (keydown)=\"onKeyDown($event)\"\n (blur)=\"onBlur()\"\n >\n <div\n class=\"po-switch-button\"\n [class.po-switch-button-on]=\"value === true\"\n [class.po-switch-button-off]=\"value === false\"\n [class.po-switch-button-disabled]=\"disabled\"\n >\n <span class=\"po-icon po-icon-{{ value === true ? 'ok' : 'close' }}\"></span>\n </div>\n </div>\n\n <span class=\"po-switch-label po-clickable po-switch-label-{{ getLabelPosition() }}\" (click)=\"eventClick()\">\n {{ value === true ? labelOn : labelOff }}\n </span>\n </div>\n\n <po-field-container-bottom></po-field-container-bottom>\n</po-field-container>\n",
24795
25244
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
24796
25245
  providers: [
24797
25246
  {
@@ -24806,7 +25255,10 @@
24806
25255
  { type: i0.ChangeDetectorRef }
24807
25256
  ]; };
24808
25257
  PoSwitchComponent.propDecorators = {
24809
- switchContainer: [{ type: i0.ViewChild, args: ['switchContainer', { static: true },] }]
25258
+ switchContainer: [{ type: i0.ViewChild, args: ['switchContainer', { static: true },] }],
25259
+ labelPosition: [{ type: i0.Input, args: ['p-label-position',] }],
25260
+ labelOff: [{ type: i0.Input, args: ['p-label-off',] }],
25261
+ labelOn: [{ type: i0.Input, args: ['p-label-on',] }]
24810
25262
  };
24811
25263
 
24812
25264
  /**
@@ -27022,8 +27474,8 @@
27022
27474
  var PoUrlComponent = /** @class */ (function (_super) {
27023
27475
  __extends(PoUrlComponent, _super);
27024
27476
  /* istanbul ignore next */
27025
- function PoUrlComponent(el) {
27026
- var _this = _super.call(this, el) || this;
27477
+ function PoUrlComponent(el, cd) {
27478
+ var _this = _super.call(this, el, cd) || this;
27027
27479
  _this.icon = 'po-icon-world';
27028
27480
  _this.type = 'url';
27029
27481
  _this.pattern = '^((https|http):\\/\\/)?' + // protocol
@@ -27061,6 +27513,7 @@
27061
27513
  { type: i0.Component, args: [{
27062
27514
  selector: 'po-url',
27063
27515
  template: "<po-field-container [p-help]=\"help\" [p-label]=\"label\" [p-optional]=\"!required && optional\">\n <div class=\"po-field-container-content\">\n <div *ngIf=\"icon\" class=\"po-field-icon-container-left\">\n <po-icon class=\"po-field-icon\" [class.po-field-icon-disabled]=\"disabled\" [p-icon]=\"icon\"></po-icon>\n </div>\n\n <input\n #inp\n class=\"po-input\"\n [attr.name]=\"name\"\n [autocomplete]=\"autocomplete\"\n [class.po-input-icon-left]=\"icon\"\n [class.po-input-icon-right]=\"clean\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n [type]=\"type\"\n (blur)=\"eventOnBlur($event)\"\n (click)=\"eventOnClick($event)\"\n (focus)=\"eventOnFocus($event)\"\n (input)=\"eventOnInput($event)\"\n />\n\n <div class=\"po-field-icon-container-right\">\n <po-clean *ngIf=\"clean && !disabled && !readonly\" [p-element-ref]=\"inputEl\" (p-change-event)=\"clear($event)\">\n </po-clean>\n </div>\n </div>\n\n <po-field-container-bottom [p-error-pattern]=\"getErrorPattern()\"> </po-field-container-bottom>\n</po-field-container>\n",
27516
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
27064
27517
  providers: [
27065
27518
  {
27066
27519
  provide: forms.NG_VALUE_ACCESSOR,
@@ -27076,7 +27529,8 @@
27076
27529
  },] }
27077
27530
  ];
27078
27531
  PoUrlComponent.ctorParameters = function () { return [
27079
- { type: i0.ElementRef }
27532
+ { type: i0.ElementRef },
27533
+ { type: i0.ChangeDetectorRef }
27080
27534
  ]; };
27081
27535
 
27082
27536
  /**
@@ -27836,7 +28290,7 @@
27836
28290
  return 'switch';
27837
28291
  }
27838
28292
  else if (this.compareTo(type, exports.PoDynamicFieldType.Date) || this.compareTo(type, exports.PoDynamicFieldType.DateTime)) {
27839
- return 'datepicker';
28293
+ return field.range ? 'datepickerrange' : 'datepicker';
27840
28294
  }
27841
28295
  else if (this.compareTo(type, exports.PoDynamicFieldType.Time)) {
27842
28296
  field.mask = field.mask || '99:99';
@@ -28061,7 +28515,7 @@
28061
28515
  PoDynamicFormFieldsComponent.decorators = [
28062
28516
  { type: i0.Component, args: [{
28063
28517
  selector: 'po-dynamic-form-fields',
28064
- template: "<div class=\"po-row\" *ngIf=\"visibleFields && visibleFields.length > 0\">\n <ng-container *ngFor=\"let field of visibleFields; trackBy: trackBy\">\n <po-divider *ngIf=\"field?.divider?.trim()\" class=\"po-sm-12\" [p-label]=\"field.divider\"> </po-divider>\n\n <po-datepicker\n #component\n *ngIf=\"compareTo(field.control, 'datepicker')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-format]=\"field.format\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-locale]=\"field.locale\"\n [p-max-date]=\"field.maxValue\"\n [p-min-date]=\"field.minValue\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-datepicker>\n\n <po-input\n #component\n *ngIf=\"compareTo(field.control, 'input')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-mask-format-model]=\"field.maskFormatModel\"\n [p-mask]=\"field.mask\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-pattern]=\"field.pattern\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-icon]=\"field.icon\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-input>\n\n <po-number\n #component\n *ngIf=\"compareTo(field.control, 'number')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-min]=\"field.minValue\"\n [p-max]=\"field.maxValue\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-icon]=\"field.icon\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-number>\n\n <po-decimal\n #component\n *ngIf=\"compareTo(field.control, 'decimal')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-decimals-length]=\"field.decimalsLength\"\n [p-thousand-maxlength]=\"field.thousandMaxlength\"\n [p-icon]=\"field.icon\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-locale]=\"field.locale\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-decimal>\n\n <po-select\n #component\n *ngIf=\"compareTo(field.control, 'select')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-select>\n\n <po-radio-group\n #component\n *ngIf=\"compareTo(field.control, 'radioGroup')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-columns=\"3\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-radio-group>\n\n <po-switch\n #component\n *ngIf=\"compareTo(field.control, 'switch')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-label-off]=\"field.booleanFalse\"\n [p-label-on]=\"field.booleanTrue\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-switch>\n\n <po-combo\n #component\n *ngIf=\"compareTo(field.control, 'combo')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-emit-object-value\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-field-label]=\"field.fieldLabel\"\n [p-field-value]=\"field.fieldValue\"\n [p-filter-params]=\"field.params\"\n [p-filter-service]=\"field.optionsService\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field, $event)\"\n [p-icon]=\"field.icon\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-combo>\n\n <po-lookup\n #component\n *ngIf=\"compareTo(field.control, 'lookup')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n p-field-label=\"label\"\n p-field-value=\"value\"\n [ngClass]=\"field.componentClass\"\n [p-columns]=\"field.columns\"\n [p-disabled]=\"isDisabled(field)\"\n [p-field-label]=\"field.fieldLabel || 'label'\"\n [p-field-value]=\"field.fieldValue || 'value'\"\n [p-filter-params]=\"field.params\"\n [p-filter-service]=\"field.searchService\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-field-format]=\"field.format\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-lookup>\n\n <po-checkbox-group\n #component\n *ngIf=\"compareTo(field.control, 'checkboxGroup')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-columns=\"3\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-checkbox-group>\n\n <po-multiselect\n #component\n *ngIf=\"compareTo(field.control, 'multiselect')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-disabled]=\"isDisabled(field)\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-multiselect>\n\n <po-textarea\n #component\n *ngIf=\"compareTo(field.control, 'textarea')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-disabled]=\"isDisabled(field)\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n [p-rows]=\"field.rows\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-textarea>\n\n <po-password\n #component\n *ngIf=\"compareTo(field.control, 'password')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-pattern]=\"field.pattern\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-password>\n </ng-container>\n</div>\n",
28518
+ template: "<div class=\"po-row\" *ngIf=\"visibleFields && visibleFields.length > 0\">\n <ng-container *ngFor=\"let field of visibleFields; trackBy: trackBy\">\n <po-divider *ngIf=\"field?.divider?.trim()\" class=\"po-sm-12\" [p-label]=\"field.divider\"> </po-divider>\n\n <po-datepicker\n #component\n *ngIf=\"compareTo(field.control, 'datepicker')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-format]=\"field.format\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-locale]=\"field.locale\"\n [p-max-date]=\"field.maxValue\"\n [p-min-date]=\"field.minValue\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-datepicker>\n\n <po-datepicker-range\n #component\n *ngIf=\"compareTo(field.control, 'datepickerrange')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-datepicker-range>\n\n <po-input\n #component\n *ngIf=\"compareTo(field.control, 'input')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-mask-format-model]=\"field.maskFormatModel\"\n [p-mask]=\"field.mask\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-pattern]=\"field.pattern\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-icon]=\"field.icon\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-input>\n\n <po-number\n #component\n *ngIf=\"compareTo(field.control, 'number')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-min]=\"field.minValue\"\n [p-max]=\"field.maxValue\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-icon]=\"field.icon\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-number>\n\n <po-decimal\n #component\n *ngIf=\"compareTo(field.control, 'decimal')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-decimals-length]=\"field.decimalsLength\"\n [p-thousand-maxlength]=\"field.thousandMaxlength\"\n [p-icon]=\"field.icon\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-locale]=\"field.locale\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-decimal>\n\n <po-select\n #component\n *ngIf=\"compareTo(field.control, 'select')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-select>\n\n <po-radio-group\n #component\n *ngIf=\"compareTo(field.control, 'radioGroup')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-columns=\"3\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-radio-group>\n\n <po-switch\n #component\n *ngIf=\"compareTo(field.control, 'switch')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-label-off]=\"field.booleanFalse\"\n [p-label-on]=\"field.booleanTrue\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-switch>\n\n <po-combo\n #component\n *ngIf=\"compareTo(field.control, 'combo')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-emit-object-value\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-field-label]=\"field.fieldLabel\"\n [p-field-value]=\"field.fieldValue\"\n [p-filter-params]=\"field.params\"\n [p-filter-service]=\"field.optionsService\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field, $event)\"\n [p-icon]=\"field.icon\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-combo>\n\n <po-lookup\n #component\n *ngIf=\"compareTo(field.control, 'lookup')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n p-field-label=\"label\"\n p-field-value=\"value\"\n [ngClass]=\"field.componentClass\"\n [p-columns]=\"field.columns\"\n [p-disabled]=\"isDisabled(field)\"\n [p-field-label]=\"field.fieldLabel || 'label'\"\n [p-field-value]=\"field.fieldValue || 'value'\"\n [p-filter-params]=\"field.params\"\n [p-filter-service]=\"field.searchService\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-field-format]=\"field.format\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-lookup>\n\n <po-checkbox-group\n #component\n *ngIf=\"compareTo(field.control, 'checkboxGroup')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-columns=\"3\"\n [p-auto-focus]=\"field.focus\"\n [p-disabled]=\"isDisabled(field)\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n >\n </po-checkbox-group>\n\n <po-multiselect\n #component\n *ngIf=\"compareTo(field.control, 'multiselect')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-disabled]=\"isDisabled(field)\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-optional]=\"field.optional\"\n [p-options]=\"field.options\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-multiselect>\n\n <po-textarea\n #component\n *ngIf=\"compareTo(field.control, 'textarea')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n [p-disabled]=\"isDisabled(field)\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-required]=\"field.required\"\n [p-rows]=\"field.rows\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-textarea>\n\n <po-password\n #component\n *ngIf=\"compareTo(field.control, 'password')\"\n [name]=\"field.property\"\n [(ngModel)]=\"value[field.property]\"\n [ngClass]=\"field.componentClass\"\n p-clean\n [p-disabled]=\"isDisabled(field)\"\n [p-error-pattern]=\"field.errorMessage\"\n [p-auto-focus]=\"field.focus\"\n [p-help]=\"field.help\"\n [p-label]=\"field.label\"\n [p-maxlength]=\"field.maxLength\"\n [p-minlength]=\"field.minLength\"\n [p-optional]=\"field.optional\"\n [p-pattern]=\"field.pattern\"\n [p-required]=\"field.required\"\n (p-change)=\"onChangeField(field)\"\n [p-placeholder]=\"field.placeholder\"\n >\n </po-password>\n </ng-container>\n</div>\n",
28065
28519
  viewProviders: [{ provide: forms.ControlContainer, useExisting: forms.NgForm }],
28066
28520
  providers: [PoDynamicFormValidationService]
28067
28521
  },] }
@@ -33455,7 +33909,7 @@
33455
33909
  PoPageHeaderComponent.decorators = [
33456
33910
  { type: i0.Component, args: [{
33457
33911
  selector: 'po-page-header',
33458
- template: "<div class=\"po-page-header\">\n <!-- Breadcrumb -->\n <div class=\"po-page-header-breadcrumb\" *ngIf=\"breadcrumb && breadcrumb.items.length\">\n <po-breadcrumb\n [p-favorite-service]=\"breadcrumb.favorite\"\n [p-items]=\"breadcrumb.items\"\n [p-params-service]=\"breadcrumb.params\"\n >\n </po-breadcrumb>\n </div>\n\n <!-- Titulo -->\n <h1 class=\"po-page-header-title\" *ngIf=\"title\">\n {{ title }}\n </h1>\n\n <!-- Opera\u00E7\u00F5es -->\n <ng-content></ng-content>\n</div>\n"
33912
+ template: "<div class=\"po-page-header\">\n <!-- Breadcrumb -->\n <div class=\"po-page-header-breadcrumb\" *ngIf=\"breadcrumb && breadcrumb.items.length\">\n <po-breadcrumb\n [p-favorite-service]=\"breadcrumb.favorite\"\n [p-items]=\"breadcrumb.items\"\n [p-params-service]=\"breadcrumb.params\"\n >\n </po-breadcrumb>\n </div>\n\n <div class=\"po-pt-1\">\n <!-- Titulo -->\n <h1 class=\"po-page-header-title\" *ngIf=\"title\">\n {{ title }}\n </h1>\n\n <!-- Opera\u00E7\u00F5es -->\n <ng-content></ng-content>\n </div>\n</div>\n"
33459
33913
  },] }
33460
33914
  ];
33461
33915
 
@@ -34895,7 +35349,7 @@
34895
35349
  PoStepperCircleComponent.decorators = [
34896
35350
  { type: i0.Component, args: [{
34897
35351
  selector: 'po-stepper-circle',
34898
- template: "<div\n class=\"po-stepper-circle\"\n [class.po-stepper-circle-with-icon]=\"icons\"\n [style.height.px]=\"size\"\n [style.width.px]=\"size\"\n [tabindex]=\"isDisabled ? -1 : 0\"\n>\n <span\n class=\"po-stepper-circle-content\"\n [class.po-icon]=\"icons\"\n [class.po-icon-exclamation]=\"icons && isError\"\n [class.po-icon-info]=\"icons && (isActive || isDefault || isDisabled)\"\n [class.po-icon-ok]=\"icons && isDone\"\n [class.po-stepper-circle-content-lg]=\"isLargeStep\"\n [class.po-stepper-circle-content-md]=\"isMediumStep\"\n >\n {{ !icons ? content : '' }}\n </span>\n</div>\n"
35352
+ template: "<div class=\"po-stepper-circle\" [style.height.px]=\"size\" [style.width.px]=\"size\" [tabindex]=\"isDisabled ? -1 : 0\">\n <span\n *ngIf=\"!isActive\"\n class=\"po-stepper-circle-content\"\n [class.po-icon]=\"icons || isDone\"\n [class.po-icon-exclamation]=\"icons && isError\"\n [class.po-icon-info]=\"icons && (isActive || isDefault || isDisabled)\"\n [class.po-icon-ok]=\"isDone\"\n [class.po-stepper-circle-content-lg]=\"isLargeStep\"\n [class.po-stepper-circle-content-md]=\"isMediumStep\"\n >\n {{ !icons && !isDone ? content : '' }}\n </span>\n\n <div *ngIf=\"isActive || isError\" class=\"po-stepper-circle-active\"></div>\n</div>\n"
34899
35353
  },] }
34900
35354
  ];
34901
35355
  PoStepperCircleComponent.propDecorators = {
@@ -35099,6 +35553,12 @@
35099
35553
  * <file name="sample-po-stepper-sales/sample-po-stepper-sales.component.html"> </file>
35100
35554
  * <file name="sample-po-stepper-sales/sample-po-stepper-sales.component.ts"> </file>
35101
35555
  * </example>
35556
+ *
35557
+ * <example name="po-stepper-active" title="PO Stepper - Active">
35558
+ * <file name="sample-po-stepper-active/sample-po-stepper-active.component.html"> </file>
35559
+ * <file name="sample-po-stepper-active/sample-po-stepper-active.component.ts"> </file>
35560
+ * <file name="sample-po-stepper-active/sample-po-stepper-active.service.ts"> </file>
35561
+ * </example>
35102
35562
  */
35103
35563
  var PoStepperComponent = /** @class */ (function (_super) {
35104
35564
  __extends(PoStepperComponent, _super);
@@ -35148,11 +35608,7 @@
35148
35608
  }
35149
35609
  var stepsArray = this.getPoSteps();
35150
35610
  var step = stepsArray[index];
35151
- var isDisabledStep = step.status === exports.PoStepperStatus.Disabled;
35152
- var isErrorStep = step.status === exports.PoStepperStatus.Error;
35153
- if (!isDisabledStep || isErrorStep) {
35154
- this.changeStep(index, step);
35155
- }
35611
+ this.changeStep(index, step);
35156
35612
  };
35157
35613
  /**
35158
35614
  * Ativa o primeiro *step*.
@@ -35215,8 +35671,12 @@
35215
35671
  };
35216
35672
  PoStepperComponent.prototype.onStepActive = function (step) {
35217
35673
  this.currentActiveStep = step;
35218
- this.previousActiveStep = this.poSteps.find(function (stepChild) { return stepChild.status === exports.PoStepperStatus.Active && stepChild.id !== step.id; });
35219
- this.setPreviousStepAsDone();
35674
+ var stepIndex = this.getStepsAndIndex(this.currentActiveStep).stepIndex;
35675
+ this.poSteps.forEach(function (stepChild, i) {
35676
+ if (i < stepIndex) {
35677
+ stepChild.status = exports.PoStepperStatus.Done;
35678
+ }
35679
+ });
35220
35680
  };
35221
35681
  PoStepperComponent.prototype.trackByFn = function (step) {
35222
35682
  return step.id;
@@ -35293,17 +35753,12 @@
35293
35753
  steps[nextIndex].status = exports.PoStepperStatus.Default;
35294
35754
  }
35295
35755
  };
35296
- PoStepperComponent.prototype.setPreviousStepAsDone = function () {
35297
- if (this.previousActiveStep) {
35298
- this.previousActiveStep.status = exports.PoStepperStatus.Done;
35299
- }
35300
- };
35301
35756
  return PoStepperComponent;
35302
35757
  }(PoStepperBaseComponent));
35303
35758
  PoStepperComponent.decorators = [
35304
35759
  { type: i0.Component, args: [{
35305
35760
  selector: 'po-stepper',
35306
- template: "<div class=\"po-stepper po-stepper-{{ orientation }}\">\n <div class=\"po-stepper-container\">\n <po-stepper-step\n *ngFor=\"let step of stepList; let index = index; trackBy: trackByFn\"\n class=\"po-stepper-step-position\"\n [p-circle-content]=\"index + 1\"\n [p-label]=\"step.label\"\n [p-orientation]=\"orientation\"\n [p-status]=\"step.status\"\n [p-step-icons]=\"stepIcons\"\n [p-step-size]=\"stepSize\"\n (p-activated)=\"onStepActive(step)\"\n (p-click)=\"changeStep(index, step)\"\n (p-enter)=\"changeStep(index, step)\"\n >\n </po-stepper-step>\n </div>\n\n <div *ngIf=\"usePoSteps\" class=\"po-stepper-content\">\n <ng-content></ng-content>\n </div>\n</div>\n"
35761
+ template: "<div class=\"po-stepper po-stepper-{{ orientation }}\">\n <div class=\"po-stepper-container\">\n <po-stepper-step\n *ngFor=\"let step of stepList; let index = index; trackBy: trackByFn\"\n class=\"po-stepper-step-position\"\n [p-circle-content]=\"index + 1\"\n [p-label]=\"step.label\"\n [p-orientation]=\"orientation\"\n [p-status]=\"step.status\"\n [p-step-icons]=\"stepIcons\"\n [p-step-size]=\"stepSize\"\n [p-next-status]=\"poSteps.get(index + 1)?.status\"\n (p-activated)=\"onStepActive(step)\"\n (p-click)=\"changeStep(index, step)\"\n (p-enter)=\"changeStep(index, step)\"\n >\n </po-stepper-step>\n </div>\n\n <div *ngIf=\"usePoSteps\" class=\"po-stepper-content\">\n <ng-content></ng-content>\n </div>\n</div>\n"
35307
35762
  },] }
35308
35763
  ];
35309
35764
  PoStepperComponent.ctorParameters = function () { return [
@@ -35433,11 +35888,11 @@
35433
35888
  PoStepperStepComponent.prototype.getStatusClass = function (status) {
35434
35889
  switch (status) {
35435
35890
  case exports.PoStepperStatus.Active:
35436
- return 'po-stepper-step-active';
35891
+ return 'po-stepper-step-default';
35437
35892
  case exports.PoStepperStatus.Disabled:
35438
35893
  return 'po-stepper-step-disabled';
35439
35894
  case exports.PoStepperStatus.Done:
35440
- return 'po-stepper-step-done';
35895
+ return 'po-stepper-step-default';
35441
35896
  case exports.PoStepperStatus.Error:
35442
35897
  return 'po-stepper-step-error';
35443
35898
  default:
@@ -35459,12 +35914,13 @@
35459
35914
  PoStepperStepComponent.decorators = [
35460
35915
  { type: i0.Component, args: [{
35461
35916
  selector: 'po-stepper-step',
35462
- template: "<div class=\"po-stepper-step\" [ngClass]=\"getStatusClass(status)\" (click)=\"onClick()\" (keydown.enter)=\"onEnter()\">\n <div class=\"po-stepper-step-container\" [style.width.px]=\"isVerticalOrientation ? stepSize : undefined\">\n <div\n [class.po-stepper-step-bar-top]=\"isVerticalOrientation\"\n [class.po-stepper-step-bar-left]=\"!isVerticalOrientation\"\n [style.margin-right.px]=\"marginHorizontalBar\"\n ></div>\n\n <po-stepper-circle [p-content]=\"circleContent\" [p-icons]=\"stepIcons\" [p-size]=\"stepSize\" [p-status]=\"status\">\n </po-stepper-circle>\n\n <div\n [class.po-stepper-step-bar-bottom]=\"isVerticalOrientation\"\n [class.po-stepper-step-bar-right]=\"!isVerticalOrientation\"\n [style.margin-left.px]=\"marginHorizontalBar\"\n ></div>\n </div>\n\n <po-stepper-label class=\"po-stepper-step-label-position\" [p-content]=\"label\"> </po-stepper-label>\n</div>\n"
35917
+ template: "<div class=\"po-stepper-step\" [ngClass]=\"getStatusClass(status)\" (click)=\"onClick()\" (keydown.enter)=\"onEnter()\">\n <div class=\"po-stepper-step-container\" [style.width.px]=\"isVerticalOrientation ? stepSize : undefined\">\n <div\n [class.po-stepper-step-bar-top]=\"isVerticalOrientation\"\n [class.po-stepper-step-bar-left]=\"!isVerticalOrientation\"\n [style.margin-right.px]=\"marginHorizontalBar\"\n ></div>\n\n <po-stepper-circle [p-content]=\"circleContent\" [p-icons]=\"stepIcons\" [p-size]=\"stepSize\" [p-status]=\"status\">\n </po-stepper-circle>\n\n <div\n [class.po-stepper-step-bar-bottom]=\"isVerticalOrientation\"\n [class.po-stepper-step-bar-right]=\"!isVerticalOrientation\"\n [class.po-stepper-step-dashed-border]=\"nextStatus === 'disabled' && !isVerticalOrientation\"\n [class.po-stepper-step-dashed-border-vertical]=\"nextStatus === 'disabled' && isVerticalOrientation\"\n [style.margin-left.px]=\"marginHorizontalBar\"\n ></div>\n </div>\n\n <po-stepper-label class=\"po-stepper-step-label-position\" [p-content]=\"label\"> </po-stepper-label>\n</div>\n"
35463
35918
  },] }
35464
35919
  ];
35465
35920
  PoStepperStepComponent.propDecorators = {
35466
35921
  circleContent: [{ type: i0.Input, args: ['p-circle-content',] }],
35467
35922
  orientation: [{ type: i0.Input, args: ['p-orientation',] }],
35923
+ nextStatus: [{ type: i0.Input, args: ['p-next-status',] }],
35468
35924
  activated: [{ type: i0.Output, args: ['p-activated',] }],
35469
35925
  click: [{ type: i0.Output, args: ['p-click',] }],
35470
35926
  enter: [{ type: i0.Output, args: ['p-enter',] }],
@@ -38768,7 +39224,7 @@
38768
39224
  exports.ɵdz = PoRichTextBodyComponent;
38769
39225
  exports.ɵe = PoAvatarBaseComponent;
38770
39226
  exports.ɵea = PoSelectBaseComponent;
38771
- exports.ɵeb = PoSwitchBaseComponent;
39227
+ exports.ɵeb = PoFieldModel;
38772
39228
  exports.ɵec = PoTextareaBaseComponent;
38773
39229
  exports.ɵed = PoUploadBaseComponent;
38774
39230
  exports.ɵee = PoUploadService;