@trismegisto/angular 2.0.1 → 2.1.1

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
@@ -107,6 +107,10 @@ use o que o resto do app já usa.
107
107
  - **Sem zone.js:** a lib é toda OnPush + signals e funciona com `provideZonelessChangeDetection()`.
108
108
  - **Overlay próprio movido para o `<body>`** precisa de `copyThemeScope()` (`@trismegisto/primitives`) para não
109
109
  perder o tema.
110
+ - **Dado do servidor nunca vira marcação.** Texto do catálogo com HTML e parâmetro vai a `[innerHTML]` por
111
+ `formatMessageHtml` (escapa o parâmetro), nunca `formatMessage`; o `check-strings` da lib reprova o contrário.
112
+ `hm-session-recovery` só navega para `http(s)` e, com `allowedOrigins`, só para a mesma origem ou as listadas:
113
+ declare a lista quando `origin` vier da URL. Ação destrutiva por linha no `hm-data-grid` leva `confirm`.
110
114
 
111
115
  ## Skill para agentes de IA
112
116
 
@@ -8,6 +8,7 @@ import { AlertComponent } from '@trismegisto/angular/alert';
8
8
  import { ButtonComponent } from '@trismegisto/angular/button';
9
9
  import { HermesDragDropService, SortableDirective, DraggableDirective, DragHandleDirective } from '@trismegisto/angular/drag-drop';
10
10
  import { DropdownComponent, DropdownTriggerDirective, DropdownIfOpenDirective, DropdownMenuComponent } from '@trismegisto/angular/dropdown';
11
+ import { HermesDialogService } from '@trismegisto/angular/dialog';
11
12
  import { IconButtonComponent } from '@trismegisto/angular/icon-button';
12
13
  import { MenuComponent } from '@trismegisto/angular/menu';
13
14
  import { MenuButtonComponent } from '@trismegisto/angular/menu-button';
@@ -446,6 +447,15 @@ function headerFloor(th) {
446
447
  const padding = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
447
448
  return Math.ceil(end - start + padding);
448
449
  }
450
+ /**
451
+ * Largura que uma coluna pede no encaixe automático, a partir do que foi medido no modo de medição (`measured`, o
452
+ * conteúdo sem quebra). Coluna com `initialWidth` (`fixed`): a largura inicial (`current`) é o MÍNIMO, não o tamanho —
453
+ * se o conteúdo pede mais (ex.: o grupo de botões da coluna de ações), ela cresce até caber. Antes o conteúdo dela
454
+ * não era medido: os botões passavam da largura inicial, vazavam da célula e o "…" do grupo ficava fora da tela.
455
+ */
456
+ function columnNaturalWidth(fixed, current, floor, measured) {
457
+ return fixed ? Math.max(current, floor, measured) : Math.max(measured, floor);
458
+ }
449
459
  /** Soma das colunas de sistema (seleção, detalhe, ações), que têm largura própria no CSS. */
450
460
  function systemColumnsWidth(table) {
451
461
  return Array.from(table.querySelectorAll('thead tr > th:not([data-key])')).reduce((sum, th) => sum + th.getBoundingClientRect().width, 0);
@@ -676,9 +686,10 @@ class GridColumnSizingFeature {
676
686
  if (!th)
677
687
  continue;
678
688
  const floor = this.clamp(headerFloor(th));
679
- // Coluna com `initialWidth`: o tamanho atual dela é o mínimo, e ela não entra na partilha.
680
- const content = fixedKeys.has(key) ? Math.max(current.get(key) ?? 0, floor) : th.getBoundingClientRect().width;
681
- natural.set(key, this.clamp(Math.max(content, floor)));
689
+ // Coluna com `initialWidth`: o tamanho atual dela é o mínimo (cresce se o conteúdo pedir mais), e ela não
690
+ // entra na partilha.
691
+ const content = columnNaturalWidth(fixedKeys.has(key), current.get(key) ?? 0, floor, th.getBoundingClientRect().width);
692
+ natural.set(key, this.clamp(content));
682
693
  floors.set(key, floor);
683
694
  }
684
695
  return { natural, floors };
@@ -1740,8 +1751,6 @@ class GridVirtualFeature {
1740
1751
  }
1741
1752
  }
1742
1753
 
1743
- /** Tipos públicos do `hm-data-grid` — reexportados por `data-grid.component.ts`. */
1744
-
1745
1754
  let gridSequence = 0;
1746
1755
  /** Clique nestes alvos é do controle, não da linha. */
1747
1756
  const INTERACTIVE = 'button, a, input, select, textarea, label, [role="button"]';
@@ -1951,7 +1960,19 @@ class DataGridComponent {
1951
1960
  pinned: this.pinnedColumns,
1952
1961
  manuallySized: () => this.sizing.manuallySized,
1953
1962
  });
1954
- rowMenu = new GridRowActionsFeature(this.rowActions, (action, row) => this.actionTriggered.emit({ action, row }));
1963
+ dialogs = inject(HermesDialogService);
1964
+ rowMenu = new GridRowActionsFeature(this.rowActions, (action, row) => void this.triggerAction(action, row));
1965
+ /** Emite `actionTriggered`; com `confirm` na ação, só depois que a pessoa confirma no diálogo. */
1966
+ async triggerAction(id, row) {
1967
+ const action = this.rowActions().find((a) => a.id === id);
1968
+ const confirm = typeof action?.confirm === 'function' ? action.confirm(row) : action?.confirm;
1969
+ if (action && confirm) {
1970
+ const ok = await this.dialogs.confirm({ ...confirm, danger: confirm.danger ?? !!action.danger, confirmLabel: confirm.confirmLabel ?? action.label });
1971
+ if (!ok)
1972
+ return;
1973
+ }
1974
+ this.actionTriggered.emit({ action: id, row });
1975
+ }
1955
1976
  // ---------------------------------------------------------------- modelos do template
1956
1977
  cellByKey = computed(() => new Map(this.cellTemplates().map((d) => [d.hmCell(), d.template])), ...(ngDevMode ? [{ debugName: "cellByKey" }] : /* istanbul ignore next */ []));
1957
1978
  headerByKey = computed(() => new Map(this.headerTemplates().map((d) => [d.hmColumnHeader(), d.template])), ...(ngDevMode ? [{ debugName: "headerByKey" }] : /* istanbul ignore next */ []));