logitude-dashboard-library 3.2.66 → 3.2.67

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.
@@ -2417,6 +2417,10 @@ var resolvePivotGroupHeaderName = function resolvePivotGroupHeaderName(colGroupD
2417
2417
  return 'Grand Total';
2418
2418
  }
2419
2419
 
2420
+ if (colGroupDef && colGroupDef.dlPivotColumnGroupTotal) {
2421
+ return null;
2422
+ }
2423
+
2420
2424
  var pivotKeys = colGroupDef && colGroupDef.pivotKeys ? colGroupDef.pivotKeys : [];
2421
2425
 
2422
2426
  if (pivotKeys.length === 0) {
@@ -2431,6 +2435,97 @@ var resolvePivotGroupHeaderName = function resolvePivotGroupHeaderName(colGroupD
2431
2435
 
2432
2436
  return lookupDisplayName(field, pivotKeys[pivotKeys.length - 1]);
2433
2437
  };
2438
+ var isAgGridExpandablePivotColumnTotalLeaf = function isAgGridExpandablePivotColumnTotalLeaf(colDef) {
2439
+ if (!colDef || colDef.children) {
2440
+ return false;
2441
+ }
2442
+
2443
+ if (isPivotRowGrandTotalColumnDef(colDef)) {
2444
+ return false;
2445
+ }
2446
+
2447
+ if (colDef.pivotTotalColumnIds === undefined || colDef.pivotTotalColumnIds === null) {
2448
+ return false;
2449
+ }
2450
+
2451
+ return colDef.columnGroupShow === 'closed';
2452
+ };
2453
+ var isAgGridPivotColumnGroupTotalColumn = function isAgGridPivotColumnGroupTotalColumn(colDef) {
2454
+ if (!colDef || colDef.children) {
2455
+ return false;
2456
+ }
2457
+
2458
+ if (isPivotRowGrandTotalColumnDef(colDef)) {
2459
+ return false;
2460
+ }
2461
+
2462
+ if (colDef.dlPivotColumnGroupTotalLeaf) {
2463
+ return true;
2464
+ }
2465
+
2466
+ return colDef.pivotTotalColumnIds !== undefined && colDef.pivotTotalColumnIds !== null;
2467
+ };
2468
+ var setAllAgGridColumnGroupsOpened = function setAllAgGridColumnGroupsOpened(columnApi, opened) {
2469
+ if (!columnApi || !columnApi.getColumnGroupState || !columnApi.setColumnGroupState) {
2470
+ return;
2471
+ }
2472
+
2473
+ var groupState = columnApi.getColumnGroupState();
2474
+
2475
+ if (!groupState || groupState.length === 0) {
2476
+ return;
2477
+ }
2478
+
2479
+ columnApi.setColumnGroupState(groupState.map(function (group) {
2480
+ return {
2481
+ groupId: group.groupId,
2482
+ open: opened
2483
+ };
2484
+ }));
2485
+ };
2486
+
2487
+ var buildDxPivotColumnGroupTotalHeaderName = function buildDxPivotColumnGroupTotalHeaderName(parentGroupDef, columnFields, lookupDisplayName) {
2488
+ var pivotKeys = parentGroupDef && parentGroupDef.pivotKeys ? parentGroupDef.pivotKeys : [];
2489
+
2490
+ if (pivotKeys.length === 0) {
2491
+ return 'Total';
2492
+ }
2493
+
2494
+ var field = columnFields[pivotKeys.length - 1];
2495
+ var rawValue = pivotKeys[pivotKeys.length - 1];
2496
+ var displayName = field ? lookupDisplayName(field, rawValue) : rawValue == null ? '' : String(rawValue);
2497
+ return displayName ? displayName + " Total" : 'Total';
2498
+ };
2499
+
2500
+ var promoteExpandablePivotColumnTotalsForDx = function promoteExpandablePivotColumnTotalsForDx(colGroupDef, columnFields, lookupDisplayName) {
2501
+ if (!colGroupDef || !colGroupDef.children || colGroupDef.children.length === 0) {
2502
+ return;
2503
+ }
2504
+
2505
+ var totalLeaves = [];
2506
+ var otherChildren = [];
2507
+ colGroupDef.children.forEach(function (child) {
2508
+ if (isAgGridExpandablePivotColumnTotalLeaf(child)) {
2509
+ delete child.columnGroupShow;
2510
+ child.dlPivotColumnGroupTotalLeaf = true;
2511
+ totalLeaves.push(child);
2512
+ } else {
2513
+ otherChildren.push(child);
2514
+ }
2515
+ });
2516
+
2517
+ if (totalLeaves.length === 0) {
2518
+ return;
2519
+ }
2520
+
2521
+ colGroupDef.children = otherChildren.concat([{
2522
+ headerName: buildDxPivotColumnGroupTotalHeaderName(colGroupDef, columnFields, lookupDisplayName),
2523
+ marryChildren: true,
2524
+ dlPivotColumnGroupTotal: true,
2525
+ headerClass: 'dl-pivot-column-group-total-header',
2526
+ children: totalLeaves
2527
+ }]);
2528
+ };
2434
2529
  var getPivotValueColumnId = function getPivotValueColumnId(pivotValueColumn) {
2435
2530
  if (!pivotValueColumn) {
2436
2531
  return null;
@@ -2757,6 +2852,13 @@ var isAgGridPivotDrillDownMeasureColumn = function isAgGridPivotDrillDownMeasure
2757
2852
  return measure.PivotMeasureCode === colDef.field || measure.PivotMeasureCode === colId;
2758
2853
  });
2759
2854
  };
2855
+ var normalizePivotDrillDownFieldValue = function normalizePivotDrillDownFieldValue(value) {
2856
+ if (value === null || value === undefined || value === '' || value === ' ') {
2857
+ return null;
2858
+ }
2859
+
2860
+ return value;
2861
+ };
2760
2862
  var buildPivotDrillDownPivotFields = function buildPivotDrillDownPivotFields(colDef, startNode, apiFields) {
2761
2863
  var columnFields = apiFields.filter(function (field) {
2762
2864
  return !isRowPivotField(field);
@@ -2778,7 +2880,7 @@ var buildPivotDrillDownPivotFields = function buildPivotDrillDownPivotFields(col
2778
2880
  pivotFields.push({
2779
2881
  FieldId: field.FieldId,
2780
2882
  FieldType: field.FieldType ? field.FieldType : 'Field',
2781
- FieldValue: key,
2883
+ FieldValue: normalizePivotDrillDownFieldValue(key),
2782
2884
  DateCode: field.DateCode
2783
2885
  });
2784
2886
  });
@@ -2796,7 +2898,7 @@ var buildPivotDrillDownPivotFields = function buildPivotDrillDownPivotFields(col
2796
2898
  pivotFields.push({
2797
2899
  FieldId: field.FieldId,
2798
2900
  FieldType: field.FieldType ? field.FieldType : 'Field',
2799
- FieldValue: pathItem.key,
2901
+ FieldValue: normalizePivotDrillDownFieldValue(pathItem.key),
2800
2902
  DateCode: field.DateCode
2801
2903
  });
2802
2904
  });
@@ -3253,6 +3355,42 @@ var PivotTable = forwardRef(function (props, comRef) {
3253
3355
  });
3254
3356
 
3255
3357
  var ROW_GROUP_COLUMN_MIN_WIDTH = 100;
3358
+ var PIVOT_VALUE_COLUMN_MIN_WIDTH = 100;
3359
+ var PIVOT_HEADER_BASE_HEIGHT = 36;
3360
+ var PIVOT_ROW_MIN_HEIGHT = 30;
3361
+ var PIVOT_HEADER_WRAP_PADDING = 20;
3362
+ var AG_PIVOT_WRAPPING_HEADER_TEMPLATE = '<div class="ag-cell-label-container" role="presentation">' + ' <span ref="eMenu" class="ag-header-icon ag-header-cell-menu-button"></span>' + ' <div ref="eLabel" class="ag-header-cell-label" role="presentation">' + ' <span ref="eSortOrder" class="ag-header-icon ag-sort-order"></span>' + ' <span ref="eSortAsc" class="ag-header-icon ag-sort-ascending-icon"></span>' + ' <span ref="eSortDesc" class="ag-header-icon ag-sort-descending-icon"></span>' + ' <span ref="eSortNone" class="ag-header-icon ag-sort-none-icon"></span>' + ' <span ref="eText" class="ag-header-cell-text" role="columnheader" style="white-space: normal;"></span>' + ' <span ref="eFilter" class="ag-header-icon ag-filter-icon"></span>' + ' </div>' + '</div>';
3363
+
3364
+ var applyFlexiblePivotValueColumnSizing = function applyFlexiblePivotValueColumnSizing(colDef) {
3365
+ delete colDef.width;
3366
+ colDef.flex = 1;
3367
+ colDef.minWidth = PIVOT_VALUE_COLUMN_MIN_WIDTH;
3368
+ };
3369
+
3370
+ var getMaxHeaderTextClientHeight = function getMaxHeaderTextClientHeight(root, selector) {
3371
+ var nodes = root.querySelectorAll(selector);
3372
+ var maxHeight = 0;
3373
+
3374
+ for (var i = 0; i < nodes.length; i++) {
3375
+ var height = nodes[i].clientHeight;
3376
+ if (height > maxHeight) maxHeight = height;
3377
+ }
3378
+
3379
+ return maxHeight;
3380
+ };
3381
+
3382
+ var syncWrappedPivotHeaderHeights = function syncWrappedPivotHeaderHeights(api, root) {
3383
+ if (!api || !root) return;
3384
+ var apiAny = api;
3385
+ var leafTextHeight = getMaxHeaderTextClientHeight(root, '.ag-header-cell-text');
3386
+ var groupTextHeight = getMaxHeaderTextClientHeight(root, '.ag-header-group-text');
3387
+ var leafHeight = Math.max(PIVOT_HEADER_BASE_HEIGHT, leafTextHeight + PIVOT_HEADER_WRAP_PADDING);
3388
+ var groupHeight = Math.max(PIVOT_HEADER_BASE_HEIGHT, groupTextHeight + PIVOT_HEADER_WRAP_PADDING);
3389
+ if (apiAny.setPivotHeaderHeight) apiAny.setPivotHeaderHeight(leafHeight);
3390
+ if (apiAny.setHeaderHeight) apiAny.setHeaderHeight(leafHeight);
3391
+ if (apiAny.setPivotGroupHeaderHeight) apiAny.setPivotGroupHeaderHeight(groupHeight);
3392
+ if (apiAny.setGroupHeaderHeight) apiAny.setGroupHeaderHeight(groupHeight);
3393
+ };
3256
3394
 
3257
3395
  var applyAgGridLicense = function applyAgGridLicense() {
3258
3396
  if (!Session.AgGridLicenseKey) return;
@@ -3468,6 +3606,7 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3468
3606
  return formatPivotMeasureValue(params.value, measure);
3469
3607
  }
3470
3608
  };
3609
+ applyFlexiblePivotValueColumnSizing(colDef);
3471
3610
 
3472
3611
  if (!isPivotDateMinMaxMeasure(measure)) {
3473
3612
  colDef.type = 'numericColumn';
@@ -3494,26 +3633,45 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3494
3633
  };
3495
3634
 
3496
3635
  var canShowRowsTotal = function canShowRowsTotal() {
3636
+ var pivotRows = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotRows);
3637
+ if (pivotRows.length <= 1) return false;
3497
3638
  var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
3498
3639
  return !isNullOrUndefinedOrEmpty(settings.ShowRowsTotal) ? !!settings.ShowRowsTotal : false;
3499
3640
  };
3500
3641
 
3501
3642
  var canShowColumnsTotal = function canShowColumnsTotal() {
3643
+ var pivotColumns = parseJsonArray(widget === null || widget === void 0 ? void 0 : widget.PivotColumns);
3644
+ if (pivotColumns.length <= 1) return false;
3502
3645
  var settings = parsePivotTotalsSettings(widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings);
3503
3646
  return !isNullOrUndefinedOrEmpty(settings.ShowColumnsTotal) ? !!settings.ShowColumnsTotal : false;
3504
3647
  };
3505
3648
 
3649
+ var showColumnsTotal = canShowColumnsTotal();
3650
+ var pivotRowTotalsPosition = canShowColumnsGrandTotal() ? 'after' : '';
3651
+ useEffect(function () {
3652
+ if (!gridApiRef.current || isLoading || columnDefs.length === 0) return;
3653
+ gridApiRef.current.setColumnDefs(columnDefs.slice());
3654
+ }, [widget === null || widget === void 0 ? void 0 : widget.PivotTotalsSettings, showColumnsTotal, pivotRowTotalsPosition]);
3506
3655
  var isSingleMeasurePivot = measureCount <= 1;
3507
3656
  var processSecondaryColGroupDef = useCallback(function (colGroupDef) {
3508
3657
  var columnFields = pivotFieldsRef.current.filter(function (field) {
3509
3658
  return !isRowPivotField(field);
3510
3659
  });
3660
+
3661
+ if (showColumnsTotal) {
3662
+ promoteExpandablePivotColumnTotalsForDx(colGroupDef, columnFields, lookupDisplayName);
3663
+
3664
+ if (!colGroupDef.dlPivotColumnGroupTotal) {
3665
+ colGroupDef.openByDefault = true;
3666
+ }
3667
+ }
3668
+
3511
3669
  var headerName = resolvePivotGroupHeaderName(colGroupDef, columnFields, lookupDisplayName);
3512
3670
 
3513
3671
  if (headerName) {
3514
3672
  colGroupDef.headerName = headerName;
3515
3673
  }
3516
- }, []);
3674
+ }, [showColumnsTotal]);
3517
3675
  var processSecondaryColDef = useCallback(function (colDef) {
3518
3676
  var columnFields = pivotFieldsRef.current.filter(function (field) {
3519
3677
  return !isRowPivotField(field);
@@ -3532,6 +3690,13 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3532
3690
 
3533
3691
  var measure = resolveMeasureForSecondaryColDef(colDef, pivotMeasuresRef.current);
3534
3692
  applyPivotDataCellFormatting(colDef, measure);
3693
+ applyFlexiblePivotValueColumnSizing(colDef);
3694
+
3695
+ if (isAgGridPivotColumnGroupTotalColumn(colDefAny)) {
3696
+ var existingCellClass = colDef.cellClass ? String(colDef.cellClass) : '';
3697
+ colDef.cellClass = (existingCellClass + ' dl-pivot-column-group-total-cell').trim();
3698
+ colDef.headerClass = 'dl-pivot-column-group-total-header';
3699
+ }
3535
3700
 
3536
3701
  colDef.valueFormatter = function (params) {
3537
3702
  var resolvedMeasure = measure || resolveMeasureForSecondaryColDef(params.colDef, pivotMeasuresRef.current);
@@ -3566,13 +3731,27 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3566
3731
  resizable: false,
3567
3732
  suppressMenu: true,
3568
3733
  wrapText: true,
3569
- autoHeight: true
3734
+ autoHeight: true,
3735
+ headerComponentParams: {
3736
+ template: AG_PIVOT_WRAPPING_HEADER_TEMPLATE
3737
+ }
3570
3738
  };
3571
3739
  }, []);
3740
+ var scheduleWrappedPivotHeaderHeights = useCallback(function () {
3741
+ var run = function run() {
3742
+ return syncWrappedPivotHeaderHeights(gridApiRef.current, gridContainerRef.current);
3743
+ };
3744
+
3745
+ window.requestAnimationFrame(function () {
3746
+ run();
3747
+ window.setTimeout(run, 0);
3748
+ });
3749
+ }, []);
3572
3750
  var autoGroupColumnDef = useMemo(function () {
3573
3751
  return {
3574
3752
  minWidth: ROW_GROUP_COLUMN_MIN_WIDTH,
3575
3753
  width: ROW_GROUP_COLUMN_MIN_WIDTH,
3754
+ suppressSizeToFit: true,
3576
3755
  sortable: false,
3577
3756
  filter: false,
3578
3757
  wrapText: true,
@@ -3642,32 +3821,77 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3642
3821
  columnApi.autoSizeColumns(autoGroupColumnIds, false);
3643
3822
  }
3644
3823
 
3824
+ scheduleWrappedPivotHeaderHeights();
3645
3825
  scheduleRowGrandTotalHeaderLabel();
3646
3826
  };
3647
3827
 
3648
3828
  var onColumnPivotChanged = function onColumnPivotChanged() {
3829
+ scheduleWrappedPivotHeaderHeights();
3649
3830
  scheduleRowGrandTotalHeaderLabel();
3650
3831
  };
3651
3832
 
3652
3833
  var onColumnResized = function onColumnResized() {
3834
+ scheduleWrappedPivotHeaderHeights();
3653
3835
  scheduleRowGrandTotalHeaderLabel();
3654
3836
  };
3655
3837
 
3656
3838
  var getContextMenuItems = useCallback(function (params) {
3657
3839
  var colId = params.column && params.column.getColId ? params.column.getColId() : '';
3658
- if (!colId || colId.indexOf('ag-Grid-AutoColumn') !== 0) return [];
3840
+ var isRowLabelColumn = !!(colId && colId.indexOf('ag-Grid-AutoColumn') === 0);
3841
+
3842
+ if (isRowLabelColumn) {
3843
+ return [{
3844
+ name: 'Expand All',
3845
+ action: function action() {
3846
+ if (params.api) params.api.expandAll();
3847
+ }
3848
+ }, {
3849
+ name: 'Collapse All',
3850
+ action: function action() {
3851
+ if (params.api) params.api.collapseAll();
3852
+ }
3853
+ }];
3854
+ }
3855
+
3856
+ var columnApi = columnApiRef.current;
3857
+ if (!columnApi || !columnApi.getColumnGroupState) return [];
3858
+ var groupState = columnApi.getColumnGroupState();
3859
+ if (!groupState || groupState.length === 0) return [];
3659
3860
  return [{
3660
3861
  name: 'Expand All',
3661
3862
  action: function action() {
3662
- if (params.api) params.api.expandAll();
3863
+ return setAllAgGridColumnGroupsOpened(columnApi, true);
3663
3864
  }
3664
3865
  }, {
3665
3866
  name: 'Collapse All',
3666
3867
  action: function action() {
3667
- if (params.api) params.api.collapseAll();
3868
+ return setAllAgGridColumnGroupsOpened(columnApi, false);
3668
3869
  }
3669
3870
  }];
3670
3871
  }, []);
3872
+ useEffect(function () {
3873
+ var container = gridContainerRef.current;
3874
+ if (!container || isLoading) return;
3875
+
3876
+ var onHeaderContextMenu = function onHeaderContextMenu(event) {
3877
+ var target = event.target;
3878
+ if (!target) return;
3879
+ var headerCell = target.closest('.ag-header-cell, .ag-header-group-cell');
3880
+ if (!headerCell) return;
3881
+ var colId = headerCell.getAttribute('col-id') || '';
3882
+ if (colId.indexOf('ag-Grid-AutoColumn') === 0) return;
3883
+ var api = gridApiRef.current;
3884
+ if (!api || !api.contextMenuFactory || !api.contextMenuFactory.onContextMenu) return;
3885
+ event.preventDefault();
3886
+ event.stopPropagation();
3887
+ api.contextMenuFactory.onContextMenu(event, null, null, null, null, headerCell);
3888
+ };
3889
+
3890
+ container.addEventListener('contextmenu', onHeaderContextMenu);
3891
+ return function () {
3892
+ return container.removeEventListener('contextmenu', onHeaderContextMenu);
3893
+ };
3894
+ }, [isLoading]);
3671
3895
  var gridWrapperClassName = 'ag-theme-balham pivot-grid-element dl-ag-pivot-grid';
3672
3896
  return React__default.createElement(React__default.Fragment, null, isLoading ? React__default.createElement("div", {
3673
3897
  className: 'dl-full-hight dl-flex-content-center spinner-custome'
@@ -3694,8 +3918,9 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3694
3918
  removePivotHeaderRowWhenSingleValueColumn: isSingleMeasurePivot,
3695
3919
  groupIncludeFooter: canShowRowsTotal(),
3696
3920
  groupIncludeTotalFooter: canShowRowsGrandTotal(),
3697
- pivotRowTotals: canShowColumnsGrandTotal() ? 'after' : undefined,
3698
- pivotColumnGroupTotals: canShowColumnsTotal() ? 'after' : undefined,
3921
+ pivotRowTotals: pivotRowTotalsPosition,
3922
+ pivotColumnGroupTotals: '',
3923
+ suppressExpandablePivotGroups: !showColumnsTotal,
3699
3924
  processSecondaryColGroupDef: processSecondaryColGroupDef,
3700
3925
  processSecondaryColDef: processSecondaryColDef,
3701
3926
  onCellClicked: onCellClicked,
@@ -3706,8 +3931,11 @@ var AgPivotGrid = forwardRef(function (props, _comRef) {
3706
3931
  getContextMenuItems: getContextMenuItems,
3707
3932
  animateRows: false,
3708
3933
  suppressMovableColumns: true,
3709
- headerHeight: 36,
3710
- rowHeight: 36
3934
+ headerHeight: PIVOT_HEADER_BASE_HEIGHT,
3935
+ groupHeaderHeight: PIVOT_HEADER_BASE_HEIGHT,
3936
+ pivotHeaderHeight: PIVOT_HEADER_BASE_HEIGHT,
3937
+ pivotGroupHeaderHeight: PIVOT_HEADER_BASE_HEIGHT,
3938
+ rowHeight: PIVOT_ROW_MIN_HEIGHT
3711
3939
  })));
3712
3940
  });
3713
3941