@masterteam/client-components 0.0.119 → 0.0.121

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.
package/README.md CHANGED
@@ -223,6 +223,9 @@ contextMenu: {
223
223
  grid's own menu.
224
224
  - A row with nothing to show (`open: false`, no link, no action) keeps the
225
225
  grid's / browser's menu: the right-click is only claimed when the menu opens.
226
+ - `excludeAction(action)` leaves row actions out of this menu (they stay in
227
+ the ⋮ menu) — e.g. a host whose ⋮ menu has its own "Open in a new tab" /
228
+ "Copy link" actions, which this menu already lists in its navigation section.
226
229
  - Items are `mt-button`s, like the ⋮ menu. The menu adds nothing to the page
227
230
  (no anchor, no document listener) until it first opens.
228
231
  - Mouse only: the ContextMenu key / Shift+F10 keep the grid's menu; keyboard
@@ -13,7 +13,7 @@ import { isSectionKey, CalculatedValueHistory, mergeStakeholderNameEntities, res
13
13
  import { applyGridViewState, captureGridViewState } from '@masterteam/data-grid';
14
14
  import { MtTableText, mtEntityColumn, mtActionsColumn, MtStandardGridComponent } from '@masterteam/data-table';
15
15
  import { MtTablePreferences } from '@masterteam/data-table/legacy';
16
- import { TableValueResolver, TableExportService, TableGroupingController, TableCaption } from '@masterteam/components/table';
16
+ import { TableValueResolver, TableExportService, TableGroupingController, resolveEntityColumnExcelCell, TableCaption } from '@masterteam/components/table';
17
17
  import { toSignal } from '@angular/core/rxjs-interop';
18
18
  import { Card } from '@masterteam/components/card';
19
19
  import { EmptyState } from '@masterteam/components/empty-state';
@@ -1933,6 +1933,18 @@ function isDestructiveAction(action) {
1933
1933
  return (action.color === 'danger' ||
1934
1934
  action.confirmation?.confirmationType === 'delete');
1935
1935
  }
1936
+ /**
1937
+ * Whether a menu draws a divider above `menu[index]`: at the first destructive
1938
+ * item, and under an item flagged `dividerAfter`. Never at the top, and never
1939
+ * at the bottom (a divider is always drawn above an item).
1940
+ */
1941
+ function dividerAbove(menu, index) {
1942
+ if (index <= 0 || !menu[index]) {
1943
+ return false;
1944
+ }
1945
+ return (!!menu[index - 1]?.dividerAfter ||
1946
+ (isDestructiveAction(menu[index]) && !isDestructiveAction(menu[index - 1])));
1947
+ }
1936
1948
  /**
1937
1949
  * A row's menu actions: hidden ones dropped, destructive ones last (the ⋮
1938
1950
  * menu's order), the page's order kept within each group.
@@ -2210,14 +2222,12 @@ class ClientListCardsView {
2210
2222
  this.bucket().filterTerm.set('');
2211
2223
  this.bucket().filters.set({});
2212
2224
  }
2213
- /** True at the first destructive item — where the divider is drawn. */
2225
+ /**
2226
+ * Whether a divider is drawn above this item: the first destructive one, or
2227
+ * the one after an item flagged `dividerAfter`.
2228
+ */
2214
2229
  isFirstDestructiveCardAction(card, index) {
2215
- const menu = this.menuActionsForCard(card);
2216
- const action = menu[index];
2217
- return (index > 0 &&
2218
- !!action &&
2219
- isDestructiveAction(action) &&
2220
- !isDestructiveAction(menu[index - 1]));
2230
+ return dividerAbove(this.menuActionsForCard(card), index);
2221
2231
  }
2222
2232
  showCardActionsMenu(card) {
2223
2233
  return (this.isCardActionsLoading(card) || this.actionsFor(card).menu.length > 0);
@@ -2514,6 +2524,7 @@ class ClientListCardsView {
2514
2524
  columns: this.columns(),
2515
2525
  filename: this.resolveExportFilename(),
2516
2526
  resolveValue: (row, column) => this.resolveCellValue(row, column),
2527
+ resolveExcelCell: resolveEntityColumnExcelCell,
2517
2528
  });
2518
2529
  }
2519
2530
  printPdf() {
@@ -2770,7 +2781,13 @@ class ClientListRowMenu {
2770
2781
  }, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
2771
2782
  menuActions = computed(() => {
2772
2783
  const row = this.row();
2773
- return row ? orderMenuActions(this.actions(), row) : [];
2784
+ if (!row)
2785
+ return [];
2786
+ const exclude = this.config()?.excludeAction;
2787
+ const actions = exclude
2788
+ ? this.actions().filter((action) => !exclude(action))
2789
+ : this.actions();
2790
+ return orderMenuActions(actions, row);
2774
2791
  }, ...(ngDevMode ? [{ debugName: "menuActions" }] : /* istanbul ignore next */ []));
2775
2792
  empty = computed(() => !this.hasNavigation() &&
2776
2793
  !this.isLoading() &&
@@ -2871,12 +2888,12 @@ class ClientListRowMenu {
2871
2888
  .then(() => navigator.clipboard.writeText(link))
2872
2889
  .then(() => toast.success(this.transloco.translate(`${TEXT}.linkCopied`)), () => toast.error(this.transloco.translate(`${TEXT}.copyFailed`)));
2873
2890
  }
2874
- /** The divider goes above the first destructive item, never at the top. */
2891
+ /**
2892
+ * A divider goes above the first destructive item and under an item flagged
2893
+ * `dividerAfter`; never at the top.
2894
+ */
2875
2895
  firstDestructive(index) {
2876
- const menu = this.menuActions();
2877
- return (index > 0 &&
2878
- isDestructiveAction(menu[index]) &&
2879
- !isDestructiveAction(menu[index - 1]));
2896
+ return dividerAbove(this.menuActions(), index);
2880
2897
  }
2881
2898
  /** The action is running (its `loading`), as the ⋮ menu shows it. */
2882
2899
  busy(action) {