@energycap/components 0.39.30 → 0.39.32-ECAP-26866-table-multi-sort-improvements.20241022-1702

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.
@@ -5237,11 +5237,15 @@ class ConfirmComponent {
5237
5237
  /** Form Group to hold any form controls needed */
5238
5238
  this.formGroup = new UntypedFormGroup({});
5239
5239
  this.status = new Overlay('hasData');
5240
+ this.showTextBox = true;
5241
+ this.destroyed = new Subject();
5240
5242
  this.onDialogSave = new EventEmitter();
5241
5243
  this.onDialogCancel = new EventEmitter();
5242
5244
  }
5243
5245
  ngOnInit() {
5244
5246
  this.addFormControls();
5247
+ this.setValidations();
5248
+ this.listenCheckBox();
5245
5249
  }
5246
5250
  onSave(source) {
5247
5251
  this.formGroup.markAllAsTouched();
@@ -5250,6 +5254,9 @@ class ConfirmComponent {
5250
5254
  if (formValues.textbox) {
5251
5255
  this.context.textboxValue = formValues.textbox;
5252
5256
  }
5257
+ if (this.context.checkConfirm) {
5258
+ this.context.checkboxValue = formValues.checkbox ? formValues.checkbox : false;
5259
+ }
5253
5260
  this.context.saveSource = source;
5254
5261
  if (this.context.inlineConfirmAction) {
5255
5262
  this.doInlineConfirmAction();
@@ -5265,6 +5272,26 @@ class ConfirmComponent {
5265
5272
  onCancel() {
5266
5273
  this.onDialogCancel.emit();
5267
5274
  }
5275
+ ngOnDestroy() {
5276
+ this.destroyed.next();
5277
+ this.destroyed.complete();
5278
+ }
5279
+ listenCheckBox() {
5280
+ var _a;
5281
+ (_a = this.formGroup.get('checkbox')) === null || _a === void 0 ? void 0 : _a.valueChanges.pipe(takeUntil(this.destroyed)).subscribe(value => {
5282
+ this.showTextBox = value;
5283
+ this.setValidations();
5284
+ });
5285
+ }
5286
+ setValidations() {
5287
+ var _a, _b;
5288
+ if (this.showTextBox) {
5289
+ (_a = this.formGroup.controls['textbox']) === null || _a === void 0 ? void 0 : _a.enable();
5290
+ }
5291
+ else {
5292
+ (_b = this.formGroup.controls['textbox']) === null || _b === void 0 ? void 0 : _b.disable();
5293
+ }
5294
+ }
5268
5295
  /**
5269
5296
  * Adds the textbox form control to our form group if its configured to be visible
5270
5297
  * Will also add the required validator if requested
@@ -5280,6 +5307,11 @@ class ConfirmComponent {
5280
5307
  }
5281
5308
  this.formGroup.addControl('textbox', new UntypedFormControl('', validators));
5282
5309
  }
5310
+ if (this.context.checkConfirm) {
5311
+ this.showTextBox = false;
5312
+ const checkboxControl = new UntypedFormControl('');
5313
+ this.formGroup.addControl('checkbox', checkboxControl);
5314
+ }
5283
5315
  }
5284
5316
  doInlineConfirmAction() {
5285
5317
  return __awaiter(this, void 0, void 0, function* () {
@@ -5296,10 +5328,10 @@ class ConfirmComponent {
5296
5328
  }
5297
5329
  }
5298
5330
  ConfirmComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfirmComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
5299
- ConfirmComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ConfirmComponent, selector: "ec-confirm", inputs: { context: "context" }, outputs: { onDialogSave: "onDialogSave", onDialogCancel: "onDialogCancel" }, ngImport: i0, template: "<section ecOverlay\r\n [status]=\"status?.status\"\r\n [message]=\"status?.message\"\r\n [action]=\"status?.action\"\r\n [noDataTemplate]=\"inlineConfirmResult\"\r\n overlayClassList=\"p-0\"\r\n class=\"bg-body flex-grow d-flex\">\r\n <form [formGroup]=\"formGroup\" class=\"flex-grow flex-column confirm-content text-body-1\">\r\n <section class=\"flex-grow\">\r\n <h2 class=\"font-weight-bold mb-3\" *ngIf=\"context?.title\">{{context?.title}}</h2>\r\n <ec-banner *ngIf=\"error\" [text]=\"error | translate\" bannerStyle=\"normal\" class=\"mb-3\"></ec-banner>\r\n <div *ngIf=\"context?.message\" [innerHtml]=\"context?.message | translate\" class=\"mb-3\"></div>\r\n <ec-textbox id=\"confirmTextbox\"\r\n *ngIf=\"context?.textboxType\"\r\n [autofocus]=\"true\"\r\n [formModel]=\"formGroup.get('textbox')\"\r\n [required]=\"context?.textboxRequired\"\r\n [label]=\"context?.textboxLabel\"\r\n [type]=\"context?.textboxType\"\r\n [rows]=\"context?.textareaRows\"\r\n [placeholder]=\"context?.textboxPlaceholder\"\r\n [upperCase]=\"context?.textboxUppercase\">\r\n </ec-textbox>\r\n </section>\r\n <footer class=\"mt-auto flex-shrink d-flex py-2 flex-row-reverse\">\r\n <ec-button id=\"saveConfirmButton\"\r\n class=\"ml-2\"\r\n [type]=\"context?.saveButtonType ? context?.saveButtonType : 'primary'\"\r\n [label]=\"context?.saveLabel ? context?.saveLabel : 'Save'\"\r\n [autofocus]=\"!context?.textboxType\"\r\n [isSubmit]=\"context?.saveOnEnter\"\r\n (clicked)=\"onSave('primary')\">\r\n </ec-button>\r\n <ec-button id=\"alternateSaveConfirmButton\"\r\n *ngIf=\"context?.alternateSaveLabel\"\r\n class=\"ml-2\"\r\n [type]=\"context?.alternateSaveButtonType ? context?.alternateSaveButtonType : 'primary'\"\r\n [label]=\"context?.alternateSaveLabel\"\r\n (clicked)=\"onSave('alternate')\">\r\n </ec-button>\r\n <ec-button *ngIf=\"!context?.hideCancel\"\r\n id=\"cancelConfirmButton\"\r\n class=\"ml-auto\"\r\n type=\"secondary\"\r\n [label]=\"context?.cancelLabel ? context?.cancelLabel : 'Cancel'\"\r\n (clicked)=\"onCancel()\">\r\n </ec-button>\r\n </footer>\r\n </form>\r\n</section>\r\n\r\n<ng-template #inlineConfirmResult>\r\n <section class=\"flex-grow align-self-stretch confirm-content text-body-1\">\r\n <div class=\"d-flex\">\r\n <i class=\"ec-icon {{status?.action?.icon}} {{status?.action?.classlist}} inline-confirm-result-icon\"></i>\r\n <div [innerHTML]=\"status?.message | translate\"></div>\r\n </div>\r\n <div class=\"d-flex pt-2 mt-auto\">\r\n <ec-button id=\"inlineConfirmClose\"\r\n label=\"Close\"\r\n type=\"secondary\"\r\n class=\"ml-auto\"\r\n (clicked)=\"status?.action?.onClick!()\"\r\n [autofocus]=\"true\">\r\n </ec-button>\r\n </div>\r\n </section>\r\n</ng-template>", styles: [":host{width:100%;display:flex}.confirm-content{padding:1.5rem;display:flex;flex-direction:column}.inline-confirm-result-icon{margin:.0625rem .25rem .0625rem 0}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: ButtonComponent, selector: "ec-button", inputs: ["id", "disabled", "icon", "label", "badge", "tabindex", "type", "pending", "pendingIcon", "customTemplate", "isSubmit", "autofocus"], outputs: ["clicked"] }, { kind: "component", type: TextboxComponent, selector: "ec-textbox", inputs: ["autocomplete", "type", "placeholder", "maxlength", "minlength", "rows", "selectOnAutofocus", "upperCase"] }, { kind: "component", type: ViewOverlayComponent, selector: "[ecOverlay]", inputs: ["status", "message", "action", "noDataTemplate", "displayAsMask", "overlayClassList"] }, { kind: "component", type: BannerComponent, selector: "ec-banner", inputs: ["hidden", "id", "type", "bannerStyle", "title", "text", "list", "showCloseBtn", "autoHideOnClose", "customIcon", "rememberClosed"], outputs: ["closed"] }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }] });
5331
+ ConfirmComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ConfirmComponent, selector: "ec-confirm", inputs: { context: "context" }, outputs: { onDialogSave: "onDialogSave", onDialogCancel: "onDialogCancel" }, ngImport: i0, template: "<section ecOverlay\r\n [status]=\"status?.status\"\r\n [message]=\"status?.message\"\r\n [action]=\"status?.action\"\r\n [noDataTemplate]=\"inlineConfirmResult\"\r\n overlayClassList=\"p-0\"\r\n class=\"bg-body flex-grow d-flex\">\r\n <form [formGroup]=\"formGroup\" class=\"flex-grow flex-column confirm-content text-body-1\">\r\n <section class=\"flex-grow\">\r\n <h2 class=\"font-weight-bold mb-3\" *ngIf=\"context?.title\">{{context?.title}}</h2>\r\n <ec-banner *ngIf=\"error\" [text]=\"error | translate\" bannerStyle=\"normal\" class=\"mb-3\"></ec-banner>\r\n <div *ngIf=\"context?.message\" [innerHtml]=\"context?.message | translate\" class=\"mb-3\"></div>\r\n \r\n <ec-checkbox *ngIf=\"context?.checkConfirm\"\r\n [formModel]=\"formGroup.get('checkbox')\"\r\n name=\"confirmCheckbox\"\r\n [label]=\"context?.checkboxText\"\r\n [autofocus]=\"true\"\r\n ></ec-checkbox>\r\n <div *ngIf=\"showTextBox\" [innerHtml]=\"context.confirmLabel\" class=\"mb-3\"></div>\r\n <ec-textbox id=\"confirmTextbox\"\r\n *ngIf=\"(context?.textboxType && !context?.checkConfirm) || showTextBox\"\r\n [autofocus]=\"true\"\r\n [formModel]=\"formGroup.get('textbox')\"\r\n [required]=\"context?.textboxRequired\"\r\n [label]=\"context?.textboxLabel\"\r\n [type]=\"context?.textboxType\"\r\n [rows]=\"context?.textareaRows\"\r\n [placeholder]=\"context?.textboxPlaceholder\"\r\n [upperCase]=\"context?.textboxUppercase\">\r\n </ec-textbox>\r\n </section>\r\n <footer class=\"mt-auto flex-shrink d-flex py-2 flex-row-reverse\">\r\n <ec-button id=\"saveConfirmButton\"\r\n class=\"ml-2\"\r\n [type]=\"context?.saveButtonType ? context?.saveButtonType : 'primary'\"\r\n [label]=\"context?.saveLabel ? context?.saveLabel : 'Save'\"\r\n [autofocus]=\"!context?.textboxType\"\r\n [isSubmit]=\"context?.saveOnEnter\"\r\n (clicked)=\"onSave('primary')\">\r\n </ec-button>\r\n <ec-button id=\"alternateSaveConfirmButton\"\r\n *ngIf=\"context?.alternateSaveLabel\"\r\n class=\"ml-2\"\r\n [type]=\"context?.alternateSaveButtonType ? context?.alternateSaveButtonType : 'primary'\"\r\n [label]=\"context?.alternateSaveLabel\"\r\n (clicked)=\"onSave('alternate')\">\r\n </ec-button>\r\n <ec-button *ngIf=\"!context?.hideCancel\"\r\n id=\"cancelConfirmButton\"\r\n class=\"ml-auto\"\r\n type=\"secondary\"\r\n [label]=\"context?.cancelLabel ? context?.cancelLabel : 'Cancel'\"\r\n (clicked)=\"onCancel()\">\r\n </ec-button>\r\n </footer>\r\n </form>\r\n</section>\r\n\r\n<ng-template #inlineConfirmResult>\r\n <section class=\"flex-grow align-self-stretch confirm-content text-body-1\">\r\n <div class=\"d-flex\">\r\n <i class=\"ec-icon {{status?.action?.icon}} {{status?.action?.classlist}} inline-confirm-result-icon\"></i>\r\n <div [innerHTML]=\"status?.message | translate\"></div>\r\n </div>\r\n <div class=\"d-flex pt-2 mt-auto\">\r\n <ec-button id=\"inlineConfirmClose\"\r\n label=\"Close\"\r\n type=\"secondary\"\r\n class=\"ml-auto\"\r\n (clicked)=\"status?.action?.onClick!()\"\r\n [autofocus]=\"true\">\r\n </ec-button>\r\n </div>\r\n </section>\r\n</ng-template>", styles: [":host{width:100%;display:flex}.confirm-content{padding:1.5rem;display:flex;flex-direction:column}.inline-confirm-result-icon{margin:.0625rem .25rem .0625rem 0}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: ButtonComponent, selector: "ec-button", inputs: ["id", "disabled", "icon", "label", "badge", "tabindex", "type", "pending", "pendingIcon", "customTemplate", "isSubmit", "autofocus"], outputs: ["clicked"] }, { kind: "component", type: TextboxComponent, selector: "ec-textbox", inputs: ["autocomplete", "type", "placeholder", "maxlength", "minlength", "rows", "selectOnAutofocus", "upperCase"] }, { kind: "component", type: ViewOverlayComponent, selector: "[ecOverlay]", inputs: ["status", "message", "action", "noDataTemplate", "displayAsMask", "overlayClassList"] }, { kind: "component", type: BannerComponent, selector: "ec-banner", inputs: ["hidden", "id", "type", "bannerStyle", "title", "text", "list", "showCloseBtn", "autoHideOnClose", "customIcon", "rememberClosed"], outputs: ["closed"] }, { kind: "component", type: CheckboxComponent, selector: "ec-checkbox", inputs: ["name", "dependentCheckboxesGroup", "ignoreDisabledDependents"] }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }] });
5300
5332
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfirmComponent, decorators: [{
5301
5333
  type: Component,
5302
- args: [{ selector: 'ec-confirm', template: "<section ecOverlay\r\n [status]=\"status?.status\"\r\n [message]=\"status?.message\"\r\n [action]=\"status?.action\"\r\n [noDataTemplate]=\"inlineConfirmResult\"\r\n overlayClassList=\"p-0\"\r\n class=\"bg-body flex-grow d-flex\">\r\n <form [formGroup]=\"formGroup\" class=\"flex-grow flex-column confirm-content text-body-1\">\r\n <section class=\"flex-grow\">\r\n <h2 class=\"font-weight-bold mb-3\" *ngIf=\"context?.title\">{{context?.title}}</h2>\r\n <ec-banner *ngIf=\"error\" [text]=\"error | translate\" bannerStyle=\"normal\" class=\"mb-3\"></ec-banner>\r\n <div *ngIf=\"context?.message\" [innerHtml]=\"context?.message | translate\" class=\"mb-3\"></div>\r\n <ec-textbox id=\"confirmTextbox\"\r\n *ngIf=\"context?.textboxType\"\r\n [autofocus]=\"true\"\r\n [formModel]=\"formGroup.get('textbox')\"\r\n [required]=\"context?.textboxRequired\"\r\n [label]=\"context?.textboxLabel\"\r\n [type]=\"context?.textboxType\"\r\n [rows]=\"context?.textareaRows\"\r\n [placeholder]=\"context?.textboxPlaceholder\"\r\n [upperCase]=\"context?.textboxUppercase\">\r\n </ec-textbox>\r\n </section>\r\n <footer class=\"mt-auto flex-shrink d-flex py-2 flex-row-reverse\">\r\n <ec-button id=\"saveConfirmButton\"\r\n class=\"ml-2\"\r\n [type]=\"context?.saveButtonType ? context?.saveButtonType : 'primary'\"\r\n [label]=\"context?.saveLabel ? context?.saveLabel : 'Save'\"\r\n [autofocus]=\"!context?.textboxType\"\r\n [isSubmit]=\"context?.saveOnEnter\"\r\n (clicked)=\"onSave('primary')\">\r\n </ec-button>\r\n <ec-button id=\"alternateSaveConfirmButton\"\r\n *ngIf=\"context?.alternateSaveLabel\"\r\n class=\"ml-2\"\r\n [type]=\"context?.alternateSaveButtonType ? context?.alternateSaveButtonType : 'primary'\"\r\n [label]=\"context?.alternateSaveLabel\"\r\n (clicked)=\"onSave('alternate')\">\r\n </ec-button>\r\n <ec-button *ngIf=\"!context?.hideCancel\"\r\n id=\"cancelConfirmButton\"\r\n class=\"ml-auto\"\r\n type=\"secondary\"\r\n [label]=\"context?.cancelLabel ? context?.cancelLabel : 'Cancel'\"\r\n (clicked)=\"onCancel()\">\r\n </ec-button>\r\n </footer>\r\n </form>\r\n</section>\r\n\r\n<ng-template #inlineConfirmResult>\r\n <section class=\"flex-grow align-self-stretch confirm-content text-body-1\">\r\n <div class=\"d-flex\">\r\n <i class=\"ec-icon {{status?.action?.icon}} {{status?.action?.classlist}} inline-confirm-result-icon\"></i>\r\n <div [innerHTML]=\"status?.message | translate\"></div>\r\n </div>\r\n <div class=\"d-flex pt-2 mt-auto\">\r\n <ec-button id=\"inlineConfirmClose\"\r\n label=\"Close\"\r\n type=\"secondary\"\r\n class=\"ml-auto\"\r\n (clicked)=\"status?.action?.onClick!()\"\r\n [autofocus]=\"true\">\r\n </ec-button>\r\n </div>\r\n </section>\r\n</ng-template>", styles: [":host{width:100%;display:flex}.confirm-content{padding:1.5rem;display:flex;flex-direction:column}.inline-confirm-result-icon{margin:.0625rem .25rem .0625rem 0}\n"] }]
5334
+ args: [{ selector: 'ec-confirm', template: "<section ecOverlay\r\n [status]=\"status?.status\"\r\n [message]=\"status?.message\"\r\n [action]=\"status?.action\"\r\n [noDataTemplate]=\"inlineConfirmResult\"\r\n overlayClassList=\"p-0\"\r\n class=\"bg-body flex-grow d-flex\">\r\n <form [formGroup]=\"formGroup\" class=\"flex-grow flex-column confirm-content text-body-1\">\r\n <section class=\"flex-grow\">\r\n <h2 class=\"font-weight-bold mb-3\" *ngIf=\"context?.title\">{{context?.title}}</h2>\r\n <ec-banner *ngIf=\"error\" [text]=\"error | translate\" bannerStyle=\"normal\" class=\"mb-3\"></ec-banner>\r\n <div *ngIf=\"context?.message\" [innerHtml]=\"context?.message | translate\" class=\"mb-3\"></div>\r\n \r\n <ec-checkbox *ngIf=\"context?.checkConfirm\"\r\n [formModel]=\"formGroup.get('checkbox')\"\r\n name=\"confirmCheckbox\"\r\n [label]=\"context?.checkboxText\"\r\n [autofocus]=\"true\"\r\n ></ec-checkbox>\r\n <div *ngIf=\"showTextBox\" [innerHtml]=\"context.confirmLabel\" class=\"mb-3\"></div>\r\n <ec-textbox id=\"confirmTextbox\"\r\n *ngIf=\"(context?.textboxType && !context?.checkConfirm) || showTextBox\"\r\n [autofocus]=\"true\"\r\n [formModel]=\"formGroup.get('textbox')\"\r\n [required]=\"context?.textboxRequired\"\r\n [label]=\"context?.textboxLabel\"\r\n [type]=\"context?.textboxType\"\r\n [rows]=\"context?.textareaRows\"\r\n [placeholder]=\"context?.textboxPlaceholder\"\r\n [upperCase]=\"context?.textboxUppercase\">\r\n </ec-textbox>\r\n </section>\r\n <footer class=\"mt-auto flex-shrink d-flex py-2 flex-row-reverse\">\r\n <ec-button id=\"saveConfirmButton\"\r\n class=\"ml-2\"\r\n [type]=\"context?.saveButtonType ? context?.saveButtonType : 'primary'\"\r\n [label]=\"context?.saveLabel ? context?.saveLabel : 'Save'\"\r\n [autofocus]=\"!context?.textboxType\"\r\n [isSubmit]=\"context?.saveOnEnter\"\r\n (clicked)=\"onSave('primary')\">\r\n </ec-button>\r\n <ec-button id=\"alternateSaveConfirmButton\"\r\n *ngIf=\"context?.alternateSaveLabel\"\r\n class=\"ml-2\"\r\n [type]=\"context?.alternateSaveButtonType ? context?.alternateSaveButtonType : 'primary'\"\r\n [label]=\"context?.alternateSaveLabel\"\r\n (clicked)=\"onSave('alternate')\">\r\n </ec-button>\r\n <ec-button *ngIf=\"!context?.hideCancel\"\r\n id=\"cancelConfirmButton\"\r\n class=\"ml-auto\"\r\n type=\"secondary\"\r\n [label]=\"context?.cancelLabel ? context?.cancelLabel : 'Cancel'\"\r\n (clicked)=\"onCancel()\">\r\n </ec-button>\r\n </footer>\r\n </form>\r\n</section>\r\n\r\n<ng-template #inlineConfirmResult>\r\n <section class=\"flex-grow align-self-stretch confirm-content text-body-1\">\r\n <div class=\"d-flex\">\r\n <i class=\"ec-icon {{status?.action?.icon}} {{status?.action?.classlist}} inline-confirm-result-icon\"></i>\r\n <div [innerHTML]=\"status?.message | translate\"></div>\r\n </div>\r\n <div class=\"d-flex pt-2 mt-auto\">\r\n <ec-button id=\"inlineConfirmClose\"\r\n label=\"Close\"\r\n type=\"secondary\"\r\n class=\"ml-auto\"\r\n (clicked)=\"status?.action?.onClick!()\"\r\n [autofocus]=\"true\">\r\n </ec-button>\r\n </div>\r\n </section>\r\n</ng-template>", styles: [":host{width:100%;display:flex}.confirm-content{padding:1.5rem;display:flex;flex-direction:column}.inline-confirm-result-icon{margin:.0625rem .25rem .0625rem 0}\n"] }]
5303
5335
  }], ctorParameters: function () { return []; }, propDecorators: { context: [{
5304
5336
  type: Input
5305
5337
  }], onDialogSave: [{
@@ -7113,7 +7145,7 @@ class TableComponent {
7113
7145
  if (this.sortable && changes.sort && changes.sort.currentValue && !changes.sort.firstChange) {
7114
7146
  const newValue = changes.sort.currentValue;
7115
7147
  if (!this.currentSort || !isEqual(newValue, this.currentSort)) {
7116
- this.onSort(newValue.field, newValue.direction);
7148
+ this.onSort(newValue);
7117
7149
  }
7118
7150
  }
7119
7151
  }
@@ -7162,7 +7194,14 @@ class TableComponent {
7162
7194
  if (th.classList.contains('is-resizable') && event.target && event.target.classList.contains('handle')) {
7163
7195
  return;
7164
7196
  }
7165
- this.onSort(field);
7197
+ let direction;
7198
+ if (th.classList.contains('is-sorted-desc')) {
7199
+ direction = 'asc';
7200
+ }
7201
+ else {
7202
+ direction = 'desc';
7203
+ }
7204
+ this.onSort({ field, direction });
7166
7205
  });
7167
7206
  // Store unlisten function to remove listener when component is destroyed
7168
7207
  this.unlisteners.push(unlisten);
@@ -7174,7 +7213,7 @@ class TableComponent {
7174
7213
  });
7175
7214
  // Set the initial sort
7176
7215
  if (this.sort) {
7177
- this.onSort(this.sort.field, this.sort.direction);
7216
+ this.onSort(this.sort);
7178
7217
  }
7179
7218
  }
7180
7219
  /**
@@ -7183,32 +7222,29 @@ class TableComponent {
7183
7222
  * Emit the current field and direction of the sorted column
7184
7223
  * @param field
7185
7224
  */
7186
- onSort(field, direction) {
7187
- const th = this.sortableCols[field];
7188
- if (!th) {
7189
- return;
7190
- }
7191
- if (this.currentSort && this.currentSort.field !== field) {
7192
- this.renderer.removeClass(this.sortableCols[this.currentSort.field], `is-sorted-${this.currentSort.direction}`);
7193
- }
7194
- if (th.classList.contains('is-sorted-desc')) {
7195
- this.renderer.removeClass(th, 'is-sorted-desc');
7196
- if (!direction) {
7197
- direction = 'asc';
7198
- }
7225
+ onSort(sort) {
7226
+ this.clearSort();
7227
+ if (Array.isArray(sort)) {
7228
+ sort.forEach(s => this.applySort(s));
7199
7229
  }
7200
7230
  else {
7201
- if (th.classList.contains('is-sorted-asc')) {
7202
- this.renderer.removeClass(th, 'is-sorted-asc');
7203
- }
7204
- if (!direction) {
7205
- direction = 'desc';
7206
- }
7231
+ this.applySort(sort);
7232
+ }
7233
+ this.currentSort = cloneDeep(sort);
7234
+ this.sortChange.emit(this.currentSort);
7235
+ }
7236
+ clearSort() {
7237
+ Object.values(this.sortableCols).forEach(th => {
7238
+ this.renderer.removeClass(th, `is-sorted-asc`);
7239
+ this.renderer.removeClass(th, `is-sorted-desc`);
7240
+ });
7241
+ }
7242
+ applySort(sort) {
7243
+ const th = this.sortableCols[sort.field];
7244
+ if (!th) {
7245
+ return;
7207
7246
  }
7208
- this.renderer.addClass(th, `is-sorted-${direction}`);
7209
- const sortEvent = { field: field, direction: direction };
7210
- this.currentSort = sortEvent;
7211
- this.sortChange.emit(sortEvent);
7247
+ this.renderer.addClass(th, `is-sorted-${sort.direction}`);
7212
7248
  }
7213
7249
  initSelectable() {
7214
7250
  this.selectionContext.rowCheckboxes.valueChanges.pipe(takeUntil(this.destroyed)).subscribe((value) => {