steps.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7. };
  8. var __metadata = (this && this.__metadata) || function (k, v) {
  9. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var common_1 = require("@angular/common");
  14. var router_1 = require("@angular/router");
  15. var Steps = /** @class */ (function () {
  16. function Steps() {
  17. this.activeIndex = 0;
  18. this.readonly = true;
  19. this.activeIndexChange = new core_1.EventEmitter();
  20. }
  21. Steps.prototype.itemClick = function (event, item, i) {
  22. if (this.readonly || item.disabled) {
  23. event.preventDefault();
  24. return;
  25. }
  26. this.activeIndexChange.emit(i);
  27. if (!item.url) {
  28. event.preventDefault();
  29. }
  30. if (item.command) {
  31. item.command({
  32. originalEvent: event,
  33. item: item,
  34. index: i
  35. });
  36. }
  37. };
  38. __decorate([
  39. core_1.Input(),
  40. __metadata("design:type", Number)
  41. ], Steps.prototype, "activeIndex", void 0);
  42. __decorate([
  43. core_1.Input(),
  44. __metadata("design:type", Array)
  45. ], Steps.prototype, "model", void 0);
  46. __decorate([
  47. core_1.Input(),
  48. __metadata("design:type", Boolean)
  49. ], Steps.prototype, "readonly", void 0);
  50. __decorate([
  51. core_1.Input(),
  52. __metadata("design:type", Object)
  53. ], Steps.prototype, "style", void 0);
  54. __decorate([
  55. core_1.Input(),
  56. __metadata("design:type", String)
  57. ], Steps.prototype, "styleClass", void 0);
  58. __decorate([
  59. core_1.Output(),
  60. __metadata("design:type", core_1.EventEmitter)
  61. ], Steps.prototype, "activeIndexChange", void 0);
  62. Steps = __decorate([
  63. core_1.Component({
  64. selector: 'p-steps',
  65. template: "\n <div [ngClass]=\"{'ui-steps ui-widget ui-helper-clearfix':true,'ui-steps-readonly':readonly}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <ul role=\"tablist\">\n <li *ngFor=\"let item of model; let i = index\" class=\"ui-steps-item\" #menuitem [ngStyle]=\"item.style\" [class]=\"item.styleClass\"\n [ngClass]=\"{'ui-state-highlight ui-steps-current':(i === activeIndex),\n 'ui-state-default':(i !== activeIndex),\n 'ui-state-complete':(i < activeIndex),\n 'ui-state-disabled ui-steps-incomplete':item.disabled||(i !== activeIndex && readonly)}\">\n <a *ngIf=\"!item.routerLink\" [href]=\"item.url||'#'\" class=\"ui-menuitem-link\" (click)=\"itemClick($event, item, i)\" [attr.target]=\"item.target\" [attr.id]=\"item.id\" [attr.tabindex]=\"item.tabindex ? item.tabindex : '0'\">\n <span class=\"ui-steps-number\">{{i + 1}}</span>\n <span class=\"ui-steps-title\">{{item.label}}</span>\n </a>\n <a *ngIf=\"item.routerLink\" [routerLink]=\"item.routerLink\" [queryParams]=\"item.queryParams\" [routerLinkActive]=\"'ui-state-active'\" [routerLinkActiveOptions]=\"item.routerLinkActiveOptions||{exact:false}\" class=\"ui-menuitem-link\" (click)=\"itemClick($event, item, i)\" [attr.target]=\"item.target\" [attr.id]=\"item.id\" [attr.tabindex]=\"item.tabindex ? item.tabindex : '0'\">\n <span class=\"ui-steps-number\">{{i + 1}}</span>\n <span class=\"ui-steps-title\">{{item.label}}</span>\n </a>\n </li>\n </ul>\n </div>\n "
  66. })
  67. ], Steps);
  68. return Steps;
  69. }());
  70. exports.Steps = Steps;
  71. var StepsModule = /** @class */ (function () {
  72. function StepsModule() {
  73. }
  74. StepsModule = __decorate([
  75. core_1.NgModule({
  76. imports: [common_1.CommonModule, router_1.RouterModule],
  77. exports: [Steps, router_1.RouterModule],
  78. declarations: [Steps]
  79. })
  80. ], StepsModule);
  81. return StepsModule;
  82. }());
  83. exports.StepsModule = StepsModule;
  84. //# sourceMappingURL=steps.js.map