@nanahoshi/mona-ui 0.51.0 → 0.52.0

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.
@@ -1,5 +1,5 @@
1
- import { $ as getGridCellText, A as gridHeaderThemeVariants, C as gridHeaderGroupTableRowThemeVariants, D as gridHeaderTableColumnWrapThemeVariants, E as gridHeaderTableColumnTitleThemeVariants, F as gridNoDataThemeVariants, G as observeGridCellTabStops, H as GridLogicalCellDirective, J as getColumnGroupDepth, K as GridLockedCellDirective, O as gridHeaderTableRowThemeVariants, R as gridSelectAllCellThemeVariants, S as gridHeaderGroupSpacerCellThemeVariants, T as gridHeaderTableCellThemeVariants, W as isKeyboardEntryElement, X as getColumnStepTarget, Y as getColumnGroups, Z as getSiblingRuns, _ as gridFooterThemeVariants, at as GridEditEvent, c as gridColumnActionsThemeVariants, ct as RowEditEvent, d as gridColumnResizerThemeVariants, et as RowReorderEvent, f as gridFilterRowCellThemeVariants, g as gridFooterTableThemeVariants, it as GridRemoveEvent, k as gridHeaderTableThemeVariants, l as gridColumnDragPreviewThemeVariants, lt as CellEditEvent, nt as GRID_DEFAULT_MESSAGES, ot as GridCancelEvent, p as gridFilterRowHeaderCellThemeVariants, q as GridService, rt as GridSaveEvent, st as GridAddEvent, t as gridBaseThemeVariants, tt as GridNavigationService, u as gridColumnDropHintThemeVariants, v as gridGroupPanelPlaceholderThemeVariants, w as gridHeaderGroupTitleThemeVariants, x as gridHeaderGroupCellThemeVariants, y as gridGroupPanelThemeVariants } from "./grid.styles-D6jP3vwD.mjs";
2
- import { n as removeGridRow, t as GridColgroupComponent } from "./grid-colgroup.component-BFbiAvkG.mjs";
1
+ import { $ as getGridCellText, A as gridHeaderThemeVariants, C as gridHeaderGroupTableRowThemeVariants, D as gridHeaderTableColumnWrapThemeVariants, E as gridHeaderTableColumnTitleThemeVariants, F as gridNoDataThemeVariants, G as observeGridCellTabStops, H as GridLogicalCellDirective, J as getColumnGroupDepth, K as GridLockedCellDirective, O as gridHeaderTableRowThemeVariants, R as gridSelectAllCellThemeVariants, S as gridHeaderGroupSpacerCellThemeVariants, T as gridHeaderTableCellThemeVariants, W as isKeyboardEntryElement, X as getColumnStepTarget, Y as getColumnGroups, Z as getSiblingRuns, _ as gridFooterThemeVariants, at as GridEditEvent, c as gridColumnActionsThemeVariants, ct as RowEditEvent, d as gridColumnResizerThemeVariants, et as RowReorderEvent, f as gridFilterRowCellThemeVariants, g as gridFooterTableThemeVariants, it as GridRemoveEvent, k as gridHeaderTableThemeVariants, l as gridColumnDragPreviewThemeVariants, lt as CellEditEvent, nt as GRID_DEFAULT_MESSAGES, ot as GridCancelEvent, p as gridFilterRowHeaderCellThemeVariants, q as GridService, rt as GridSaveEvent, st as GridAddEvent, t as gridBaseThemeVariants, tt as GridNavigationService, u as gridColumnDropHintThemeVariants, v as gridGroupPanelPlaceholderThemeVariants, w as gridHeaderGroupTitleThemeVariants, x as gridHeaderGroupCellThemeVariants, y as gridGroupPanelThemeVariants } from "./grid.styles-DBLUtq2X.mjs";
2
+ import { n as removeGridRow, t as GridColgroupComponent } from "./grid-colgroup.component-Ccz4jNGD.mjs";
3
3
  import { DOCUMENT, NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
4
4
  import * as i0 from "@angular/core";
5
5
  import { Component, DOCUMENT as DOCUMENT$1, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, LOCALE_ID, PLATFORM_ID, Pipe, TemplateRef, afterEveryRender, afterNextRender, booleanAttribute, computed, contentChild, contentChildren, effect, forwardRef, inject, input, isDevMode, linkedSignal, model, output, signal, untracked, viewChild, viewChildren } from "@angular/core";
@@ -5965,31 +5965,29 @@ const TOOLBAR_ITEM_SELECTOR = ":is(button, input, select, textarea, a[href], [ta
5965
5965
  var GridComponent = class GridComponent {
5966
5966
  #destroyRef;
5967
5967
  #document;
5968
- #fitViewInitialScrollbarGutterWidth;
5969
- #fitViewScrollbarSyncResolved;
5970
5968
  #gridNavigationService;
5971
5969
  #hostElementRef;
5972
5970
  #injector;
5973
5971
  #liveAnnouncer;
5974
- #manuallyResized;
5975
5972
  #registeredFooterScrollElement;
5976
5973
  #dragCancelled;
5977
5974
  #dragKeySubscription;
5975
+ #fitViewHeaderWidth;
5976
+ #fitViewRefitScheduled;
5978
5977
  #toolbarActiveItem;
5979
5978
  #toolbarActiveItemIndex;
5980
5979
  constructor() {
5981
5980
  this.#destroyRef = inject(DestroyRef);
5982
5981
  this.#document = inject(DOCUMENT$1);
5983
- this.#fitViewInitialScrollbarGutterWidth = signal(null, ...ngDevMode ? [{ debugName: "#fitViewInitialScrollbarGutterWidth" }] : /* istanbul ignore next */ []);
5984
- this.#fitViewScrollbarSyncResolved = signal(false, ...ngDevMode ? [{ debugName: "#fitViewScrollbarSyncResolved" }] : /* istanbul ignore next */ []);
5985
5982
  this.#gridNavigationService = inject(GridNavigationService);
5986
5983
  this.#hostElementRef = inject(ElementRef);
5987
5984
  this.#injector = inject(Injector);
5988
5985
  this.#liveAnnouncer = injectLiveAnnouncer();
5989
- this.#manuallyResized = signal(false, ...ngDevMode ? [{ debugName: "#manuallyResized" }] : /* istanbul ignore next */ []);
5990
5986
  this.#registeredFooterScrollElement = signal(null, ...ngDevMode ? [{ debugName: "#registeredFooterScrollElement" }] : /* istanbul ignore next */ []);
5991
5987
  this.#dragCancelled = false;
5992
5988
  this.#dragKeySubscription = null;
5989
+ this.#fitViewHeaderWidth = null;
5990
+ this.#fitViewRefitScheduled = false;
5993
5991
  this.#toolbarActiveItem = null;
5994
5992
  this.#toolbarActiveItemIndex = 0;
5995
5993
  this.columnDefinitions = contentChildren(GRID_COLUMN_DEFINITION, {
@@ -6176,7 +6174,6 @@ var GridComponent = class GridComponent {
6176
6174
  this.setDataEffect();
6177
6175
  this.setEditSessionEffect();
6178
6176
  this.setFooterScrollElementEffect();
6179
- this.setFitViewScrollbarSyncEffect();
6180
6177
  afterEveryRender({ write: () => this.syncToolbarFocusTargets() });
6181
6178
  this.#gridNavigationService.setViewport({
6182
6179
  scrollElement: () => this.gridService.bodyScrollElement(),
@@ -6186,7 +6183,7 @@ var GridComponent = class GridComponent {
6186
6183
  this.gridService.gridHeaderElement.set(this.gridHeaderElement().nativeElement);
6187
6184
  this.gridService.headerTableElement.set(this.gridHeaderTableElement().nativeElement);
6188
6185
  this.setInitialCalculatedWidthOfColumns();
6189
- this.#fitViewInitialScrollbarGutterWidth.set(this.gridService.scrollbarGutterWidth());
6186
+ this.#observeHeaderWidth();
6190
6187
  this.gridWidthSet.set(true);
6191
6188
  const stopObservingTabStops = observeGridCellTabStops(this.#hostElementRef.nativeElement);
6192
6189
  this.#destroyRef.onDestroy(stopObservingTabStops);
@@ -6289,10 +6286,11 @@ var GridComponent = class GridComponent {
6289
6286
  }
6290
6287
  onColumnResizeEnd(event) {
6291
6288
  this.resizing.set(false);
6289
+ if (event.newWidth !== event.oldWidth) this.gridService.markColumnSizedByUser(event.column.id);
6290
+ this.#scheduleFitViewRefit();
6292
6291
  this.gridService.columnResize$.next(event);
6293
6292
  }
6294
6293
  onColumnResizeStart() {
6295
- this.#manuallyResized.set(true);
6296
6294
  this.resizing.set(true);
6297
6295
  }
6298
6296
  onColumnSort(column) {
@@ -6403,6 +6401,12 @@ var GridComponent = class GridComponent {
6403
6401
  this.#liveAnnouncer.announce(this.messages().columnMoved(column.title, position));
6404
6402
  this.#refocusHeader(column.id);
6405
6403
  }
6404
+ #observeHeaderWidth() {
6405
+ if (typeof ResizeObserver === "undefined") return;
6406
+ const resizeObserver = new ResizeObserver(() => this.#scheduleFitViewRefit());
6407
+ resizeObserver.observe(this.gridHeaderElement().nativeElement);
6408
+ this.#destroyRef.onDestroy(() => resizeObserver.disconnect());
6409
+ }
6406
6410
  #refocusHeader(columnId) {
6407
6411
  afterNextRender({ write: () => {
6408
6412
  if (!this.#gridNavigationService.focusHeaderCell(columnId)) this.#gridNavigationService.focusActiveCellOrFirstHeader();
@@ -6432,6 +6436,19 @@ var GridComponent = class GridComponent {
6432
6436
  column: visible[0]
6433
6437
  };
6434
6438
  }
6439
+ #scheduleFitViewRefit() {
6440
+ if (this.#fitViewRefitScheduled || this.resizeMethod() !== "fitView") return;
6441
+ this.#fitViewRefitScheduled = true;
6442
+ afterNextRender({
6443
+ earlyRead: () => this.gridHeaderElement().nativeElement.clientWidth,
6444
+ write: (headerWidth) => {
6445
+ this.#fitViewRefitScheduled = false;
6446
+ if (headerWidth === 0 || headerWidth === this.#fitViewHeaderWidth || this.gridService.columnResizeActive()) return;
6447
+ this.#fitViewHeaderWidth = headerWidth;
6448
+ this.gridService.setCalculatedWidths(this.createFitViewWidthMap(headerWidth));
6449
+ }
6450
+ }, { injector: this.#injector });
6451
+ }
6435
6452
  clearDragState() {
6436
6453
  this.dragColumn.set(null);
6437
6454
  this.dropColumn.set(null);
@@ -6442,10 +6459,13 @@ var GridComponent = class GridComponent {
6442
6459
  this.#dragKeySubscription = null;
6443
6460
  }
6444
6461
  createFitViewWidthMap(headerWidth) {
6445
- const flexibleColumns = this.gridService.visibleColumns().where((column) => column.width == null).toArray();
6462
+ const flexibleColumns = [];
6463
+ let availableWidth = headerWidth - this.gridService.leadingStructuralWidth();
6464
+ for (const column of this.gridService.visibleColumns()) if (column.width == null && !this.gridService.isColumnSizedByUser(column.id)) flexibleColumns.push(column);
6465
+ else availableWidth -= this.gridService.getColumnWidth(column);
6446
6466
  if (flexibleColumns.length === 0) return /* @__PURE__ */ new Map();
6447
6467
  const devicePixelRatio = this.gridHeaderElement().nativeElement.ownerDocument.defaultView?.devicePixelRatio ?? 1;
6448
- const totalWidthUnits = Math.max(0, Math.round(headerWidth * devicePixelRatio));
6468
+ const totalWidthUnits = Math.max(0, Math.round(availableWidth * devicePixelRatio));
6449
6469
  const widthByColumnId = /* @__PURE__ */ new Map();
6450
6470
  const baseWidthUnits = Math.floor(totalWidthUnits / flexibleColumns.length);
6451
6471
  let remainingWidthUnits = totalWidthUnits - baseWidthUnits * flexibleColumns.length;
@@ -6518,18 +6538,6 @@ var GridComponent = class GridComponent {
6518
6538
  untracked(() => this.gridService.reconcileEditSession());
6519
6539
  });
6520
6540
  }
6521
- setFitViewScrollbarSyncEffect() {
6522
- effect(() => {
6523
- if (this.resizeMethod() !== "fitView" || !this.gridWidthSet()) return;
6524
- if (this.#fitViewScrollbarSyncResolved() || this.#manuallyResized()) return;
6525
- if (!this.gridService.hasLiveScrollbarGutterWidth()) return;
6526
- const initialScrollbarGutterWidth = this.#fitViewInitialScrollbarGutterWidth();
6527
- if (initialScrollbarGutterWidth == null) return;
6528
- const liveScrollbarGutterWidth = this.gridService.scrollbarGutterWidth();
6529
- this.#fitViewScrollbarSyncResolved.set(true);
6530
- if (liveScrollbarGutterWidth !== initialScrollbarGutterWidth) untracked(() => this.setInitialCalculatedWidthOfColumns());
6531
- });
6532
- }
6533
6541
  setFooterScrollElementEffect() {
6534
6542
  effect(() => {
6535
6543
  const virtual = this.gridService.virtualScrollOptions().enabled;
@@ -6562,19 +6570,14 @@ var GridComponent = class GridComponent {
6562
6570
  if (this.gridService.gridHeaderElement()) {
6563
6571
  const headerElement = this.gridService.gridHeaderElement();
6564
6572
  const headerCells = this.getTableColumnHeaderCellList();
6565
- let headerWidth = headerElement.clientWidth;
6566
- const columnsWithWidth = this.gridService.visibleColumns().where((c) => c.width != null);
6567
- if (columnsWithWidth.any()) headerWidth -= columnsWithWidth.sum((c) => c.width ?? 0);
6568
- if (this.gridService.rowReorderColumnVisible()) headerWidth -= this.gridService.rowReorderColumnWidth;
6569
- if (this.gridService.masterDetailTemplate()) headerWidth -= this.gridService.detailColumnWidth;
6570
- if (this.gridService.selectionColumnVisible()) headerWidth -= this.gridService.selectionColumnWidth;
6571
- headerWidth -= this.gridService.groupColumnWidth * this.gridService.groupColumns().length;
6573
+ const headerWidth = headerElement.clientWidth;
6574
+ this.#fitViewHeaderWidth = headerWidth;
6572
6575
  const fitViewWidthByColumn = this.resizeMethod() === "fitView" ? this.createFitViewWidthMap(headerWidth) : /* @__PURE__ */ new Map();
6573
6576
  const visibleColumns = this.gridService.visibleColumns().toArray();
6574
6577
  const widthByColumnId = /* @__PURE__ */ new Map();
6575
6578
  for (const [cx, gridCol] of visibleColumns.entries()) {
6576
6579
  const columnTh = headerCells[cx];
6577
- if (columnTh == null) continue;
6580
+ if (columnTh == null || this.gridService.isColumnSizedByUser(gridCol.id)) continue;
6578
6581
  const explicitWidth = gridCol.width;
6579
6582
  if (explicitWidth != null) {
6580
6583
  widthByColumnId.set(gridCol.id, this.gridService.normalizeRenderedWidth(explicitWidth));
@@ -7199,9 +7202,9 @@ var GridComponent = class GridComponent {
7199
7202
  deferBlockDependencies: [() => [
7200
7203
  NgTemplateOutlet,
7201
7204
  GridColgroupComponent,
7202
- import("./grid-footer-row.component-DpSu7jvG.mjs").then((m) => m.GridFooterRowComponent),
7203
- import("./grid-list.component-B-F4bvFL.mjs").then((m) => m.GridListComponent),
7204
- import("./grid-virtual-list.component-rIz5AUOU.mjs").then((m) => m.GridVirtualListComponent),
7205
+ import("./grid-footer-row.component-3i2wvQ6a.mjs").then((m) => m.GridFooterRowComponent),
7206
+ import("./grid-list.component-BaI4IOC6.mjs").then((m) => m.GridListComponent),
7207
+ import("./grid-virtual-list.component-BPLi0OaO.mjs").then((m) => m.GridVirtualListComponent),
7205
7208
  import("@nanahoshi/mona-ui/spinner").then((m) => m.SpinnerComponent)
7206
7209
  ]]
7207
7210
  });
@@ -7213,9 +7216,9 @@ i0.ɵɵngDeclareClassMetadataAsync({
7213
7216
  ngImport: i0,
7214
7217
  type: GridComponent,
7215
7218
  resolveDeferredDeps: () => [
7216
- import("./grid-footer-row.component-DpSu7jvG.mjs").then((m) => m.GridFooterRowComponent),
7217
- import("./grid-list.component-B-F4bvFL.mjs").then((m) => m.GridListComponent),
7218
- import("./grid-virtual-list.component-rIz5AUOU.mjs").then((m) => m.GridVirtualListComponent),
7219
+ import("./grid-footer-row.component-3i2wvQ6a.mjs").then((m) => m.GridFooterRowComponent),
7220
+ import("./grid-list.component-BaI4IOC6.mjs").then((m) => m.GridListComponent),
7221
+ import("./grid-virtual-list.component-BPLi0OaO.mjs").then((m) => m.GridVirtualListComponent),
7219
7222
  import("@nanahoshi/mona-ui/spinner").then((m) => m.SpinnerComponent)
7220
7223
  ],
7221
7224
  resolveMetadata: (GridFooterRowComponent, GridListComponent, GridVirtualListComponent, SpinnerComponent) => ({