@fuentis/phoenix-ui 0.0.9-alpha.567 → 0.0.9-alpha.570

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.
@@ -3243,8 +3243,9 @@ function buildFileName(baseKey, ext = 'xlsx') {
3243
3243
  */
3244
3244
  const DEFAULT_MORE_ACTIONS = {
3245
3245
  context: tableButtonContext.MORE,
3246
- type: 'menu',
3246
+ type: tableActionType.MENU,
3247
3247
  buttonType: 'multiselect',
3248
+ label: '',
3248
3249
  items: [
3249
3250
  { key: 'EXPORT_PDF', label: 'ACTION.EXPORT_PDF', icon: 'pi pi-file-pdf' },
3250
3251
  { key: 'EXPORT_EXCEL', label: 'ACTION.EXPORT_EXCEL', icon: 'pi pi-file-excel' },
@@ -3598,6 +3599,22 @@ class TableComponent {
3598
3599
  });
3599
3600
  return sorted;
3600
3601
  }
3602
+ normalizeInitialSort(cfg) {
3603
+ const s = cfg?.initialSort;
3604
+ // NEW style
3605
+ if (Array.isArray(s))
3606
+ return s.filter(x => !!x?.field);
3607
+ if (s && typeof s === 'object' && s.field)
3608
+ return [s];
3609
+ // LEGACY fallback
3610
+ if (cfg?.initialSortField) {
3611
+ return [{
3612
+ field: cfg.initialSortField,
3613
+ order: (cfg.initialSortOrder ?? 1),
3614
+ }];
3615
+ }
3616
+ return [];
3617
+ }
3601
3618
  /**
3602
3619
  * Applies initial sort once:
3603
3620
  * - Uses tableConfiguration.initialSortField if provided
@@ -3612,7 +3629,6 @@ class TableComponent {
3612
3629
  applyInitialSortIfNeeded() {
3613
3630
  if (this.initialSortApplied)
3614
3631
  return;
3615
- // if no data, just render empty fast and stop loading
3616
3632
  if (!this.allData?.length) {
3617
3633
  this.tableData = [];
3618
3634
  this.totalRecords = 0;
@@ -3622,33 +3638,32 @@ class TableComponent {
3622
3638
  }
3623
3639
  const cols = (this.selectedColumns?.length ? this.selectedColumns : this.columns) ?? [];
3624
3640
  if (!cols.length)
3625
- return; // columns not ready yet (ngOnChanges will call again)
3626
- // pick configured or fallback
3627
- const configuredField = this.tableConfiguration?.initialSortField;
3641
+ return;
3642
+ // 1) normalize config
3643
+ const cfgMeta = this.normalizeInitialSort(this.tableConfiguration);
3644
+ // 2) if nothing configured -> fallback first column ASC
3628
3645
  const fallbackField = cols[0]?.field;
3629
- const field = configuredField || fallbackField;
3630
- const exists = cols.some((c) => c?.field === field);
3631
- const finalField = exists ? field : fallbackField;
3632
- // if still no field, just render base
3633
- if (!finalField) {
3646
+ const wantedMeta = (cfgMeta.length ? cfgMeta : [{ field: fallbackField, order: 1 }])
3647
+ .filter(m => !!m?.field);
3648
+ // 3) keep only fields that exist in columns
3649
+ const validMeta = wantedMeta.filter(m => cols.some((c) => c?.field === m.field));
3650
+ const finalMeta = validMeta.length ? validMeta : [{ field: fallbackField, order: 1 }];
3651
+ if (!finalMeta[0]?.field) {
3634
3652
  this.tableData = this.allData;
3635
3653
  this.totalRecords = this.tableData.length;
3636
3654
  this.initialSortLoading = false;
3637
3655
  this.initialSortApplied = true;
3638
- this.cdr.markForCheck();
3639
3656
  return;
3640
3657
  }
3641
- const meta = [{ field: finalField, order: 1 }];
3642
3658
  try {
3643
3659
  if (this.dt)
3644
- this.dt.multiSortMeta = meta;
3660
+ this.dt.multiSortMeta = finalMeta;
3645
3661
  }
3646
3662
  catch { }
3647
- this.lastSortKey = JSON.stringify(meta);
3663
+ this.lastSortKey = JSON.stringify(finalMeta);
3648
3664
  this.initialSortApplied = true;
3649
- this.initialSortFieldApplied = finalField;
3650
- // keep loading true until worker returns
3651
- this.runWorkerSort(meta);
3665
+ this.initialSortFieldApplied = finalMeta[0].field;
3666
+ this.runWorkerSort(finalMeta);
3652
3667
  }
3653
3668
  // ============================================================
3654
3669
  // SEARCH / FILTER
@@ -3859,8 +3874,9 @@ class TableComponent {
3859
3874
  * Some tables allow click on first N columns to open details.
3860
3875
  */
3861
3876
  isColumnClickable(columnIndex) {
3862
- return (columnIndex < (this.tableConfiguration?.clickableColumnCount ?? 1) &&
3863
- this.tableConfiguration?.hasCellClick);
3877
+ const max = this.tableConfiguration?.clickableColumnCount ?? 1;
3878
+ const enabled = this.tableConfiguration?.hasCellClick ?? false;
3879
+ return columnIndex < max && enabled;
3864
3880
  }
3865
3881
  /**
3866
3882
  * Utility for copy icons inside cells (prevents row-click).
@@ -4375,6 +4391,9 @@ class ObjectItemDialogComponent {
4375
4391
  key: 'asd',
4376
4392
  rows: 20,
4377
4393
  selectionType: tableSelectionType.RADIO_BTN,
4394
+ actions: [],
4395
+ exportTable: false,
4396
+ filterConfiguration: []
4378
4397
  };
4379
4398
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: ObjectItemDialogComponent, deps: [{ token: i1$2.DynamicDialogRef }, { token: i1$2.DynamicDialogConfig }], target: i0.ɵɵFactoryTarget.Component });
4380
4399
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: ObjectItemDialogComponent, isStandalone: true, selector: "phoenix-object-item-dialog", viewQueries: [{ propertyName: "table", first: true, predicate: ["table"], descendants: true }], ngImport: i0, template: "<div style=\"overflow: hidden; padding-bottom: 50px\">\n <phoenix-table\n #table\n [data]=\"tableData\"\n [columns]=\"columns\"\n [tableConfiguration]=\"tableConfiguration\"\n (checkBoxSelection)=\"onSelectionChanged($event)\"\n >\n </phoenix-table>\n</div>\n<div class=\"absolute bottom-0 right-0 p-4\">\n <div class=\"flex gap-2\">\n <ng-container *ngFor=\"let action of actions\">\n <p-button\n [label]=\"action.label | translate\"\n [icon]=\"action.icon || ''\"\n [severity]=\"action.severity || 'primary'\"\n [disabled]=\"action.id === 'assign' && !hasSelection\"\n [id]=\"action.id\"\n (onClick)=\"actionClick(action.id)\"\n size=\"small\"\n ></p-button>\n </ng-container>\n</div>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: TableModule }, { kind: "ngmodule", type: TooltipModule }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: TableComponent, selector: "phoenix-table", inputs: ["columns", "selectedColumnsInput", "tableConfiguration", "filters", "data"], outputs: ["actionClick", "rowSelection", "checkBoxSelection", "saveColumns"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i3.Button, selector: "p-button", inputs: ["hostName", "type", "badge", "disabled", "raised", "rounded", "text", "plain", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "iconPos", "icon", "label", "loading", "loadingIcon", "severity", "buttonProps", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: i3$2.TranslatePipe, name: "translate" }] });