@simplysm/angular 14.0.19 → 14.0.21

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.
Files changed (125) hide show
  1. package/dist/core/provideSdAngular.js +1 -1
  2. package/dist/core/providers/sd-activated-modal.provider.d.ts +13 -0
  3. package/dist/core/providers/sd-activated-modal.provider.d.ts.map +1 -0
  4. package/dist/core/providers/sd-activated-modal.provider.js +15 -0
  5. package/dist/core/providers/sd-app-structure.provider.d.ts +3 -64
  6. package/dist/core/providers/sd-app-structure.provider.d.ts.map +1 -1
  7. package/dist/core/providers/sd-app-structure.provider.js +1 -252
  8. package/dist/core/providers/sd-app-structure.types.d.ts +52 -0
  9. package/dist/core/providers/sd-app-structure.types.d.ts.map +1 -0
  10. package/dist/core/providers/sd-app-structure.types.js +1 -0
  11. package/dist/core/providers/sd-app-structure.utils.d.ts +13 -0
  12. package/dist/core/providers/sd-app-structure.utils.d.ts.map +1 -0
  13. package/dist/core/providers/sd-app-structure.utils.js +250 -0
  14. package/dist/{ui/overlay/busy → core/providers}/sd-busy.provider.d.ts +1 -1
  15. package/dist/core/providers/sd-busy.provider.d.ts.map +1 -0
  16. package/dist/{ui/overlay/busy → core/providers}/sd-busy.provider.js +1 -1
  17. package/dist/core/providers/sd-print.provider.js +1 -1
  18. package/dist/core/providers/sd-service-client-factory.provider.js +1 -1
  19. package/dist/{ui/overlay/toast → core/providers}/sd-toast.provider.d.ts +1 -1
  20. package/dist/core/providers/sd-toast.provider.d.ts.map +1 -0
  21. package/dist/{ui/overlay/toast → core/providers}/sd-toast.provider.js +3 -3
  22. package/dist/core/types/select-modal-output-result.d.ts +8 -0
  23. package/dist/core/types/select-modal-output-result.d.ts.map +1 -0
  24. package/dist/core/types/select-modal-output-result.js +1 -0
  25. package/dist/core/utils/setups/setupCanDeactivate.js +1 -1
  26. package/dist/core/utils/useViewTitleSignal.js +1 -1
  27. package/dist/core/utils/useViewTypeSignal.js +1 -1
  28. package/dist/features/base/sd-base-container.control.js +1 -1
  29. package/dist/features/data-view/sd-data-detail.control.js +1 -1
  30. package/dist/features/data-view/sd-data-sheet.control.d.ts +24 -37
  31. package/dist/features/data-view/sd-data-sheet.control.d.ts.map +1 -1
  32. package/dist/features/data-view/sd-data-sheet.control.js +98 -152
  33. package/dist/features/data-view/sd-data-sheet.types.d.ts +17 -0
  34. package/dist/features/data-view/sd-data-sheet.types.d.ts.map +1 -0
  35. package/dist/features/data-view/sd-data-sheet.types.js +1 -0
  36. package/dist/{core/utils/setups → features/data-view}/setupCloserWhenSingleSelectionChange.d.ts +1 -1
  37. package/dist/features/data-view/setupCloserWhenSingleSelectionChange.d.ts.map +1 -0
  38. package/dist/features/data-view/useDataSheetExcelManager.d.ts +14 -0
  39. package/dist/features/data-view/useDataSheetExcelManager.d.ts.map +1 -0
  40. package/dist/features/data-view/useDataSheetExcelManager.js +31 -0
  41. package/dist/features/data-view/useDataSheetFilterManager.d.ts +13 -0
  42. package/dist/features/data-view/useDataSheetFilterManager.d.ts.map +1 -0
  43. package/dist/features/data-view/useDataSheetFilterManager.js +22 -0
  44. package/dist/features/data-view/useDataSheetInlineEditManager.d.ts +26 -0
  45. package/dist/features/data-view/useDataSheetInlineEditManager.d.ts.map +1 -0
  46. package/dist/features/data-view/useDataSheetInlineEditManager.js +54 -0
  47. package/dist/features/data-view/useDataSheetModalEditManager.d.ts +19 -0
  48. package/dist/features/data-view/useDataSheetModalEditManager.d.ts.map +1 -0
  49. package/dist/features/data-view/useDataSheetModalEditManager.js +44 -0
  50. package/dist/features/data-view/useDataSheetRefreshManager.d.ts +25 -0
  51. package/dist/features/data-view/useDataSheetRefreshManager.d.ts.map +1 -0
  52. package/dist/features/data-view/useDataSheetRefreshManager.js +50 -0
  53. package/dist/features/permission-table/sd-permission-table.control.d.ts +1 -1
  54. package/dist/features/permission-table/sd-permission-table.control.d.ts.map +1 -1
  55. package/dist/index.d.ts +12 -6
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +10 -5
  58. package/dist/ui/data/sheet/sd-sheet.control.d.ts +22 -30
  59. package/dist/ui/data/sheet/sd-sheet.control.d.ts.map +1 -1
  60. package/dist/ui/data/sheet/sd-sheet.control.js +52 -210
  61. package/dist/ui/data/sheet/useSheetCellStyling.d.ts +22 -0
  62. package/dist/ui/data/sheet/useSheetCellStyling.d.ts.map +1 -0
  63. package/dist/ui/data/sheet/useSheetCellStyling.js +95 -0
  64. package/dist/ui/data/sheet/useSheetColumnResizing.d.ts +17 -0
  65. package/dist/ui/data/sheet/useSheetColumnResizing.d.ts.map +1 -0
  66. package/dist/ui/data/sheet/useSheetColumnResizing.js +65 -0
  67. package/dist/ui/data/sheet/useSheetDisplayPipeline.d.ts +24 -0
  68. package/dist/ui/data/sheet/useSheetDisplayPipeline.d.ts.map +1 -0
  69. package/dist/ui/data/sheet/useSheetDisplayPipeline.js +52 -0
  70. package/dist/ui/form/button/sd-modal-select-button.control.d.ts +1 -7
  71. package/dist/ui/form/button/sd-modal-select-button.control.d.ts.map +1 -1
  72. package/dist/ui/form/button/sd-modal-select-button.control.js +1 -1
  73. package/dist/ui/form/choice/sd-state-preset.control.js +1 -1
  74. package/dist/ui/navigation/menu-utils.d.ts +2 -7
  75. package/dist/ui/navigation/menu-utils.d.ts.map +1 -1
  76. package/dist/ui/overlay/busy/sd-busy-container.control.d.ts +1 -1
  77. package/dist/ui/overlay/busy/sd-busy-container.control.d.ts.map +1 -1
  78. package/dist/ui/overlay/busy/sd-busy-container.control.js +1 -1
  79. package/dist/ui/overlay/modal/sd-modal.control.js +1 -1
  80. package/dist/ui/overlay/modal/sd-modal.provider.d.ts +0 -10
  81. package/dist/ui/overlay/modal/sd-modal.provider.d.ts.map +1 -1
  82. package/dist/ui/overlay/modal/sd-modal.provider.js +1 -13
  83. package/dist/ui/overlay/toast/sd-toast.control.d.ts +1 -1
  84. package/dist/ui/overlay/toast/sd-toast.control.d.ts.map +1 -1
  85. package/package.json +5 -5
  86. package/src/core/provideSdAngular.ts +1 -1
  87. package/src/core/providers/sd-activated-modal.provider.ts +12 -0
  88. package/src/core/providers/sd-app-structure.provider.ts +2 -405
  89. package/src/core/providers/sd-app-structure.types.ts +60 -0
  90. package/src/core/providers/sd-app-structure.utils.ts +350 -0
  91. package/src/{ui/overlay/busy → core/providers}/sd-busy.provider.ts +1 -1
  92. package/src/core/providers/sd-print.provider.ts +1 -1
  93. package/src/core/providers/sd-service-client-factory.provider.ts +1 -1
  94. package/src/{ui/overlay/toast → core/providers}/sd-toast.provider.ts +4 -4
  95. package/src/core/types/select-modal-output-result.ts +7 -0
  96. package/src/core/utils/setups/setupCanDeactivate.ts +1 -1
  97. package/src/core/utils/useViewTitleSignal.ts +1 -1
  98. package/src/core/utils/useViewTypeSignal.ts +1 -1
  99. package/src/features/base/sd-base-container.control.ts +1 -1
  100. package/src/features/data-view/sd-data-detail.control.ts +1 -1
  101. package/src/features/data-view/sd-data-sheet.control.ts +117 -216
  102. package/src/features/data-view/sd-data-sheet.types.ts +18 -0
  103. package/src/{core/utils/setups → features/data-view}/setupCloserWhenSingleSelectionChange.ts +1 -1
  104. package/src/features/data-view/useDataSheetExcelManager.ts +57 -0
  105. package/src/features/data-view/useDataSheetFilterManager.ts +30 -0
  106. package/src/features/data-view/useDataSheetInlineEditManager.ts +89 -0
  107. package/src/features/data-view/useDataSheetModalEditManager.ts +76 -0
  108. package/src/features/data-view/useDataSheetRefreshManager.ts +90 -0
  109. package/src/features/permission-table/sd-permission-table.control.ts +1 -1
  110. package/src/index.ts +17 -11
  111. package/src/ui/data/sheet/sd-sheet.control.ts +50 -238
  112. package/src/ui/data/sheet/useSheetCellStyling.ts +113 -0
  113. package/src/ui/data/sheet/useSheetColumnResizing.ts +92 -0
  114. package/src/ui/data/sheet/useSheetDisplayPipeline.ts +64 -0
  115. package/src/ui/form/button/sd-modal-select-button.control.ts +1 -8
  116. package/src/ui/form/choice/sd-state-preset.control.ts +1 -1
  117. package/src/ui/navigation/menu-utils.ts +3 -7
  118. package/src/ui/overlay/busy/sd-busy-container.control.ts +1 -1
  119. package/src/ui/overlay/modal/sd-modal.control.ts +1 -1
  120. package/src/ui/overlay/modal/sd-modal.provider.ts +1 -10
  121. package/src/ui/overlay/toast/sd-toast.control.ts +1 -1
  122. package/dist/core/utils/setups/setupCloserWhenSingleSelectionChange.d.ts.map +0 -1
  123. package/dist/ui/overlay/busy/sd-busy.provider.d.ts.map +0 -1
  124. package/dist/ui/overlay/toast/sd-toast.provider.d.ts.map +0 -1
  125. /package/dist/{core/utils/setups → features/data-view}/setupCloserWhenSingleSelectionChange.js +0 -0
@@ -1,4 +1,4 @@
1
- import { booleanAttribute, ChangeDetectionStrategy, Component, computed, contentChildren, DestroyRef, inject, input, model, output, signal, ViewEncapsulation, } from "@angular/core";
1
+ import { booleanAttribute, ChangeDetectionStrategy, Component, computed, contentChildren, inject, input, model, output, ViewEncapsulation, } from "@angular/core";
2
2
  import { NgTemplateOutlet } from "@angular/common";
3
3
  import { SdSheetColumnDirective } from "./sd-sheet-column.directive";
4
4
  import { SdCheckboxControl } from "../../form/checkbox/sd-checkbox.control";
@@ -8,13 +8,15 @@ import { useSheetLayoutEngine } from "./useSheetLayoutEngine";
8
8
  import { useSheetColumnFixing } from "./useSheetColumnFixing";
9
9
  import { useSelectionManager } from "../../../core/utils/useSelectionManager";
10
10
  import { useSortingManager } from "../../../core/utils/useSortingManager";
11
- import { useExpandingManager } from "../../../core/utils/useExpandingManager";
12
11
  import { SdPaginationControl } from "../../navigation/pagination/sd-pagination.control";
13
12
  import { SdAnchorControl } from "../../form/button/sd-anchor.control";
14
13
  import { SdButtonControl } from "../../form/button/sd-button.control";
15
14
  import { useSdSystemConfigResource } from "../../../core/utils/useSdSystemConfigResource";
16
15
  import { useSheetDomAccessor } from "./useSheetDomAccessor";
17
16
  import { useSheetCellAgent } from "./useSheetCellAgent";
17
+ import { useSheetColumnResizing } from "./useSheetColumnResizing";
18
+ import { useSheetDisplayPipeline } from "./useSheetDisplayPipeline";
19
+ import { useSheetCellStyling } from "./useSheetCellStyling";
18
20
  import { SdModalProvider } from "../../overlay/modal/sd-modal.provider";
19
21
  import { SdSheetConfigModal } from "./sd-sheet-config.modal";
20
22
  import * as i0 from "@angular/core";
@@ -306,24 +308,22 @@ export class SdSheetControl {
306
308
  columnControls = contentChildren(SdSheetColumnDirective, ...(ngDevMode ? [{ debugName: "columnControls" }] : /* istanbul ignore next */ []));
307
309
  // Injected providers
308
310
  _modalProvider = inject(SdModalProvider);
309
- _destroyRef = inject(DestroyRef);
310
311
  // DOM accessor & cell agent
311
312
  domAccessor = useSheetDomAccessor();
312
313
  cellAgent = useSheetCellAgent({ domAccessor: this.domAccessor });
313
- constructor() {
314
- this._destroyRef.onDestroy(() => {
315
- this._resizingCleanup?.();
316
- });
317
- }
318
- // Resizing state
319
- _isResizing = signal(false, ...(ngDevMode ? [{ debugName: "_isResizing" }] : /* istanbul ignore next */ []));
320
- _resizeIndicatorLeft = signal(0, ...(ngDevMode ? [{ debugName: "_resizeIndicatorLeft" }] : /* istanbul ignore next */ []));
321
- _lastResizeEndTimeStamp = 0;
322
- _resizingCleanup = null;
323
314
  // Config resource
324
315
  _configResource = useSdSystemConfigResource({
325
316
  key: this.key,
326
317
  });
318
+ // Resizing composable
319
+ _resizing = useSheetColumnResizing({
320
+ domAccessor: this.domAccessor,
321
+ configResource: this._configResource,
322
+ });
323
+ _isResizing = this._resizing.isResizing;
324
+ _resizeIndicatorLeft = this._resizing.indicatorLeft;
325
+ onResizerMousedown = this._resizing.onMousedown;
326
+ onResizerDblClick = this._resizing.onDblClick;
327
327
  // Layout engine
328
328
  layout = useSheetLayoutEngine({
329
329
  columnControls: this.columnControls,
@@ -337,65 +337,35 @@ export class SdSheetControl {
337
337
  sorting = useSortingManager({
338
338
  sorts: this.sorts,
339
339
  });
340
- // Effective page count (from totalPageCount or computed from items/itemsPerPage)
341
- effectivePageCount = computed(() => {
342
- const total = this.totalPageCount();
343
- if (total > 0)
344
- return total;
345
- const perPage = this.itemsPerPage();
346
- if (perPage <= 0)
347
- return 0;
348
- return Math.ceil(this.items().length / perPage);
349
- }, ...(ngDevMode ? [{ debugName: "effectivePageCount" }] : /* istanbul ignore next */ []));
350
- // Icons
351
- icons = {
352
- tablerArrowUp,
353
- tablerArrowDown,
354
- tablerChevronRight,
355
- tablerChevronDown,
356
- tablerChevronsRight,
357
- tablerChevronsDown,
358
- tablerSettings,
359
- };
360
- // Sorted items
361
- _sortedItems = computed(() => {
362
- const items = this.items();
363
- if (this.useAutoSort()) {
364
- return this.sorting.sort(items);
365
- }
366
- return items;
367
- }, ...(ngDevMode ? [{ debugName: "_sortedItems" }] : /* istanbul ignore next */ []));
368
- // Paged items (root-level only)
369
- _pagedItems = computed(() => {
370
- const items = this._sortedItems();
371
- const perPage = this.itemsPerPage();
372
- if (perPage <= 0)
373
- return items;
374
- const page = this.currentPage();
375
- const start = page * perPage;
376
- return items.slice(start, start + perPage);
377
- }, ...(ngDevMode ? [{ debugName: "_pagedItems" }] : /* istanbul ignore next */ []));
378
- // Expanding manager
379
- expanding = useExpandingManager({
380
- items: this._pagedItems,
340
+ // Display pipeline (sort page expand → display)
341
+ _pipeline = useSheetDisplayPipeline({
342
+ items: this.items,
343
+ useAutoSort: this.useAutoSort,
344
+ sortItems: (items) => this.sorting.sort(items),
345
+ itemsPerPage: this.itemsPerPage,
346
+ currentPage: this.currentPage,
347
+ totalPageCount: this.totalPageCount,
381
348
  expandedItems: this.expandedItems,
382
349
  getChildrenFn: this.getChildrenFn,
383
- sort: (items) => {
384
- if (this.useAutoSort()) {
385
- return this.sorting.sort(items);
386
- }
387
- return items;
388
- },
389
350
  });
390
- // Final display items (sorted → paged → expanded)
391
- displayItems = computed(() => {
392
- const getChildrenFn = this.getChildrenFn();
393
- if (getChildrenFn != null) {
394
- // With tree: only show visible items (parent expanded)
395
- return this.expanding.displayItems().filter((item) => this.expanding.isVisible(item));
396
- }
397
- return this._pagedItems();
398
- }, ...(ngDevMode ? [{ debugName: "displayItems" }] : /* istanbul ignore next */ []));
351
+ effectivePageCount = this._pipeline.effectivePageCount;
352
+ expanding = this._pipeline.expanding;
353
+ displayItems = this._pipeline.displayItems;
354
+ // Cell styling composable
355
+ _styling = useSheetCellStyling({
356
+ columnDefs: this.layout.columnDefs,
357
+ fixedLeftMap: this.fixing.fixedLeftMap,
358
+ getItemCellStyleFn: this.getItemCellStyleFn,
359
+ getItemCellClassFn: this.getItemCellClassFn,
360
+ getChildrenFn: this.getChildrenFn,
361
+ expandingDef: (item) => this.expanding.def(item),
362
+ isCellEditMode: (addr) => this.cellAgent.isCellEditMode(addr),
363
+ });
364
+ getHeaderCellStyle = this._styling.getHeaderCellStyle;
365
+ getCellStyle = this._styling.getCellStyle;
366
+ getFixedCellStyle = this._styling.getFixedCellStyle;
367
+ getCellStyleWithIndent = this._styling.getCellStyleWithIndent;
368
+ getDataCellClass = this._styling.getDataCellClass;
399
369
  // Selection manager
400
370
  selection = useSelectionManager({
401
371
  displayItems: this.displayItems,
@@ -403,6 +373,16 @@ export class SdSheetControl {
403
373
  selectMode: this.selectMode,
404
374
  getItemSelectableFn: this.getItemSelectableFn,
405
375
  });
376
+ // Icons
377
+ icons = {
378
+ tablerArrowUp,
379
+ tablerArrowDown,
380
+ tablerChevronRight,
381
+ tablerChevronDown,
382
+ tablerChevronsRight,
383
+ tablerChevronsDown,
384
+ tablerSettings,
385
+ };
406
386
  _columnControlMap = computed(() => {
407
387
  const map = new Map();
408
388
  for (const col of this.columnControls()) {
@@ -418,52 +398,6 @@ export class SdSheetControl {
418
398
  const col = this._columnControlMap().get(key);
419
399
  return col?.summaryTplRef() ?? null;
420
400
  }
421
- // Pre-computed column styles: header/footer (fixed z-index:3)
422
- _headerColumnStyles = computed(() => {
423
- const map = new Map();
424
- for (const colDef of this.layout.columnDefs()) {
425
- const parts = [];
426
- const colStyle = this._getColDefStyle(colDef);
427
- if (colStyle != null)
428
- parts.push(colStyle);
429
- const fixedStyle = this._getFixedStyle(colDef, 3, "var(--theme-secondary-lightest)");
430
- if (fixedStyle != null)
431
- parts.push(fixedStyle);
432
- map.set(colDef.key, parts.length > 0 ? parts.join("; ") : null);
433
- }
434
- return map;
435
- }, ...(ngDevMode ? [{ debugName: "_headerColumnStyles" }] : /* istanbul ignore next */ []));
436
- // Pre-computed column styles: body (fixed z-index:1)
437
- _dataColumnBaseStyles = computed(() => {
438
- const map = new Map();
439
- for (const colDef of this.layout.columnDefs()) {
440
- const parts = [];
441
- const colStyle = this._getColDefStyle(colDef);
442
- if (colStyle != null)
443
- parts.push(colStyle);
444
- const fixedStyle = this._getFixedStyle(colDef);
445
- if (fixedStyle != null)
446
- parts.push(fixedStyle);
447
- map.set(colDef.key, parts.length > 0 ? parts.join("; ") : null);
448
- }
449
- return map;
450
- }, ...(ngDevMode ? [{ debugName: "_dataColumnBaseStyles" }] : /* istanbul ignore next */ []));
451
- getHeaderCellStyle(cell) {
452
- if (cell.colDef == null)
453
- return null;
454
- return this._headerColumnStyles().get(cell.colDef.key) ?? null;
455
- }
456
- getCellStyle(item, colDef) {
457
- const baseStyle = this._dataColumnBaseStyles().get(colDef.key) ?? null;
458
- const styleFn = this.getItemCellStyleFn();
459
- const customStyle = styleFn != null ? styleFn(item, colDef.key) : undefined;
460
- if (baseStyle != null && customStyle != null)
461
- return `${baseStyle}; ${customStyle}`;
462
- return customStyle ?? baseStyle ?? null;
463
- }
464
- getFixedCellStyle(colDef) {
465
- return this._getFixedStyle(colDef, 3);
466
- }
467
401
  getSelectableTooltip(item) {
468
402
  const result = this.selection.getSelectable(item);
469
403
  if (typeof result === "string")
@@ -490,7 +424,7 @@ export class SdSheetControl {
490
424
  }
491
425
  }
492
426
  onHeaderClick(event, cell) {
493
- if (event.timeStamp - this._lastResizeEndTimeStamp < 50)
427
+ if (event.timeStamp - this._resizing.lastResizeEndTimeStamp() < 50)
494
428
  return;
495
429
  if (cell.colDef == null)
496
430
  return;
@@ -501,21 +435,6 @@ export class SdSheetControl {
501
435
  getSortDef(key) {
502
436
  return this.sorting.defMap().get(key) ?? null;
503
437
  }
504
- getCellStyleWithIndent(item, colDef, colIdx) {
505
- const parts = [];
506
- const cellStyle = this.getCellStyle(item, colDef);
507
- if (cellStyle != null) {
508
- parts.push(cellStyle);
509
- }
510
- // Add indent for tree depth on first data column
511
- if (colIdx === 0 && this.getChildrenFn() != null) {
512
- const itemDef = this.getItemDef(item);
513
- if (itemDef.depth > 0) {
514
- parts.push(`padding-left: calc(var(--gap-default) + ${itemDef.depth}em)`);
515
- }
516
- }
517
- return parts.length > 0 ? parts.join("; ") : null;
518
- }
519
438
  getItemDef(item) {
520
439
  return this.expanding.def(item);
521
440
  }
@@ -544,34 +463,6 @@ export class SdSheetControl {
544
463
  return null;
545
464
  return sortDef.desc ? "descending" : "ascending";
546
465
  }
547
- _getColDefStyle(colDef) {
548
- if (colDef.collapse) {
549
- return "padding: 0; width: 0; min-width: 0; max-width: 0; overflow: hidden; border: none";
550
- }
551
- if (colDef.width != null) {
552
- return `width: ${colDef.width}; min-width: ${colDef.width}; max-width: ${colDef.width}`;
553
- }
554
- return null;
555
- }
556
- _getFixedStyle(colDef, zIndex = 1, background = "var(--control-color)") {
557
- const fixedLeftMap = this.fixing.fixedLeftMap();
558
- const leftValue = fixedLeftMap.get(colDef.key);
559
- if (leftValue == null)
560
- return null;
561
- return `position: sticky; left: ${leftValue}px; z-index: ${zIndex}; background: ${background}`;
562
- }
563
- getDataCellClass(item, colDef, r, c) {
564
- const parts = [];
565
- const classFn = this.getItemCellClassFn();
566
- const customClass = classFn != null ? classFn(item, colDef.key) : undefined;
567
- if (customClass != null) {
568
- parts.push(customClass);
569
- }
570
- if (this.cellAgent.isCellEditMode({ r, c })) {
571
- parts.push("_edit-mode");
572
- }
573
- return parts.length > 0 ? parts.join(" ") : null;
574
- }
575
466
  async onKeydownCapture(event) {
576
467
  await this.cellAgent.handleKeydownCapture(event);
577
468
  }
@@ -600,55 +491,6 @@ export class SdSheetControl {
600
491
  this._configResource.set(result);
601
492
  }
602
493
  }
603
- // --- Resizing ---
604
- onResizerMousedown(event, colDef) {
605
- event.preventDefault();
606
- event.stopPropagation();
607
- const container = this.domAccessor.getContainer();
608
- const startX = event.clientX;
609
- const th = event.target.parentElement;
610
- const startWidth = th.offsetWidth;
611
- this._isResizing.set(true);
612
- this._resizeIndicatorLeft.set(th.offsetLeft + th.offsetWidth - container.scrollLeft);
613
- const onMouseMove = (e) => {
614
- const deltaX = e.clientX - startX;
615
- const newWidth = Math.max(startWidth + deltaX, 5);
616
- this._resizeIndicatorLeft.set(th.offsetLeft + newWidth - container.scrollLeft);
617
- };
618
- const onMouseUp = (e) => {
619
- document.removeEventListener("mousemove", onMouseMove);
620
- document.removeEventListener("mouseup", onMouseUp);
621
- this._resizingCleanup = null;
622
- const deltaX = e.clientX - startX;
623
- const newWidth = Math.max(startWidth + deltaX, 5);
624
- this._isResizing.set(false);
625
- this._saveColumnConfig(colDef.key, { width: `${newWidth}px` });
626
- this._lastResizeEndTimeStamp = e.timeStamp;
627
- };
628
- document.addEventListener("mousemove", onMouseMove);
629
- document.addEventListener("mouseup", onMouseUp);
630
- this._resizingCleanup = () => {
631
- document.removeEventListener("mousemove", onMouseMove);
632
- document.removeEventListener("mouseup", onMouseUp);
633
- };
634
- }
635
- onResizerDblClick(event, colDef) {
636
- event.preventDefault();
637
- event.stopPropagation();
638
- // Remove the width from config to reset to column definition default
639
- const current = this._configResource.value() ?? { columnRecord: {} };
640
- const columnRecord = { ...current.columnRecord };
641
- const colConfig = { ...columnRecord[colDef.key] };
642
- delete colConfig.width;
643
- columnRecord[colDef.key] = colConfig;
644
- this._configResource.set({ ...current, columnRecord });
645
- }
646
- _saveColumnConfig(colKey, changes) {
647
- const current = this._configResource.value() ?? { columnRecord: {} };
648
- const columnRecord = { ...current.columnRecord };
649
- columnRecord[colKey] = { ...columnRecord[colKey], ...changes };
650
- this._configResource.set({ ...current, columnRecord });
651
- }
652
494
  static ɵfac = function SdSheetControl_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SdSheetControl)(); };
653
495
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SdSheetControl, selectors: [["sd-sheet"]], contentQueries: function SdSheetControl_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
654
496
  i0.ɵɵcontentQuerySignal(dirIndex, ctx.columnControls, SdSheetColumnDirective, 4);
@@ -845,5 +687,5 @@ export class SdSheetControl {
845
687
  "(dblclick)": "onDblClick($event)",
846
688
  "(blur.capture)": "onBlurCapture($event)",
847
689
  }, styles: ["sd-sheet {\n display: block;\n position: relative;\n overflow: hidden;\n border: 1px solid var(--trans-lighter);\n}\nsd-sheet[data-sd-inset=true] {\n border: none;\n}\nsd-sheet > ._tool {\n display: flex;\n align-items: center;\n gap: var(--gap-sm);\n padding: var(--gap-sm) var(--gap-default);\n border-bottom: 1px solid var(--trans-lighter);\n background: var(--theme-secondary-lightest);\n}\nsd-sheet > ._container {\n overflow: auto;\n width: 100%;\n height: 100%;\n}\nsd-sheet > ._container > table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\nsd-sheet > ._container > table > thead > tr > th {\n position: sticky;\n top: 0;\n z-index: 2;\n background: var(--theme-secondary-lightest);\n border: 1px solid var(--trans-lighter);\n padding: var(--gap-sm) var(--gap-default);\n text-align: left;\n font-weight: bold;\n white-space: nowrap;\n cursor: pointer;\n user-select: none;\n}\nsd-sheet > ._container > table > thead > tr > th:not(._select-col):not(._expand-col) {\n position: relative;\n}\nsd-sheet > ._container > table > thead > tr > th > ._sort-icon {\n font-size: 0.85em;\n vertical-align: middle;\n margin-left: 0.25em;\n}\nsd-sheet > ._container > table > thead > tr > th > ._sort-index {\n font-size: 0.75em;\n vertical-align: super;\n}\nsd-sheet > ._container > table > thead > tr > th > ._resizer {\n position: absolute;\n top: 0;\n right: -2px;\n width: 5px;\n height: 100%;\n cursor: col-resize;\n z-index: 3;\n}\nsd-sheet > ._container > table > tbody > tr > td {\n border: 1px solid var(--trans-lighter);\n padding: var(--gap-sm) var(--gap-default);\n white-space: nowrap;\n}\nsd-sheet > ._container > table > tbody > tr > td:focus {\n outline: 2px solid var(--theme-primary-default);\n outline-offset: -2px;\n}\nsd-sheet > ._container > table > thead > tr > th._select-col,\nsd-sheet > ._container > table > tbody > tr > td._select-col {\n width: 2em;\n min-width: 2em;\n max-width: 2em;\n text-align: center;\n padding: 0;\n}\nsd-sheet > ._container > table > thead > tr > th._expand-col,\nsd-sheet > ._container > table > tbody > tr > td._expand-col {\n width: 2em;\n min-width: 2em;\n max-width: 2em;\n text-align: center;\n padding: 0;\n}\nsd-sheet > ._container > table > tfoot > tr > td {\n position: sticky;\n bottom: 0;\n z-index: 2;\n background: var(--theme-secondary-lightest);\n border: 1px solid var(--trans-lighter);\n padding: var(--gap-sm) var(--gap-default);\n}\nsd-sheet > ._container > ._resize-indicator {\n position: absolute;\n top: 0;\n width: 2px;\n height: 100%;\n background: var(--theme-primary-default);\n z-index: 10;\n pointer-events: none;\n}"] }]
848
- }], () => [], { key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], trackByFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackByFn", required: false }] }], selectMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectMode", required: false }] }], autoSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSelect", required: false }] }], getItemSelectableFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getItemSelectableFn", required: false }] }], getChildrenFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getChildrenFn", required: false }] }], useAutoSort: [{ type: i0.Input, args: [{ isSignal: true, alias: "useAutoSort", required: false }] }], visiblePageCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "visiblePageCount", required: false }] }], totalPageCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "totalPageCount", required: false }] }], itemsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsPerPage", required: false }] }], focusMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusMode", required: false }] }], inset: [{ type: i0.Input, args: [{ isSignal: true, alias: "inset", required: false }] }], contentStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentStyle", required: false }] }], getItemCellClassFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getItemCellClassFn", required: false }] }], getItemCellStyleFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getItemCellStyleFn", required: false }] }], hideConfigBar: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideConfigBar", required: false }] }], itemKeydown: [{ type: i0.Output, args: ["itemKeydown"] }], cellKeydown: [{ type: i0.Output, args: ["cellKeydown"] }], selectedItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedItems", required: false }] }, { type: i0.Output, args: ["selectedItemsChange"] }], expandedItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandedItems", required: false }] }, { type: i0.Output, args: ["expandedItemsChange"] }], sorts: [{ type: i0.Input, args: [{ isSignal: true, alias: "sorts", required: false }] }, { type: i0.Output, args: ["sortsChange"] }], currentPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "currentPage", required: false }] }, { type: i0.Output, args: ["currentPageChange"] }], columnControls: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => SdSheetColumnDirective), { isSignal: true }] }] }); })();
849
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SdSheetControl, { className: "SdSheetControl", filePath: "packages/angular/src/ui/data/sheet/sd-sheet.control.ts", lineNumber: 338, forbidOrphanRendering: true }); })();
690
+ }], null, { key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], trackByFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackByFn", required: false }] }], selectMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectMode", required: false }] }], autoSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSelect", required: false }] }], getItemSelectableFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getItemSelectableFn", required: false }] }], getChildrenFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getChildrenFn", required: false }] }], useAutoSort: [{ type: i0.Input, args: [{ isSignal: true, alias: "useAutoSort", required: false }] }], visiblePageCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "visiblePageCount", required: false }] }], totalPageCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "totalPageCount", required: false }] }], itemsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsPerPage", required: false }] }], focusMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusMode", required: false }] }], inset: [{ type: i0.Input, args: [{ isSignal: true, alias: "inset", required: false }] }], contentStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentStyle", required: false }] }], getItemCellClassFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getItemCellClassFn", required: false }] }], getItemCellStyleFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "getItemCellStyleFn", required: false }] }], hideConfigBar: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideConfigBar", required: false }] }], itemKeydown: [{ type: i0.Output, args: ["itemKeydown"] }], cellKeydown: [{ type: i0.Output, args: ["cellKeydown"] }], selectedItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedItems", required: false }] }, { type: i0.Output, args: ["selectedItemsChange"] }], expandedItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandedItems", required: false }] }, { type: i0.Output, args: ["expandedItemsChange"] }], sorts: [{ type: i0.Input, args: [{ isSignal: true, alias: "sorts", required: false }] }, { type: i0.Output, args: ["sortsChange"] }], currentPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "currentPage", required: false }] }, { type: i0.Output, args: ["currentPageChange"] }], columnControls: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => SdSheetColumnDirective), { isSignal: true }] }] }); })();
691
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SdSheetControl, { className: "SdSheetControl", filePath: "packages/angular/src/ui/data/sheet/sd-sheet.control.ts", lineNumber: 337, forbidOrphanRendering: true }); })();
@@ -0,0 +1,22 @@
1
+ import { type Signal } from "@angular/core";
2
+ import type { ISdSheetColumnDef, ISdSheetHeaderDef } from "./types";
3
+ import type { IExpandItemDef } from "../../../core/utils/useExpandingManager";
4
+ export declare function useSheetCellStyling<T>(options: {
5
+ columnDefs: Signal<ISdSheetColumnDef[]>;
6
+ fixedLeftMap: Signal<Map<string, number>>;
7
+ getItemCellStyleFn: Signal<((item: T, colKey: string) => string | undefined) | undefined>;
8
+ getItemCellClassFn: Signal<((item: T, colKey: string) => string) | undefined>;
9
+ getChildrenFn: Signal<((item: T, index: number) => T[] | undefined) | undefined>;
10
+ expandingDef: (item: T) => IExpandItemDef<T>;
11
+ isCellEditMode: (addr: {
12
+ r: number;
13
+ c: number;
14
+ }) => boolean;
15
+ }): {
16
+ getHeaderCellStyle: (cell: ISdSheetHeaderDef) => string | null;
17
+ getCellStyle: (item: T, colDef: ISdSheetColumnDef) => string | null;
18
+ getFixedCellStyle: (colDef: ISdSheetColumnDef) => string | null;
19
+ getCellStyleWithIndent: (item: T, colDef: ISdSheetColumnDef, colIdx: number) => string | null;
20
+ getDataCellClass: (item: T, colDef: ISdSheetColumnDef, r: number, c: number) => string | null;
21
+ };
22
+ //# sourceMappingURL=useSheetCellStyling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSheetCellStyling.d.ts","sourceRoot":"","sources":["../../../../src/ui/data/sheet/useSheetCellStyling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAE9E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1F,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IAC9E,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;IACjF,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7C,cAAc,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;CAC7D;+BAgDmC,iBAAiB,KAAG,MAAM,GAAG,IAAI;yBAKvC,CAAC,UAAU,iBAAiB,KAAG,MAAM,GAAG,IAAI;gCAQrC,iBAAiB,KAAG,MAAM,GAAG,IAAI;mCAI9B,CAAC,UAAU,iBAAiB,UAAU,MAAM,KAAG,MAAM,GAAG,IAAI;6BAelE,CAAC,UAAU,iBAAiB,KAAK,MAAM,KAAK,MAAM,KAAG,MAAM,GAAG,IAAI;EAoBnG"}
@@ -0,0 +1,95 @@
1
+ import { computed } from "@angular/core";
2
+ export function useSheetCellStyling(options) {
3
+ function getColDefStyle(colDef) {
4
+ if (colDef.collapse) {
5
+ return "padding: 0; width: 0; min-width: 0; max-width: 0; overflow: hidden; border: none";
6
+ }
7
+ if (colDef.width != null) {
8
+ return `width: ${colDef.width}; min-width: ${colDef.width}; max-width: ${colDef.width}`;
9
+ }
10
+ return null;
11
+ }
12
+ function getFixedStyle(colDef, zIndex = 1, background = "var(--control-color)") {
13
+ const leftValue = options.fixedLeftMap().get(colDef.key);
14
+ if (leftValue == null)
15
+ return null;
16
+ return `position: sticky; left: ${leftValue}px; z-index: ${zIndex}; background: ${background}`;
17
+ }
18
+ const headerColumnStyles = computed(() => {
19
+ const map = new Map();
20
+ for (const colDef of options.columnDefs()) {
21
+ const parts = [];
22
+ const colStyle = getColDefStyle(colDef);
23
+ if (colStyle != null)
24
+ parts.push(colStyle);
25
+ const fixedStyle = getFixedStyle(colDef, 3, "var(--theme-secondary-lightest)");
26
+ if (fixedStyle != null)
27
+ parts.push(fixedStyle);
28
+ map.set(colDef.key, parts.length > 0 ? parts.join("; ") : null);
29
+ }
30
+ return map;
31
+ }, ...(ngDevMode ? [{ debugName: "headerColumnStyles" }] : /* istanbul ignore next */ []));
32
+ const dataColumnBaseStyles = computed(() => {
33
+ const map = new Map();
34
+ for (const colDef of options.columnDefs()) {
35
+ const parts = [];
36
+ const colStyle = getColDefStyle(colDef);
37
+ if (colStyle != null)
38
+ parts.push(colStyle);
39
+ const fixedStyle = getFixedStyle(colDef);
40
+ if (fixedStyle != null)
41
+ parts.push(fixedStyle);
42
+ map.set(colDef.key, parts.length > 0 ? parts.join("; ") : null);
43
+ }
44
+ return map;
45
+ }, ...(ngDevMode ? [{ debugName: "dataColumnBaseStyles" }] : /* istanbul ignore next */ []));
46
+ function getHeaderCellStyle(cell) {
47
+ if (cell.colDef == null)
48
+ return null;
49
+ return headerColumnStyles().get(cell.colDef.key) ?? null;
50
+ }
51
+ function getCellStyle(item, colDef) {
52
+ const baseStyle = dataColumnBaseStyles().get(colDef.key) ?? null;
53
+ const styleFn = options.getItemCellStyleFn();
54
+ const customStyle = styleFn != null ? styleFn(item, colDef.key) : undefined;
55
+ if (baseStyle != null && customStyle != null)
56
+ return `${baseStyle}; ${customStyle}`;
57
+ return customStyle ?? baseStyle ?? null;
58
+ }
59
+ function getFixedCellStyle(colDef) {
60
+ return getFixedStyle(colDef, 3);
61
+ }
62
+ function getCellStyleWithIndent(item, colDef, colIdx) {
63
+ const parts = [];
64
+ const cellStyle = getCellStyle(item, colDef);
65
+ if (cellStyle != null) {
66
+ parts.push(cellStyle);
67
+ }
68
+ if (colIdx === 0 && options.getChildrenFn() != null) {
69
+ const itemDef = options.expandingDef(item);
70
+ if (itemDef.depth > 0) {
71
+ parts.push(`padding-left: calc(var(--gap-default) + ${itemDef.depth}em)`);
72
+ }
73
+ }
74
+ return parts.length > 0 ? parts.join("; ") : null;
75
+ }
76
+ function getDataCellClass(item, colDef, r, c) {
77
+ const parts = [];
78
+ const classFn = options.getItemCellClassFn();
79
+ const customClass = classFn != null ? classFn(item, colDef.key) : undefined;
80
+ if (customClass != null) {
81
+ parts.push(customClass);
82
+ }
83
+ if (options.isCellEditMode({ r, c })) {
84
+ parts.push("_edit-mode");
85
+ }
86
+ return parts.length > 0 ? parts.join(" ") : null;
87
+ }
88
+ return {
89
+ getHeaderCellStyle,
90
+ getCellStyle,
91
+ getFixedCellStyle,
92
+ getCellStyleWithIndent,
93
+ getDataCellClass,
94
+ };
95
+ }
@@ -0,0 +1,17 @@
1
+ import { type Signal } from "@angular/core";
2
+ import type { ISdSheetColumnDef, ISdSheetConfig } from "./types";
3
+ import type { useSheetDomAccessor } from "./useSheetDomAccessor";
4
+ export declare function useSheetColumnResizing(options: {
5
+ domAccessor: ReturnType<typeof useSheetDomAccessor>;
6
+ configResource: {
7
+ value: Signal<ISdSheetConfig | undefined>;
8
+ set: (v: ISdSheetConfig) => void;
9
+ };
10
+ }): {
11
+ isResizing: import("@angular/core").WritableSignal<boolean>;
12
+ indicatorLeft: import("@angular/core").WritableSignal<number>;
13
+ lastResizeEndTimeStamp: import("@angular/core").WritableSignal<number>;
14
+ onMousedown: (event: MouseEvent, colDef: ISdSheetColumnDef) => void;
15
+ onDblClick: (event: MouseEvent, colDef: ISdSheetColumnDef) => void;
16
+ };
17
+ //# sourceMappingURL=useSheetColumnResizing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSheetColumnResizing.d.ts","sourceRoot":"","sources":["../../../../src/ui/data/sheet/useSheetColumnResizing.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,WAAW,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IACpD,cAAc,EAAE;QACd,KAAK,EAAE,MAAM,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;QAC1C,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;KAClC,CAAC;CACH;;;;yBAsB6B,UAAU,UAAU,iBAAiB,KAAG,IAAI;wBAwC7C,UAAU,UAAU,iBAAiB,KAAG,IAAI;EAmBxE"}
@@ -0,0 +1,65 @@
1
+ import { DestroyRef, inject, signal } from "@angular/core";
2
+ export function useSheetColumnResizing(options) {
3
+ const destroyRef = inject(DestroyRef);
4
+ const isResizing = signal(false, ...(ngDevMode ? [{ debugName: "isResizing" }] : /* istanbul ignore next */ []));
5
+ const indicatorLeft = signal(0, ...(ngDevMode ? [{ debugName: "indicatorLeft" }] : /* istanbul ignore next */ []));
6
+ const lastResizeEndTimeStamp = signal(0, ...(ngDevMode ? [{ debugName: "lastResizeEndTimeStamp" }] : /* istanbul ignore next */ []));
7
+ let resizingCleanup = null;
8
+ destroyRef.onDestroy(() => {
9
+ resizingCleanup?.();
10
+ });
11
+ function saveColumnConfig(colKey, changes) {
12
+ const current = options.configResource.value() ?? { columnRecord: {} };
13
+ const columnRecord = { ...current.columnRecord };
14
+ columnRecord[colKey] = { ...columnRecord[colKey], ...changes };
15
+ options.configResource.set({ ...current, columnRecord });
16
+ }
17
+ function onMousedown(event, colDef) {
18
+ event.preventDefault();
19
+ event.stopPropagation();
20
+ const container = options.domAccessor.getContainer();
21
+ const startX = event.clientX;
22
+ const th = event.target.parentElement;
23
+ const startWidth = th.offsetWidth;
24
+ isResizing.set(true);
25
+ indicatorLeft.set(th.offsetLeft + th.offsetWidth - container.scrollLeft);
26
+ const onMouseMove = (e) => {
27
+ const deltaX = e.clientX - startX;
28
+ const newWidth = Math.max(startWidth + deltaX, 5);
29
+ indicatorLeft.set(th.offsetLeft + newWidth - container.scrollLeft);
30
+ };
31
+ const onMouseUp = (e) => {
32
+ document.removeEventListener("mousemove", onMouseMove);
33
+ document.removeEventListener("mouseup", onMouseUp);
34
+ resizingCleanup = null;
35
+ const deltaX = e.clientX - startX;
36
+ const newWidth = Math.max(startWidth + deltaX, 5);
37
+ isResizing.set(false);
38
+ saveColumnConfig(colDef.key, { width: `${newWidth}px` });
39
+ lastResizeEndTimeStamp.set(e.timeStamp);
40
+ };
41
+ document.addEventListener("mousemove", onMouseMove);
42
+ document.addEventListener("mouseup", onMouseUp);
43
+ resizingCleanup = () => {
44
+ document.removeEventListener("mousemove", onMouseMove);
45
+ document.removeEventListener("mouseup", onMouseUp);
46
+ };
47
+ }
48
+ function onDblClick(event, colDef) {
49
+ event.preventDefault();
50
+ event.stopPropagation();
51
+ const current = options.configResource.value() ?? { columnRecord: {} };
52
+ const columnRecord = { ...current.columnRecord };
53
+ const colConfig = { ...columnRecord[colDef.key] };
54
+ delete colConfig.width;
55
+ columnRecord[colDef.key] = colConfig;
56
+ options.configResource.set({ ...current, columnRecord });
57
+ }
58
+ return {
59
+ isResizing,
60
+ indicatorLeft,
61
+ lastResizeEndTimeStamp,
62
+ onMousedown,
63
+ onDblClick,
64
+ };
65
+ }
@@ -0,0 +1,24 @@
1
+ import { type Signal, type WritableSignal } from "@angular/core";
2
+ export declare function useSheetDisplayPipeline<T>(options: {
3
+ items: Signal<T[]>;
4
+ useAutoSort: Signal<boolean>;
5
+ sortItems: (items: T[]) => T[];
6
+ itemsPerPage: Signal<number>;
7
+ currentPage: Signal<number>;
8
+ totalPageCount: Signal<number>;
9
+ expandedItems: WritableSignal<T[]>;
10
+ getChildrenFn: Signal<((item: T, index: number) => T[] | undefined) | undefined>;
11
+ }): {
12
+ effectivePageCount: Signal<number>;
13
+ displayItems: Signal<T[]>;
14
+ expanding: {
15
+ displayItems: Signal<T[]>;
16
+ hasExpandable: Signal<boolean>;
17
+ isAllExpanded: Signal<boolean>;
18
+ toggle(item: T): void;
19
+ toggleAll(): void;
20
+ isVisible(item: T): boolean;
21
+ def(item: T): import("../../..").IExpandItemDef<T>;
22
+ };
23
+ };
24
+ //# sourceMappingURL=useSheetDisplayPipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSheetDisplayPipeline.d.ts","sourceRoot":"","sources":["../../../../src/ui/data/sheet/useSheetDisplayPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAG3E,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,EAAE;IAClD,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,aAAa,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;CAClF;;;;;;;;;;;;EAmDA"}
@@ -0,0 +1,52 @@
1
+ import { computed } from "@angular/core";
2
+ import { useExpandingManager } from "../../../core/utils/useExpandingManager";
3
+ export function useSheetDisplayPipeline(options) {
4
+ const effectivePageCount = computed(() => {
5
+ const total = options.totalPageCount();
6
+ if (total > 0)
7
+ return total;
8
+ const perPage = options.itemsPerPage();
9
+ if (perPage <= 0)
10
+ return 0;
11
+ return Math.ceil(options.items().length / perPage);
12
+ }, ...(ngDevMode ? [{ debugName: "effectivePageCount" }] : /* istanbul ignore next */ []));
13
+ const sortedItems = computed(() => {
14
+ const items = options.items();
15
+ if (options.useAutoSort()) {
16
+ return options.sortItems(items);
17
+ }
18
+ return items;
19
+ }, ...(ngDevMode ? [{ debugName: "sortedItems" }] : /* istanbul ignore next */ []));
20
+ const pagedItems = computed(() => {
21
+ const items = sortedItems();
22
+ const perPage = options.itemsPerPage();
23
+ if (perPage <= 0)
24
+ return items;
25
+ const page = options.currentPage();
26
+ const start = page * perPage;
27
+ return items.slice(start, start + perPage);
28
+ }, ...(ngDevMode ? [{ debugName: "pagedItems" }] : /* istanbul ignore next */ []));
29
+ const expanding = useExpandingManager({
30
+ items: pagedItems,
31
+ expandedItems: options.expandedItems,
32
+ getChildrenFn: options.getChildrenFn,
33
+ sort: (items) => {
34
+ if (options.useAutoSort()) {
35
+ return options.sortItems(items);
36
+ }
37
+ return items;
38
+ },
39
+ });
40
+ const displayItems = computed(() => {
41
+ const getChildrenFn = options.getChildrenFn();
42
+ if (getChildrenFn != null) {
43
+ return expanding.displayItems().filter((item) => expanding.isVisible(item));
44
+ }
45
+ return pagedItems();
46
+ }, ...(ngDevMode ? [{ debugName: "displayItems" }] : /* istanbul ignore next */ []));
47
+ return {
48
+ effectivePageCount,
49
+ displayItems,
50
+ expanding,
51
+ };
52
+ }