@deephaven/js-plugin-pivot 0.0.3-dev.984 → 0.2.0-alpha-pivots.225e162
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/dist/index.js +1279 -816
- package/package.json +17 -13
package/dist/index.js
CHANGED
|
@@ -10,8 +10,8 @@ const plugin = require("@deephaven/plugin");
|
|
|
10
10
|
const icons = require("@deephaven/icons");
|
|
11
11
|
const React = require("react");
|
|
12
12
|
const irisGrid = require("@deephaven/iris-grid");
|
|
13
|
-
const jsapiBootstrap = require("@deephaven/jsapi-bootstrap");
|
|
14
13
|
const components = require("@deephaven/components");
|
|
14
|
+
const jsapiBootstrap = require("@deephaven/jsapi-bootstrap");
|
|
15
15
|
const Log = require("@deephaven/log");
|
|
16
16
|
const jsapiUtils = require("@deephaven/jsapi-utils");
|
|
17
17
|
const dashboardCorePlugins = require("@deephaven/dashboard-core-plugins");
|
|
@@ -274,6 +274,9 @@ class EventShimCustomEvent extends CustomEvent {
|
|
|
274
274
|
super(typeArg, eventInitDict);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
+
function isNotNullOrUndefined(value2) {
|
|
278
|
+
return value2 != null;
|
|
279
|
+
}
|
|
277
280
|
function assertNotNull(value2) {
|
|
278
281
|
var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Value is null or undefined";
|
|
279
282
|
if (value2 == null)
|
|
@@ -499,9 +502,6 @@ function isEditableGridModel(model) {
|
|
|
499
502
|
function isExpandableGridModel(model) {
|
|
500
503
|
return (model === null || model === void 0 ? void 0 : model.hasExpandableRows) !== void 0;
|
|
501
504
|
}
|
|
502
|
-
function isExpandableColumnGridModel(model) {
|
|
503
|
-
return (model === null || model === void 0 ? void 0 : model.hasExpandableColumns) !== void 0;
|
|
504
|
-
}
|
|
505
505
|
var NAN = 0 / 0;
|
|
506
506
|
var symbolTag = "[object Symbol]";
|
|
507
507
|
var reTrim = /^\s+|\s+$/g;
|
|
@@ -1693,30 +1693,24 @@ function find(str2, type = null, opts = null) {
|
|
|
1693
1693
|
}
|
|
1694
1694
|
return filtered;
|
|
1695
1695
|
}
|
|
1696
|
-
function _defineProperty$9(
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
var
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
return input;
|
|
1712
|
-
var prim = input[Symbol.toPrimitive];
|
|
1713
|
-
if (prim !== void 0) {
|
|
1714
|
-
var res = prim.call(input, hint || "default");
|
|
1715
|
-
if (typeof res !== "object")
|
|
1716
|
-
return res;
|
|
1696
|
+
function _defineProperty$9(e, r, t) {
|
|
1697
|
+
return (r = _toPropertyKey$9(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
1698
|
+
}
|
|
1699
|
+
function _toPropertyKey$9(t) {
|
|
1700
|
+
var i = _toPrimitive$9(t, "string");
|
|
1701
|
+
return "symbol" == typeof i ? i : i + "";
|
|
1702
|
+
}
|
|
1703
|
+
function _toPrimitive$9(t, r) {
|
|
1704
|
+
if ("object" != typeof t || !t)
|
|
1705
|
+
return t;
|
|
1706
|
+
var e = t[Symbol.toPrimitive];
|
|
1707
|
+
if (void 0 !== e) {
|
|
1708
|
+
var i = e.call(t, r || "default");
|
|
1709
|
+
if ("object" != typeof i)
|
|
1710
|
+
return i;
|
|
1717
1711
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1718
1712
|
}
|
|
1719
|
-
return (
|
|
1713
|
+
return ("string" === r ? String : Number)(t);
|
|
1720
1714
|
}
|
|
1721
1715
|
var SELECTION_DIRECTION;
|
|
1722
1716
|
(function(SELECTION_DIRECTION2) {
|
|
@@ -2352,51 +2346,45 @@ function isAxisRange(range) {
|
|
|
2352
2346
|
function isBoundedAxisRange(range) {
|
|
2353
2347
|
return isAxisRange(range) && range[0] != null && range[1] != null;
|
|
2354
2348
|
}
|
|
2355
|
-
function ownKeys$1(
|
|
2356
|
-
var
|
|
2349
|
+
function ownKeys$1(e, r) {
|
|
2350
|
+
var t = Object.keys(e);
|
|
2357
2351
|
if (Object.getOwnPropertySymbols) {
|
|
2358
|
-
var
|
|
2359
|
-
|
|
2360
|
-
return Object.getOwnPropertyDescriptor(
|
|
2361
|
-
})),
|
|
2362
|
-
}
|
|
2363
|
-
return
|
|
2364
|
-
}
|
|
2365
|
-
function _objectSpread$1(
|
|
2366
|
-
for (var
|
|
2367
|
-
var
|
|
2368
|
-
|
|
2369
|
-
_defineProperty$8(
|
|
2370
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
2371
|
-
Object.defineProperty(
|
|
2352
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
2353
|
+
r && (o = o.filter(function(r2) {
|
|
2354
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
2355
|
+
})), t.push.apply(t, o);
|
|
2356
|
+
}
|
|
2357
|
+
return t;
|
|
2358
|
+
}
|
|
2359
|
+
function _objectSpread$1(e) {
|
|
2360
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
2361
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
2362
|
+
r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
|
|
2363
|
+
_defineProperty$8(e, r2, t[r2]);
|
|
2364
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
|
|
2365
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
2372
2366
|
});
|
|
2373
2367
|
}
|
|
2374
|
-
return
|
|
2368
|
+
return e;
|
|
2375
2369
|
}
|
|
2376
|
-
function _defineProperty$8(
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
var
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
return input;
|
|
2392
|
-
var prim = input[Symbol.toPrimitive];
|
|
2393
|
-
if (prim !== void 0) {
|
|
2394
|
-
var res = prim.call(input, hint || "default");
|
|
2395
|
-
if (typeof res !== "object")
|
|
2396
|
-
return res;
|
|
2370
|
+
function _defineProperty$8(e, r, t) {
|
|
2371
|
+
return (r = _toPropertyKey$8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
2372
|
+
}
|
|
2373
|
+
function _toPropertyKey$8(t) {
|
|
2374
|
+
var i = _toPrimitive$8(t, "string");
|
|
2375
|
+
return "symbol" == typeof i ? i : i + "";
|
|
2376
|
+
}
|
|
2377
|
+
function _toPrimitive$8(t, r) {
|
|
2378
|
+
if ("object" != typeof t || !t)
|
|
2379
|
+
return t;
|
|
2380
|
+
var e = t[Symbol.toPrimitive];
|
|
2381
|
+
if (void 0 !== e) {
|
|
2382
|
+
var i = e.call(t, r || "default");
|
|
2383
|
+
if ("object" != typeof i)
|
|
2384
|
+
return i;
|
|
2397
2385
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2398
2386
|
}
|
|
2399
|
-
return (
|
|
2387
|
+
return ("string" === r ? String : Number)(t);
|
|
2400
2388
|
}
|
|
2401
2389
|
class GridUtils {
|
|
2402
2390
|
// use same constant as chrome source for windows
|
|
@@ -2669,15 +2657,35 @@ class GridUtils {
|
|
|
2669
2657
|
} = metrics;
|
|
2670
2658
|
return GridUtils.getNextShownItem(startIndex, modelRows, visibleRows, userRowHeights);
|
|
2671
2659
|
}
|
|
2660
|
+
/**
|
|
2661
|
+
* Check if a separator exists between a column and the next column at a given depth.
|
|
2662
|
+
* A separator exists if adjacent columns have different header text at the specified depth.
|
|
2663
|
+
*
|
|
2664
|
+
* @param model The grid model
|
|
2665
|
+
* @param depth The header depth to check at
|
|
2666
|
+
* @param columnIndex The current model column index
|
|
2667
|
+
* @param nextColumnIndex The next model column index (undefined for last column)
|
|
2668
|
+
* @returns true if a separator should be shown, false otherwise
|
|
2669
|
+
*/
|
|
2670
|
+
static hasColumnSeparatorAtDepth(model, depth, columnIndex, nextColumnIndex) {
|
|
2671
|
+
if (depth == null || columnIndex == null) {
|
|
2672
|
+
return false;
|
|
2673
|
+
}
|
|
2674
|
+
if (nextColumnIndex == null) {
|
|
2675
|
+
return true;
|
|
2676
|
+
}
|
|
2677
|
+
return model.textForColumnHeader(columnIndex, depth) !== model.textForColumnHeader(nextColumnIndex, depth);
|
|
2678
|
+
}
|
|
2672
2679
|
/**
|
|
2673
2680
|
* Gets the column index if the x/y coordinates provided are close enough to the separator, otherwise null
|
|
2674
2681
|
* @param x Mouse x coordinate
|
|
2675
2682
|
* @param y Mouse y coordinate
|
|
2676
2683
|
* @param metrics The grid metrics
|
|
2677
2684
|
* @param theme The grid theme with potential user overrides
|
|
2685
|
+
* @param model The grid model
|
|
2678
2686
|
* @returns Index of the column separator at the coordinates provided, or null if none match
|
|
2679
2687
|
*/
|
|
2680
|
-
static getColumnSeparatorIndex(x, y, metrics, theme) {
|
|
2688
|
+
static getColumnSeparatorIndex(x, y, metrics, theme, model) {
|
|
2681
2689
|
var {
|
|
2682
2690
|
rowHeaderWidth,
|
|
2683
2691
|
columnHeaderHeight,
|
|
@@ -2686,7 +2694,8 @@ class GridUtils {
|
|
|
2686
2694
|
visibleColumns,
|
|
2687
2695
|
allColumnXs,
|
|
2688
2696
|
allColumnWidths,
|
|
2689
|
-
columnHeaderMaxDepth
|
|
2697
|
+
columnHeaderMaxDepth,
|
|
2698
|
+
modelColumns
|
|
2690
2699
|
} = metrics;
|
|
2691
2700
|
var {
|
|
2692
2701
|
allowColumnResize,
|
|
@@ -2697,6 +2706,7 @@ class GridUtils {
|
|
|
2697
2706
|
}
|
|
2698
2707
|
var gridX = x - rowHeaderWidth;
|
|
2699
2708
|
var halfSeparatorSize = headerSeparatorHandleSize * 0.5;
|
|
2709
|
+
var depth = GridUtils.getColumnHeaderDepthAtY(y, metrics);
|
|
2700
2710
|
var isPreviousColumnHidden = false;
|
|
2701
2711
|
for (var i = floatingColumns.length - 1; i >= 0; i -= 1) {
|
|
2702
2712
|
var _allColumnXs$get, _allColumnWidths$get;
|
|
@@ -2713,7 +2723,7 @@ class GridUtils {
|
|
|
2713
2723
|
}
|
|
2714
2724
|
var minX = midX - halfSeparatorSize;
|
|
2715
2725
|
var maxX = midX + halfSeparatorSize;
|
|
2716
|
-
if (minX <= gridX && gridX <= maxX) {
|
|
2726
|
+
if (minX <= gridX && gridX <= maxX && GridUtils.hasColumnSeparatorAtDepth(model, depth, modelColumns.get(column), modelColumns.get(column + 1))) {
|
|
2717
2727
|
return column;
|
|
2718
2728
|
}
|
|
2719
2729
|
isPreviousColumnHidden = isColumnHidden;
|
|
@@ -2738,7 +2748,7 @@ class GridUtils {
|
|
|
2738
2748
|
}
|
|
2739
2749
|
var _minX = _midX - halfSeparatorSize;
|
|
2740
2750
|
var _maxX = _midX + halfSeparatorSize;
|
|
2741
|
-
if (_minX <= gridX && gridX <= _maxX) {
|
|
2751
|
+
if (_minX <= gridX && gridX <= _maxX && GridUtils.hasColumnSeparatorAtDepth(model, depth, modelColumns.get(_column), modelColumns.get(_column + 1))) {
|
|
2742
2752
|
return _column;
|
|
2743
2753
|
}
|
|
2744
2754
|
isPreviousColumnHidden = _isColumnHidden;
|
|
@@ -5877,51 +5887,45 @@ var memoizee = function(fn) {
|
|
|
5877
5887
|
requireRefCounter();
|
|
5878
5888
|
return plain(fn, options);
|
|
5879
5889
|
};
|
|
5880
|
-
function ownKeys(
|
|
5881
|
-
var
|
|
5890
|
+
function ownKeys(e, r) {
|
|
5891
|
+
var t = Object.keys(e);
|
|
5882
5892
|
if (Object.getOwnPropertySymbols) {
|
|
5883
|
-
var
|
|
5884
|
-
|
|
5885
|
-
return Object.getOwnPropertyDescriptor(
|
|
5886
|
-
})),
|
|
5887
|
-
}
|
|
5888
|
-
return
|
|
5889
|
-
}
|
|
5890
|
-
function _objectSpread(
|
|
5891
|
-
for (var
|
|
5892
|
-
var
|
|
5893
|
-
|
|
5894
|
-
_defineProperty$7(
|
|
5895
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
5896
|
-
Object.defineProperty(
|
|
5893
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
5894
|
+
r && (o = o.filter(function(r2) {
|
|
5895
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
5896
|
+
})), t.push.apply(t, o);
|
|
5897
|
+
}
|
|
5898
|
+
return t;
|
|
5899
|
+
}
|
|
5900
|
+
function _objectSpread(e) {
|
|
5901
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
5902
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
5903
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
5904
|
+
_defineProperty$7(e, r2, t[r2]);
|
|
5905
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
5906
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
5897
5907
|
});
|
|
5898
5908
|
}
|
|
5899
|
-
return
|
|
5909
|
+
return e;
|
|
5900
5910
|
}
|
|
5901
|
-
function _defineProperty$7(
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
var
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
return input;
|
|
5917
|
-
var prim = input[Symbol.toPrimitive];
|
|
5918
|
-
if (prim !== void 0) {
|
|
5919
|
-
var res = prim.call(input, hint || "default");
|
|
5920
|
-
if (typeof res !== "object")
|
|
5921
|
-
return res;
|
|
5911
|
+
function _defineProperty$7(e, r, t) {
|
|
5912
|
+
return (r = _toPropertyKey$7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
5913
|
+
}
|
|
5914
|
+
function _toPropertyKey$7(t) {
|
|
5915
|
+
var i = _toPrimitive$7(t, "string");
|
|
5916
|
+
return "symbol" == typeof i ? i : i + "";
|
|
5917
|
+
}
|
|
5918
|
+
function _toPrimitive$7(t, r) {
|
|
5919
|
+
if ("object" != typeof t || !t)
|
|
5920
|
+
return t;
|
|
5921
|
+
var e = t[Symbol.toPrimitive];
|
|
5922
|
+
if (void 0 !== e) {
|
|
5923
|
+
var i = e.call(t, r || "default");
|
|
5924
|
+
if ("object" != typeof i)
|
|
5925
|
+
return i;
|
|
5922
5926
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
5923
5927
|
}
|
|
5924
|
-
return (
|
|
5928
|
+
return ("string" === r ? String : Number)(t);
|
|
5925
5929
|
}
|
|
5926
5930
|
var memoizeClear = (fn, options) => {
|
|
5927
5931
|
var isClearingCache = false;
|
|
@@ -6966,30 +6970,24 @@ const GridColorUtils = {
|
|
|
6966
6970
|
rgbToHex,
|
|
6967
6971
|
lerpColor
|
|
6968
6972
|
};
|
|
6969
|
-
function _defineProperty$6(
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
var
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
return input;
|
|
6985
|
-
var prim = input[Symbol.toPrimitive];
|
|
6986
|
-
if (prim !== void 0) {
|
|
6987
|
-
var res = prim.call(input, hint || "default");
|
|
6988
|
-
if (typeof res !== "object")
|
|
6989
|
-
return res;
|
|
6973
|
+
function _defineProperty$6(e, r, t) {
|
|
6974
|
+
return (r = _toPropertyKey$6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
6975
|
+
}
|
|
6976
|
+
function _toPropertyKey$6(t) {
|
|
6977
|
+
var i = _toPrimitive$6(t, "string");
|
|
6978
|
+
return "symbol" == typeof i ? i : i + "";
|
|
6979
|
+
}
|
|
6980
|
+
function _toPrimitive$6(t, r) {
|
|
6981
|
+
if ("object" != typeof t || !t)
|
|
6982
|
+
return t;
|
|
6983
|
+
var e = t[Symbol.toPrimitive];
|
|
6984
|
+
if (void 0 !== e) {
|
|
6985
|
+
var i = e.call(t, r || "default");
|
|
6986
|
+
if ("object" != typeof i)
|
|
6987
|
+
return i;
|
|
6990
6988
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
6991
6989
|
}
|
|
6992
|
-
return (
|
|
6990
|
+
return ("string" === r ? String : Number)(t);
|
|
6993
6991
|
}
|
|
6994
6992
|
class GridMouseHandler {
|
|
6995
6993
|
// What order this mouse handler should trigger in. Smaller numbers trigger first
|
|
@@ -7029,30 +7027,24 @@ class GridMouseHandler {
|
|
|
7029
7027
|
return false;
|
|
7030
7028
|
}
|
|
7031
7029
|
}
|
|
7032
|
-
function _defineProperty$5(
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
var
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
return input;
|
|
7048
|
-
var prim = input[Symbol.toPrimitive];
|
|
7049
|
-
if (prim !== void 0) {
|
|
7050
|
-
var res = prim.call(input, hint || "default");
|
|
7051
|
-
if (typeof res !== "object")
|
|
7052
|
-
return res;
|
|
7030
|
+
function _defineProperty$5(e, r, t) {
|
|
7031
|
+
return (r = _toPropertyKey$5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
7032
|
+
}
|
|
7033
|
+
function _toPropertyKey$5(t) {
|
|
7034
|
+
var i = _toPrimitive$5(t, "string");
|
|
7035
|
+
return "symbol" == typeof i ? i : i + "";
|
|
7036
|
+
}
|
|
7037
|
+
function _toPrimitive$5(t, r) {
|
|
7038
|
+
if ("object" != typeof t || !t)
|
|
7039
|
+
return t;
|
|
7040
|
+
var e = t[Symbol.toPrimitive];
|
|
7041
|
+
if (void 0 !== e) {
|
|
7042
|
+
var i = e.call(t, r || "default");
|
|
7043
|
+
if ("object" != typeof i)
|
|
7044
|
+
return i;
|
|
7053
7045
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7054
7046
|
}
|
|
7055
|
-
return (
|
|
7047
|
+
return ("string" === r ? String : Number)(t);
|
|
7056
7048
|
}
|
|
7057
7049
|
class GridSeparatorMouseHandler extends GridMouseHandler {
|
|
7058
7050
|
constructor() {
|
|
@@ -7260,30 +7252,24 @@ class GridSeparatorMouseHandler extends GridMouseHandler {
|
|
|
7260
7252
|
}
|
|
7261
7253
|
}
|
|
7262
7254
|
const GridSeparatorMouseHandler$1 = GridSeparatorMouseHandler;
|
|
7263
|
-
function _defineProperty$4(
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
var
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
return input;
|
|
7279
|
-
var prim = input[Symbol.toPrimitive];
|
|
7280
|
-
if (prim !== void 0) {
|
|
7281
|
-
var res = prim.call(input, hint || "default");
|
|
7282
|
-
if (typeof res !== "object")
|
|
7283
|
-
return res;
|
|
7255
|
+
function _defineProperty$4(e, r, t) {
|
|
7256
|
+
return (r = _toPropertyKey$4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
7257
|
+
}
|
|
7258
|
+
function _toPropertyKey$4(t) {
|
|
7259
|
+
var i = _toPrimitive$4(t, "string");
|
|
7260
|
+
return "symbol" == typeof i ? i : i + "";
|
|
7261
|
+
}
|
|
7262
|
+
function _toPrimitive$4(t, r) {
|
|
7263
|
+
if ("object" != typeof t || !t)
|
|
7264
|
+
return t;
|
|
7265
|
+
var e = t[Symbol.toPrimitive];
|
|
7266
|
+
if (void 0 !== e) {
|
|
7267
|
+
var i = e.call(t, r || "default");
|
|
7268
|
+
if ("object" != typeof i)
|
|
7269
|
+
return i;
|
|
7284
7270
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7285
7271
|
}
|
|
7286
|
-
return (
|
|
7272
|
+
return ("string" === r ? String : Number)(t);
|
|
7287
7273
|
}
|
|
7288
7274
|
class GridColumnSeparatorMouseHandler extends GridSeparatorMouseHandler$1 {
|
|
7289
7275
|
constructor() {
|
|
@@ -7311,20 +7297,20 @@ class GridColumnSeparatorMouseHandler extends GridSeparatorMouseHandler$1 {
|
|
|
7311
7297
|
var {
|
|
7312
7298
|
x,
|
|
7313
7299
|
y,
|
|
7314
|
-
columnHeaderDepth
|
|
7300
|
+
columnHeaderDepth: depth
|
|
7315
7301
|
} = gridPoint;
|
|
7316
7302
|
var {
|
|
7317
7303
|
modelColumns
|
|
7318
7304
|
} = metrics;
|
|
7319
|
-
var separatorIndex = GridUtils.getColumnSeparatorIndex(x, y, metrics, theme);
|
|
7320
|
-
if (separatorIndex == null ||
|
|
7305
|
+
var separatorIndex = GridUtils.getColumnSeparatorIndex(x, y, metrics, theme, model);
|
|
7306
|
+
if (separatorIndex == null || depth == null) {
|
|
7321
7307
|
return null;
|
|
7322
7308
|
}
|
|
7323
7309
|
var columnIndex = modelColumns.get(separatorIndex);
|
|
7324
7310
|
if (columnIndex != null) {
|
|
7325
7311
|
return {
|
|
7326
7312
|
index: separatorIndex,
|
|
7327
|
-
depth
|
|
7313
|
+
depth
|
|
7328
7314
|
};
|
|
7329
7315
|
}
|
|
7330
7316
|
return null;
|
|
@@ -7344,30 +7330,24 @@ class GridColumnSeparatorMouseHandler extends GridSeparatorMouseHandler$1 {
|
|
|
7344
7330
|
}
|
|
7345
7331
|
const GridColumnSeparatorMouseHandler$1 = GridColumnSeparatorMouseHandler;
|
|
7346
7332
|
var DEFAULT_FONT_WIDTH = 10;
|
|
7347
|
-
function _defineProperty$3(
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
var
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
return input;
|
|
7363
|
-
var prim = input[Symbol.toPrimitive];
|
|
7364
|
-
if (prim !== void 0) {
|
|
7365
|
-
var res = prim.call(input, hint || "default");
|
|
7366
|
-
if (typeof res !== "object")
|
|
7367
|
-
return res;
|
|
7333
|
+
function _defineProperty$3(e, r, t) {
|
|
7334
|
+
return (r = _toPropertyKey$3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
7335
|
+
}
|
|
7336
|
+
function _toPropertyKey$3(t) {
|
|
7337
|
+
var i = _toPrimitive$3(t, "string");
|
|
7338
|
+
return "symbol" == typeof i ? i : i + "";
|
|
7339
|
+
}
|
|
7340
|
+
function _toPrimitive$3(t, r) {
|
|
7341
|
+
if ("object" != typeof t || !t)
|
|
7342
|
+
return t;
|
|
7343
|
+
var e = t[Symbol.toPrimitive];
|
|
7344
|
+
if (void 0 !== e) {
|
|
7345
|
+
var i = e.call(t, r || "default");
|
|
7346
|
+
if ("object" != typeof i)
|
|
7347
|
+
return i;
|
|
7368
7348
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7369
7349
|
}
|
|
7370
|
-
return (
|
|
7350
|
+
return ("string" === r ? String : Number)(t);
|
|
7371
7351
|
}
|
|
7372
7352
|
class CellRenderer {
|
|
7373
7353
|
constructor() {
|
|
@@ -7427,30 +7407,24 @@ const CellRenderer$1 = CellRenderer;
|
|
|
7427
7407
|
function isDataBarGridModel(model) {
|
|
7428
7408
|
return (model === null || model === void 0 ? void 0 : model.dataBarOptionsForCell) !== void 0;
|
|
7429
7409
|
}
|
|
7430
|
-
function _defineProperty$2(
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
var
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
return input;
|
|
7446
|
-
var prim = input[Symbol.toPrimitive];
|
|
7447
|
-
if (prim !== void 0) {
|
|
7448
|
-
var res = prim.call(input, hint || "default");
|
|
7449
|
-
if (typeof res !== "object")
|
|
7450
|
-
return res;
|
|
7410
|
+
function _defineProperty$2(e, r, t) {
|
|
7411
|
+
return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
7412
|
+
}
|
|
7413
|
+
function _toPropertyKey$2(t) {
|
|
7414
|
+
var i = _toPrimitive$2(t, "string");
|
|
7415
|
+
return "symbol" == typeof i ? i : i + "";
|
|
7416
|
+
}
|
|
7417
|
+
function _toPrimitive$2(t, r) {
|
|
7418
|
+
if ("object" != typeof t || !t)
|
|
7419
|
+
return t;
|
|
7420
|
+
var e = t[Symbol.toPrimitive];
|
|
7421
|
+
if (void 0 !== e) {
|
|
7422
|
+
var i = e.call(t, r || "default");
|
|
7423
|
+
if ("object" != typeof i)
|
|
7424
|
+
return i;
|
|
7451
7425
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7452
7426
|
}
|
|
7453
|
-
return (
|
|
7427
|
+
return ("string" === r ? String : Number)(t);
|
|
7454
7428
|
}
|
|
7455
7429
|
class DataBarCellRenderer extends CellRenderer$1 {
|
|
7456
7430
|
constructor() {
|
|
@@ -7804,30 +7778,24 @@ _defineProperty$2(DataBarCellRenderer, "getGradient", memoizeClear$1((width, col
|
|
|
7804
7778
|
// Stringify the arguments for memoization. Lets the color arrays be different arrays in memory, but still cache hit
|
|
7805
7779
|
}));
|
|
7806
7780
|
const DataBarCellRenderer$1 = DataBarCellRenderer;
|
|
7807
|
-
function _defineProperty$1(
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
var
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
return input;
|
|
7823
|
-
var prim = input[Symbol.toPrimitive];
|
|
7824
|
-
if (prim !== void 0) {
|
|
7825
|
-
var res = prim.call(input, hint || "default");
|
|
7826
|
-
if (typeof res !== "object")
|
|
7827
|
-
return res;
|
|
7781
|
+
function _defineProperty$1(e, r, t) {
|
|
7782
|
+
return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
7783
|
+
}
|
|
7784
|
+
function _toPropertyKey$1(t) {
|
|
7785
|
+
var i = _toPrimitive$1(t, "string");
|
|
7786
|
+
return "symbol" == typeof i ? i : i + "";
|
|
7787
|
+
}
|
|
7788
|
+
function _toPrimitive$1(t, r) {
|
|
7789
|
+
if ("object" != typeof t || !t)
|
|
7790
|
+
return t;
|
|
7791
|
+
var e = t[Symbol.toPrimitive];
|
|
7792
|
+
if (void 0 !== e) {
|
|
7793
|
+
var i = e.call(t, r || "default");
|
|
7794
|
+
if ("object" != typeof i)
|
|
7795
|
+
return i;
|
|
7828
7796
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7829
7797
|
}
|
|
7830
|
-
return (
|
|
7798
|
+
return ("string" === r ? String : Number)(t);
|
|
7831
7799
|
}
|
|
7832
7800
|
class TextCellRenderer extends CellRenderer$1 {
|
|
7833
7801
|
constructor() {
|
|
@@ -8012,30 +7980,24 @@ class TextCellRenderer extends CellRenderer$1 {
|
|
|
8012
7980
|
*/
|
|
8013
7981
|
}
|
|
8014
7982
|
const TextCellRenderer$1 = TextCellRenderer;
|
|
8015
|
-
function _defineProperty(
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
var
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
return input;
|
|
8031
|
-
var prim = input[Symbol.toPrimitive];
|
|
8032
|
-
if (prim !== void 0) {
|
|
8033
|
-
var res = prim.call(input, hint || "default");
|
|
8034
|
-
if (typeof res !== "object")
|
|
8035
|
-
return res;
|
|
7983
|
+
function _defineProperty(e, r, t) {
|
|
7984
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
7985
|
+
}
|
|
7986
|
+
function _toPropertyKey(t) {
|
|
7987
|
+
var i = _toPrimitive(t, "string");
|
|
7988
|
+
return "symbol" == typeof i ? i : i + "";
|
|
7989
|
+
}
|
|
7990
|
+
function _toPrimitive(t, r) {
|
|
7991
|
+
if ("object" != typeof t || !t)
|
|
7992
|
+
return t;
|
|
7993
|
+
var e = t[Symbol.toPrimitive];
|
|
7994
|
+
if (void 0 !== e) {
|
|
7995
|
+
var i = e.call(t, r || "default");
|
|
7996
|
+
if ("object" != typeof i)
|
|
7997
|
+
return i;
|
|
8036
7998
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
8037
7999
|
}
|
|
8038
|
-
return (
|
|
8000
|
+
return ("string" === r ? String : Number)(t);
|
|
8039
8001
|
}
|
|
8040
8002
|
class GridRenderer {
|
|
8041
8003
|
constructor() {
|
|
@@ -9023,7 +8985,8 @@ class GridRenderer {
|
|
|
9023
8985
|
var columnIndex = startIndex;
|
|
9024
8986
|
while (columnIndex <= endIndex) {
|
|
9025
8987
|
var {
|
|
9026
|
-
columnCount
|
|
8988
|
+
columnCount,
|
|
8989
|
+
calculatedColumnWidths
|
|
9027
8990
|
} = metrics;
|
|
9028
8991
|
var modelColumn = getOrThrow(modelColumns, columnIndex);
|
|
9029
8992
|
var columnGroupName = model.textForColumnHeader(modelColumn, depth);
|
|
@@ -9033,23 +8996,23 @@ class GridRenderer {
|
|
|
9033
8996
|
if (columnGroupName != null) {
|
|
9034
8997
|
var prevColumnIndex = columnIndex - 1;
|
|
9035
8998
|
while (prevColumnIndex >= 0 && (columnGroupRight - columnGroupLeft < visibleWidth || columnGroupLeft > minX)) {
|
|
9036
|
-
var _modelColumns$get, _ref3, _userColumnWidths$get;
|
|
8999
|
+
var _modelColumns$get, _ref3, _ref4, _userColumnWidths$get;
|
|
9037
9000
|
var prevModelIndex = (_modelColumns$get = modelColumns.get(prevColumnIndex)) !== null && _modelColumns$get !== void 0 ? _modelColumns$get : GridUtils.getModelIndex(prevColumnIndex, movedColumns);
|
|
9038
9001
|
if (prevModelIndex == null || model.textForColumnHeader(prevModelIndex, depth) !== columnGroupName) {
|
|
9039
9002
|
break;
|
|
9040
9003
|
}
|
|
9041
|
-
var prevColumnWidth = (_ref3 = (_userColumnWidths$get = userColumnWidths.get(prevModelIndex)) !== null && _userColumnWidths$get !== void 0 ? _userColumnWidths$get : allColumnWidths.get(prevColumnIndex)) !== null && _ref3 !== void 0 ? _ref3 : columnWidth;
|
|
9004
|
+
var prevColumnWidth = (_ref3 = (_ref4 = (_userColumnWidths$get = userColumnWidths.get(prevModelIndex)) !== null && _userColumnWidths$get !== void 0 ? _userColumnWidths$get : allColumnWidths.get(prevColumnIndex)) !== null && _ref4 !== void 0 ? _ref4 : calculatedColumnWidths.get(prevModelIndex)) !== null && _ref3 !== void 0 ? _ref3 : columnWidth;
|
|
9042
9005
|
columnGroupLeft -= prevColumnWidth;
|
|
9043
9006
|
prevColumnIndex -= 1;
|
|
9044
9007
|
}
|
|
9045
9008
|
var nextColumnIndex = columnIndex + 1;
|
|
9046
9009
|
while (nextColumnIndex < columnCount && (columnGroupRight - columnGroupLeft < visibleWidth || columnGroupRight < maxX)) {
|
|
9047
|
-
var _modelColumns$get2,
|
|
9010
|
+
var _modelColumns$get2, _ref5, _userColumnWidths$get2;
|
|
9048
9011
|
var nextModelIndex = (_modelColumns$get2 = modelColumns.get(nextColumnIndex)) !== null && _modelColumns$get2 !== void 0 ? _modelColumns$get2 : GridUtils.getModelIndex(nextColumnIndex, movedColumns);
|
|
9049
9012
|
if (model.textForColumnHeader(nextModelIndex, depth) !== columnGroupName) {
|
|
9050
9013
|
break;
|
|
9051
9014
|
}
|
|
9052
|
-
var nextColumnWidth = (
|
|
9015
|
+
var nextColumnWidth = (_ref5 = (_userColumnWidths$get2 = userColumnWidths.get(nextModelIndex)) !== null && _userColumnWidths$get2 !== void 0 ? _userColumnWidths$get2 : allColumnWidths.get(nextColumnIndex)) !== null && _ref5 !== void 0 ? _ref5 : columnWidth;
|
|
9053
9016
|
columnGroupRight += nextColumnWidth;
|
|
9054
9017
|
nextColumnIndex += 1;
|
|
9055
9018
|
}
|
|
@@ -9920,10 +9883,10 @@ _defineProperty(GridRenderer, "getCachedColorWithAlpha", memoizeClear$1(GridColo
|
|
|
9920
9883
|
_defineProperty(GridRenderer, "getCachedColorIsDark", memoizeClear$1(ColorUtils$1.isDark, {
|
|
9921
9884
|
max: 1e3
|
|
9922
9885
|
}));
|
|
9923
|
-
function
|
|
9924
|
-
return group instanceof
|
|
9886
|
+
function isPivotColumnHeaderGroup(group) {
|
|
9887
|
+
return group instanceof PivotColumnHeaderGroup;
|
|
9925
9888
|
}
|
|
9926
|
-
class
|
|
9889
|
+
class PivotColumnHeaderGroup extends irisGrid.ColumnHeaderGroup {
|
|
9927
9890
|
constructor({
|
|
9928
9891
|
name,
|
|
9929
9892
|
displayName,
|
|
@@ -9960,6 +9923,16 @@ class ExpandableColumnHeaderGroup extends irisGrid.ColumnHeaderGroup {
|
|
|
9960
9923
|
function isCorePlusDh(dh) {
|
|
9961
9924
|
return "coreplus" in dh;
|
|
9962
9925
|
}
|
|
9926
|
+
function getKeyColumnGroups(model) {
|
|
9927
|
+
const keyColumnGroups = [];
|
|
9928
|
+
for (let depth = 0; depth <= model.columnHeaderMaxDepth; depth += 1) {
|
|
9929
|
+
const group = model.getColumnHeaderGroup(0, depth);
|
|
9930
|
+
if (isPivotColumnHeaderGroup(group) && group.isKeyColumnGroup) {
|
|
9931
|
+
keyColumnGroups.push(group);
|
|
9932
|
+
}
|
|
9933
|
+
}
|
|
9934
|
+
return keyColumnGroups;
|
|
9935
|
+
}
|
|
9963
9936
|
const GRAND_TOTALS_GROUP_NAME = "Grand Total";
|
|
9964
9937
|
const TOTALS_GROUP_NAME = "Total";
|
|
9965
9938
|
const ROOT_DEPTH = 2;
|
|
@@ -9975,29 +9948,34 @@ function makeColumn({
|
|
|
9975
9948
|
type,
|
|
9976
9949
|
index,
|
|
9977
9950
|
description,
|
|
9951
|
+
isFilterable = false,
|
|
9978
9952
|
isSortable = false,
|
|
9979
9953
|
depth = ROOT_DEPTH,
|
|
9980
9954
|
hasChildren = false,
|
|
9981
|
-
isExpanded = false
|
|
9955
|
+
isExpanded = false,
|
|
9956
|
+
isProxy = false,
|
|
9957
|
+
filter = () => {
|
|
9958
|
+
throw new Error("Filter not implemented for virtual column");
|
|
9959
|
+
},
|
|
9960
|
+
sort = () => {
|
|
9961
|
+
throw new Error("Sort not implemented for virtual column");
|
|
9962
|
+
}
|
|
9982
9963
|
}) {
|
|
9983
9964
|
return {
|
|
9984
9965
|
name,
|
|
9985
9966
|
displayName,
|
|
9986
9967
|
type,
|
|
9987
9968
|
isPartitionColumn: false,
|
|
9969
|
+
isFilterable,
|
|
9988
9970
|
isSortable,
|
|
9989
|
-
isProxy
|
|
9971
|
+
isProxy,
|
|
9990
9972
|
description,
|
|
9991
9973
|
index,
|
|
9992
9974
|
depth,
|
|
9993
9975
|
hasChildren,
|
|
9994
9976
|
isExpanded,
|
|
9995
|
-
filter
|
|
9996
|
-
|
|
9997
|
-
},
|
|
9998
|
-
sort: () => {
|
|
9999
|
-
throw new Error("Sort not implemented for virtual column");
|
|
10000
|
-
},
|
|
9977
|
+
filter,
|
|
9978
|
+
sort,
|
|
10001
9979
|
formatColor: () => {
|
|
10002
9980
|
throw new Error("Color not implemented for virtual column");
|
|
10003
9981
|
},
|
|
@@ -10022,15 +10000,15 @@ function makeGrandTotalColumnName(valueSource) {
|
|
|
10022
10000
|
return `__GRAND_TOTAL/${valueSource.name}`;
|
|
10023
10001
|
}
|
|
10024
10002
|
function makeColumnName(keys2, depth) {
|
|
10025
|
-
return keys2.slice(0, depth + 1).filter((k) => k != null).join("/");
|
|
10003
|
+
return keys2.slice(0, depth + 1).filter((k) => k != null).map((k) => encodeURIComponent(String(k))).join("/");
|
|
10026
10004
|
}
|
|
10027
10005
|
function makeColumnGroupName(keys2, columnSources, depth) {
|
|
10028
|
-
return keys2.slice(0, depth + 1).map((k, i) => k == null ? columnSources[i].name : k).join("/");
|
|
10006
|
+
return keys2.slice(0, depth + 1).map((k, i) => k == null ? columnSources[i].name : k).map((k) => encodeURIComponent(String(k))).join("/");
|
|
10029
10007
|
}
|
|
10030
10008
|
function makeValueSourceColumnName(columnName, valueSource) {
|
|
10031
10009
|
return `${columnName}/${valueSource.name}`;
|
|
10032
10010
|
}
|
|
10033
|
-
function
|
|
10011
|
+
function makeColumnFromSnapshot(snapshotDim, valueSource, originalIndex, offset) {
|
|
10034
10012
|
const keys2 = snapshotDim.getKeys(originalIndex);
|
|
10035
10013
|
const depth = snapshotDim.getDepth(originalIndex);
|
|
10036
10014
|
const hasChildren = snapshotDim.hasChildren(originalIndex);
|
|
@@ -10052,7 +10030,7 @@ function makeExpandableDisplayColumn(snapshotDim, valueSource, originalIndex, of
|
|
|
10052
10030
|
hasChildren
|
|
10053
10031
|
});
|
|
10054
10032
|
}
|
|
10055
|
-
function
|
|
10033
|
+
function makePlaceholderColumn(valueSource, originalIndex, offset) {
|
|
10056
10034
|
return makeColumn({
|
|
10057
10035
|
name: makePlaceholderColumnName(originalIndex, valueSource),
|
|
10058
10036
|
displayName: "",
|
|
@@ -10063,31 +10041,42 @@ function makePlaceholderDisplayColumn(valueSource, originalIndex, offset) {
|
|
|
10063
10041
|
hasChildren: false
|
|
10064
10042
|
});
|
|
10065
10043
|
}
|
|
10066
|
-
function
|
|
10044
|
+
function makeColumnFromSource(source, index) {
|
|
10067
10045
|
const { name, type, isSortable, description } = source;
|
|
10068
|
-
|
|
10046
|
+
const isFilterable = true;
|
|
10047
|
+
return makeColumn({
|
|
10048
|
+
name,
|
|
10049
|
+
type,
|
|
10050
|
+
index,
|
|
10051
|
+
isFilterable,
|
|
10052
|
+
isSortable,
|
|
10053
|
+
description,
|
|
10054
|
+
filter: source.filter.bind(source),
|
|
10055
|
+
sort: source.sort.bind(source)
|
|
10056
|
+
});
|
|
10069
10057
|
}
|
|
10070
10058
|
function checkColumnsChanged(prevColumns, newColumns) {
|
|
10071
10059
|
return prevColumns.length !== newColumns.length || prevColumns.some((col, i) => col.name !== newColumns[i].name);
|
|
10072
10060
|
}
|
|
10073
|
-
function
|
|
10061
|
+
function makeKeyColumnGroups(columnSources, rowSources, includeGroupColumn) {
|
|
10062
|
+
const groupName = includeGroupColumn ? ["__GROUP__"] : [];
|
|
10074
10063
|
const groups = columnSources.length === 0 ? [
|
|
10075
|
-
new
|
|
10076
|
-
|
|
10077
|
-
name: "__All",
|
|
10064
|
+
new PivotColumnHeaderGroup({
|
|
10065
|
+
name: "/",
|
|
10078
10066
|
displayName: "",
|
|
10079
|
-
//
|
|
10080
|
-
|
|
10067
|
+
// For empty row sources we will render a "dead column"
|
|
10068
|
+
// or a Groups column, depending on the table settings
|
|
10069
|
+
children: [...groupName, ...rowSources.map((c) => c.name)],
|
|
10081
10070
|
childIndexes: [],
|
|
10082
10071
|
isKeyColumnGroup: true,
|
|
10083
10072
|
depth: 1,
|
|
10084
10073
|
isExpandable: false
|
|
10085
10074
|
})
|
|
10086
10075
|
] : columnSources.map(
|
|
10087
|
-
(source, i) => new
|
|
10076
|
+
(source, i) => new PivotColumnHeaderGroup({
|
|
10088
10077
|
name: source.name,
|
|
10089
10078
|
displayName: source.name,
|
|
10090
|
-
children: i === columnSources.length - 1 ? rowSources.map((c) => c.name) : [columnSources[i + 1].name],
|
|
10079
|
+
children: i === columnSources.length - 1 ? [...groupName, ...rowSources.map((c) => c.name)] : [columnSources[i + 1].name],
|
|
10091
10080
|
childIndexes: [],
|
|
10092
10081
|
isKeyColumnGroup: true,
|
|
10093
10082
|
depth: columnSources.length - i,
|
|
@@ -10099,23 +10088,18 @@ function getKeyColumnGroups(columnSources, rowSources) {
|
|
|
10099
10088
|
[]
|
|
10100
10089
|
) : groups;
|
|
10101
10090
|
}
|
|
10102
|
-
function
|
|
10091
|
+
function makeTotalsColumnGroups(columnSources, valueSources, isRootColumnExpanded) {
|
|
10103
10092
|
const groupName = pluralize(valueSources.length, GRAND_TOTALS_GROUP_NAME);
|
|
10104
10093
|
return columnSources.length === 0 ? [
|
|
10105
|
-
new
|
|
10106
|
-
|
|
10107
|
-
name: "TMP__GrandTotals",
|
|
10094
|
+
new PivotColumnHeaderGroup({
|
|
10095
|
+
name: "/GrandTotals",
|
|
10108
10096
|
displayName: groupName,
|
|
10109
10097
|
children: valueSources.map((v) => makeGrandTotalColumnName(v)),
|
|
10110
10098
|
childIndexes: [],
|
|
10111
10099
|
depth: 1
|
|
10112
|
-
// Only the top level is expandable
|
|
10113
|
-
// TODO:
|
|
10114
|
-
// isExpandable: i === 0,
|
|
10115
|
-
// isExpanded: isRootColumnExpanded,
|
|
10116
10100
|
})
|
|
10117
10101
|
] : columnSources.map(
|
|
10118
|
-
(source, i) => new
|
|
10102
|
+
(source, i) => new PivotColumnHeaderGroup({
|
|
10119
10103
|
name: makeGrandTotalColumnName(source),
|
|
10120
10104
|
displayName: i === 0 ? groupName : "",
|
|
10121
10105
|
children: i === columnSources.length - 1 ? valueSources.map((v) => makeGrandTotalColumnName(v)) : [makeGrandTotalColumnName(columnSources[i + 1])],
|
|
@@ -10128,7 +10112,7 @@ function getTotalsColumnGroups(columnSources, valueSources, isRootColumnExpanded
|
|
|
10128
10112
|
})
|
|
10129
10113
|
);
|
|
10130
10114
|
}
|
|
10131
|
-
function
|
|
10115
|
+
function makeSnapshotColumnGroups(snapshotColumns, columnSources, valueSources, formatValue) {
|
|
10132
10116
|
const maxDepth = Math.max(columnSources.length, 1);
|
|
10133
10117
|
const groupMap = /* @__PURE__ */ new Map();
|
|
10134
10118
|
const groupName = pluralize(valueSources.length, TOTALS_GROUP_NAME);
|
|
@@ -10141,7 +10125,7 @@ function getSnapshotColumnGroups(snapshotColumns, columnSources, valueSources, f
|
|
|
10141
10125
|
const isTotalGroup = keys2[i] == null;
|
|
10142
10126
|
const parentKey = i > 0 ? keys2[i - 1] : null;
|
|
10143
10127
|
const totalsGroupDisplayName = parentKey == null ? "" : groupName;
|
|
10144
|
-
const group = groupMap.get(name) ?? new
|
|
10128
|
+
const group = groupMap.get(name) ?? new PivotColumnHeaderGroup({
|
|
10145
10129
|
name,
|
|
10146
10130
|
displayName: isTotalGroup ? totalsGroupDisplayName : keys2[i],
|
|
10147
10131
|
isTotalGroup,
|
|
@@ -10168,27 +10152,44 @@ function getSnapshotColumnGroups(snapshotColumns, columnSources, valueSources, f
|
|
|
10168
10152
|
}
|
|
10169
10153
|
return [...groupMap.values()];
|
|
10170
10154
|
}
|
|
10171
|
-
function
|
|
10155
|
+
function makeColumnGroups(pivotTable, snapshotColumns, isRootColumnExpanded = true, includeGroupColumn = false, formatValue = (v, t) => String(v)) {
|
|
10172
10156
|
const virtualColumnGroups = [
|
|
10173
|
-
...
|
|
10174
|
-
|
|
10157
|
+
...makeKeyColumnGroups(
|
|
10158
|
+
pivotTable.columnSources,
|
|
10159
|
+
pivotTable.rowSources,
|
|
10160
|
+
includeGroupColumn
|
|
10161
|
+
),
|
|
10162
|
+
...makeTotalsColumnGroups(
|
|
10175
10163
|
pivotTable.columnSources,
|
|
10176
10164
|
pivotTable.valueSources,
|
|
10177
10165
|
isRootColumnExpanded
|
|
10178
10166
|
)
|
|
10179
10167
|
];
|
|
10180
|
-
const snapshotColumnGroups = snapshotColumns == null ? [] :
|
|
10168
|
+
const snapshotColumnGroups = snapshotColumns == null ? [] : makeSnapshotColumnGroups(
|
|
10181
10169
|
snapshotColumns,
|
|
10182
10170
|
pivotTable.columnSources,
|
|
10183
10171
|
pivotTable.valueSources
|
|
10184
10172
|
);
|
|
10185
10173
|
return [...virtualColumnGroups, ...snapshotColumnGroups];
|
|
10186
10174
|
}
|
|
10187
|
-
const log$
|
|
10175
|
+
const log$4 = Log.module("@deephaven/js-plugin-pivot/IrisGridPivotModel");
|
|
10188
10176
|
const SET_VIEWPORT_THROTTLE = 150;
|
|
10189
10177
|
const APPLY_VIEWPORT_THROTTLE = 0;
|
|
10190
10178
|
const ROW_BUFFER_PAGES = 1;
|
|
10191
10179
|
const COLUMN_BUFFER_PAGES = 1;
|
|
10180
|
+
const VirtualGroupColumn = Object.freeze(
|
|
10181
|
+
makeColumn({
|
|
10182
|
+
name: "__GROUP__",
|
|
10183
|
+
displayName: "Group",
|
|
10184
|
+
type: "java.lang.String",
|
|
10185
|
+
index: 0,
|
|
10186
|
+
depth: 2,
|
|
10187
|
+
isProxy: true
|
|
10188
|
+
})
|
|
10189
|
+
);
|
|
10190
|
+
function isIrisGridPivotModel(model) {
|
|
10191
|
+
return typeof model === "object" && model !== null && "pivotTable" in model && "keyColumns" in model && "expandAll" in model && "collapseAll" in model && "hasExpandableRows" in model && "hasExpandableColumns" in model;
|
|
10192
|
+
}
|
|
10192
10193
|
class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
10193
10194
|
constructor(dh, pivotTable, formatter = new jsapiUtils.Formatter(dh), config = {}) {
|
|
10194
10195
|
if (!isCorePlusDh(dh)) {
|
|
@@ -10196,13 +10197,9 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10196
10197
|
}
|
|
10197
10198
|
super(dh);
|
|
10198
10199
|
__publicField(this, "pivotTable");
|
|
10199
|
-
__publicField(this, "
|
|
10200
|
+
__publicField(this, "showExtraGroupCol", true);
|
|
10200
10201
|
__publicField(this, "_layoutHints");
|
|
10201
|
-
__publicField(this, "
|
|
10202
|
-
__publicField(this, "columnHeaderParentMap", /* @__PURE__ */ new Map());
|
|
10203
|
-
__publicField(this, "_columnHeaderMaxDepth", null);
|
|
10204
|
-
__publicField(this, "_columnHeaderGroups", []);
|
|
10205
|
-
__publicField(this, "_isColumnHeaderGroupsInitialized", false);
|
|
10202
|
+
__publicField(this, "_sorts", EMPTY_ARRAY);
|
|
10206
10203
|
__publicField(this, "viewportData", null);
|
|
10207
10204
|
__publicField(this, "formattedStringData", []);
|
|
10208
10205
|
__publicField(this, "snapshotColumns", null);
|
|
@@ -10219,73 +10216,80 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10219
10216
|
__publicField(this, "dh");
|
|
10220
10217
|
__publicField(this, "getCachedColumns", memoizeOne(
|
|
10221
10218
|
(snapshotColumns, virtualColumns, valueSources) => {
|
|
10219
|
+
const columns = [];
|
|
10220
|
+
this.pivotTable.columnSources.forEach((source, col) => {
|
|
10221
|
+
const index = -this.pivotTable.columnSources.length + col;
|
|
10222
|
+
columns[index] = makeColumnFromSource(source, index);
|
|
10223
|
+
});
|
|
10224
|
+
columns.push(...virtualColumns);
|
|
10222
10225
|
if (snapshotColumns == null) {
|
|
10223
|
-
|
|
10224
|
-
snapshotColumns,
|
|
10225
|
-
valueSources
|
|
10226
|
-
});
|
|
10227
|
-
return virtualColumns;
|
|
10226
|
+
return columns;
|
|
10228
10227
|
}
|
|
10229
|
-
const columns = [...virtualColumns];
|
|
10230
10228
|
for (let i = 0; i < snapshotColumns.totalCount; i += 1) {
|
|
10231
10229
|
const isColumnInViewport = i >= snapshotColumns.offset && i < snapshotColumns.offset + snapshotColumns.count;
|
|
10232
10230
|
for (let v = 0; v < valueSources.length; v += 1) {
|
|
10233
10231
|
columns.push(
|
|
10234
|
-
isColumnInViewport ?
|
|
10232
|
+
isColumnInViewport ? makeColumnFromSnapshot(
|
|
10235
10233
|
snapshotColumns,
|
|
10236
10234
|
valueSources[v],
|
|
10237
10235
|
i,
|
|
10238
10236
|
virtualColumns.length
|
|
10239
|
-
) :
|
|
10240
|
-
valueSources[v],
|
|
10241
|
-
i,
|
|
10242
|
-
virtualColumns.length
|
|
10243
|
-
)
|
|
10237
|
+
) : makePlaceholderColumn(valueSources[v], i, virtualColumns.length)
|
|
10244
10238
|
);
|
|
10245
10239
|
}
|
|
10246
10240
|
}
|
|
10247
|
-
log$3.debug2("getCachedColumns", {
|
|
10248
|
-
snapshotColumns,
|
|
10249
|
-
valueSources,
|
|
10250
|
-
columns: columns.map(({ name }) => name)
|
|
10251
|
-
});
|
|
10252
10241
|
return columns;
|
|
10253
10242
|
}
|
|
10254
10243
|
));
|
|
10255
10244
|
__publicField(this, "getCachedTotalsColumns", memoizeOne(
|
|
10256
|
-
(pivotTable, valueSources) => valueSources.map(
|
|
10245
|
+
(pivotTable, valueSources, groupColumn) => valueSources.map(
|
|
10257
10246
|
(source, col) => makeColumn({
|
|
10258
10247
|
name: makeGrandTotalColumnName(source),
|
|
10259
10248
|
displayName: source.name,
|
|
10260
10249
|
description: source.description,
|
|
10261
10250
|
type: source.type,
|
|
10262
|
-
index: pivotTable.rowSources.length + col,
|
|
10251
|
+
index: pivotTable.rowSources.length + col + (groupColumn == null ? 0 : 1),
|
|
10263
10252
|
depth: 2,
|
|
10264
10253
|
isExpanded: true,
|
|
10265
10254
|
hasChildren: true
|
|
10266
10255
|
})
|
|
10267
10256
|
)
|
|
10268
10257
|
));
|
|
10258
|
+
__publicField(this, "getCachedKeyColumns", memoizeOne(
|
|
10259
|
+
(pivotTable, groupColumn) => pivotTable.rowSources.map(
|
|
10260
|
+
(source, index) => makeColumnFromSource(source, index + (groupColumn == null ? 0 : 1))
|
|
10261
|
+
)
|
|
10262
|
+
));
|
|
10269
10263
|
__publicField(this, "getCachedVirtualColumns", memoizeOne(
|
|
10270
|
-
(keyColumns, totalsColumns) => [...keyColumns, ...totalsColumns]
|
|
10264
|
+
(groupColumn, keyColumns, totalsColumns) => groupColumn ? [groupColumn, ...keyColumns, ...totalsColumns] : [...keyColumns, ...totalsColumns]
|
|
10271
10265
|
));
|
|
10272
10266
|
/**
|
|
10273
|
-
* Get the cached
|
|
10267
|
+
* Get the cached header groups data, including groups array, max depth, parent map, and group map.
|
|
10274
10268
|
* Returns groups for the key columns, totals, and the snapshot column in the current viewport.
|
|
10275
10269
|
* Placeholder columns are not included in the groups.
|
|
10276
10270
|
*/
|
|
10277
|
-
__publicField(this, "
|
|
10278
|
-
(snapshotColumns,
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10271
|
+
__publicField(this, "getCachedParsedColumnHeaderData", memoizeOne(
|
|
10272
|
+
(snapshotColumns, groupColumn, formatter, isRootColumnExpanded) => {
|
|
10273
|
+
const columnGroups = makeColumnGroups(
|
|
10274
|
+
this.pivotTable,
|
|
10275
|
+
snapshotColumns,
|
|
10276
|
+
isRootColumnExpanded,
|
|
10277
|
+
groupColumn != null,
|
|
10278
|
+
(value2, type) => this.getCachedFormattedString(formatter, value2, type, "")
|
|
10279
|
+
);
|
|
10280
|
+
return irisGrid.IrisGridUtils.parseColumnHeaderGroups(
|
|
10281
|
+
this,
|
|
10282
|
+
columnGroups,
|
|
10283
|
+
(args) => new PivotColumnHeaderGroup(args)
|
|
10284
|
+
);
|
|
10285
|
+
}
|
|
10284
10286
|
));
|
|
10285
10287
|
__publicField(this, "getColumnIndicesByNameMap", memoizeOne(
|
|
10286
10288
|
(columns) => {
|
|
10287
10289
|
const indices = /* @__PURE__ */ new Map();
|
|
10288
|
-
|
|
10290
|
+
Object.entries(columns).forEach(
|
|
10291
|
+
([i, { name }]) => indices.set(name, Number(i))
|
|
10292
|
+
);
|
|
10289
10293
|
return indices;
|
|
10290
10294
|
}
|
|
10291
10295
|
));
|
|
@@ -10318,7 +10322,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10318
10322
|
return this.dh.RangeSet.ofRange(0, totalColumnCount);
|
|
10319
10323
|
}
|
|
10320
10324
|
if (viewportColumns.length === 0) {
|
|
10321
|
-
log$
|
|
10325
|
+
log$4.debug(
|
|
10322
10326
|
"Empty viewport columns, returning minimal range",
|
|
10323
10327
|
viewportColumns
|
|
10324
10328
|
);
|
|
@@ -10341,7 +10345,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10341
10345
|
) ?? 0
|
|
10342
10346
|
);
|
|
10343
10347
|
if (minIndex > maxIndex) {
|
|
10344
|
-
log$
|
|
10348
|
+
log$4.warn(
|
|
10345
10349
|
"Invalid column range, minIndex > maxIndex",
|
|
10346
10350
|
viewportColumns,
|
|
10347
10351
|
minIndex,
|
|
@@ -10361,12 +10365,12 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10361
10365
|
__publicField(this, "setViewport", lodash_throttle(
|
|
10362
10366
|
(top, bottom, columns) => {
|
|
10363
10367
|
if (bottom < top) {
|
|
10364
|
-
log$
|
|
10368
|
+
log$4.error("Invalid viewport", top, bottom);
|
|
10365
10369
|
return;
|
|
10366
10370
|
}
|
|
10367
10371
|
const { viewport } = this;
|
|
10368
10372
|
if (viewport != null && viewport.top === top && viewport.bottom === bottom && viewport.columns === columns) {
|
|
10369
|
-
log$
|
|
10373
|
+
log$4.debug2("Ignoring duplicate viewport", viewport);
|
|
10370
10374
|
return;
|
|
10371
10375
|
}
|
|
10372
10376
|
this.viewport = {
|
|
@@ -10374,7 +10378,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10374
10378
|
bottom,
|
|
10375
10379
|
columns
|
|
10376
10380
|
};
|
|
10377
|
-
log$
|
|
10381
|
+
log$4.debug2("setViewport", this.viewport);
|
|
10378
10382
|
this.applyViewport();
|
|
10379
10383
|
},
|
|
10380
10384
|
SET_VIEWPORT_THROTTLE
|
|
@@ -10395,7 +10399,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10395
10399
|
if (!this.viewport) {
|
|
10396
10400
|
return;
|
|
10397
10401
|
}
|
|
10398
|
-
log$
|
|
10402
|
+
log$4.debug2("applyViewport", this.viewport);
|
|
10399
10403
|
const { top, bottom, columns } = this.viewport;
|
|
10400
10404
|
const [viewportTop, viewportBottom] = this.getCachedViewportRowRange(
|
|
10401
10405
|
top,
|
|
@@ -10417,9 +10421,6 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10417
10421
|
this.snapshotValueSources = pivotTable.valueSources;
|
|
10418
10422
|
this.rowBufferPages = config.rowBufferPages ?? ROW_BUFFER_PAGES;
|
|
10419
10423
|
this.columnBufferPages = config.columnBufferPages ?? COLUMN_BUFFER_PAGES;
|
|
10420
|
-
this.keyColumns = pivotTable.rowSources.map(
|
|
10421
|
-
(source, col) => makeRowSourceColumn(source, col)
|
|
10422
|
-
);
|
|
10423
10424
|
this._layoutHints = {
|
|
10424
10425
|
backColumns: [],
|
|
10425
10426
|
hiddenColumns: [],
|
|
@@ -10432,14 +10433,45 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10432
10433
|
};
|
|
10433
10434
|
}
|
|
10434
10435
|
get filter() {
|
|
10435
|
-
return
|
|
10436
|
+
return this.pivotTable.filter;
|
|
10436
10437
|
}
|
|
10437
|
-
set filter(
|
|
10438
|
+
set filter(filters) {
|
|
10439
|
+
log$4.debug2("Setting filter on pivot table", filters);
|
|
10440
|
+
this.pivotTable.applyFilter(filters);
|
|
10441
|
+
this.applyViewport();
|
|
10438
10442
|
}
|
|
10439
|
-
|
|
10440
|
-
|
|
10443
|
+
hydratePivotSort(sort) {
|
|
10444
|
+
const sourceIndex = this.getColumnIndexByName(sort.column.name);
|
|
10445
|
+
const source = this.columns[sourceIndex ?? -1];
|
|
10446
|
+
return (source == null ? void 0 : source.sort()[sort.direction === "ASC" ? "asc" : "desc"]()) ?? null;
|
|
10441
10447
|
}
|
|
10442
|
-
|
|
10448
|
+
get sort() {
|
|
10449
|
+
return this._sorts ?? EMPTY_ARRAY;
|
|
10450
|
+
}
|
|
10451
|
+
set sort(sorts) {
|
|
10452
|
+
log$4.debug("Setting sorts on pivot table", sorts);
|
|
10453
|
+
this._sorts = sorts;
|
|
10454
|
+
const columnBySorts = [];
|
|
10455
|
+
const rowBySorts = [];
|
|
10456
|
+
sorts.forEach((s) => {
|
|
10457
|
+
const sort = this.hydratePivotSort(s);
|
|
10458
|
+
if (sort == null) {
|
|
10459
|
+
log$4.warn(`Cannot hydrate sort for source: ${s.column.name}`, s);
|
|
10460
|
+
return;
|
|
10461
|
+
}
|
|
10462
|
+
const index = this.getColumnIndexByName(sort.name);
|
|
10463
|
+
if (index == null) {
|
|
10464
|
+
log$4.warn(`Cannot find index for source: ${s.column.name}`, s);
|
|
10465
|
+
return;
|
|
10466
|
+
}
|
|
10467
|
+
if (index < 0) {
|
|
10468
|
+
columnBySorts.push(sort);
|
|
10469
|
+
} else {
|
|
10470
|
+
rowBySorts.push(sort);
|
|
10471
|
+
}
|
|
10472
|
+
});
|
|
10473
|
+
this.pivotTable.applyRowSort(rowBySorts);
|
|
10474
|
+
this.pivotTable.applyColumnSort(columnBySorts);
|
|
10443
10475
|
}
|
|
10444
10476
|
get customColumns() {
|
|
10445
10477
|
return EMPTY_ARRAY;
|
|
@@ -10484,99 +10516,79 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10484
10516
|
async export() {
|
|
10485
10517
|
throw new Error("Method not implemented.");
|
|
10486
10518
|
}
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
}
|
|
10490
|
-
async quickFilter() {
|
|
10491
|
-
throw new Error("Method not implemented.");
|
|
10492
|
-
}
|
|
10493
|
-
async autoResizeColumns() {
|
|
10494
|
-
throw new Error("Method not implemented.");
|
|
10495
|
-
}
|
|
10496
|
-
async applySort() {
|
|
10497
|
-
throw new Error("Method not implemented.");
|
|
10519
|
+
get showExtraGroupColumn() {
|
|
10520
|
+
return this.showExtraGroupCol;
|
|
10498
10521
|
}
|
|
10499
|
-
|
|
10500
|
-
|
|
10522
|
+
set showExtraGroupColumn(showExtraGroupCol) {
|
|
10523
|
+
if (showExtraGroupCol === this.showExtraGroupCol) {
|
|
10524
|
+
return;
|
|
10525
|
+
}
|
|
10526
|
+
this.showExtraGroupCol = showExtraGroupCol;
|
|
10527
|
+
this.dispatchEvent(
|
|
10528
|
+
new EventShimCustomEvent(irisGrid.IrisGridModel.EVENT.COLUMNS_CHANGED, {
|
|
10529
|
+
detail: this.columns
|
|
10530
|
+
})
|
|
10531
|
+
);
|
|
10501
10532
|
}
|
|
10502
|
-
|
|
10503
|
-
|
|
10533
|
+
get groupColumn() {
|
|
10534
|
+
return this.pivotTable.rowSources.length !== 1 && this.showExtraGroupCol ? VirtualGroupColumn : null;
|
|
10504
10535
|
}
|
|
10505
|
-
|
|
10506
|
-
|
|
10536
|
+
get keyColumns() {
|
|
10537
|
+
return this.getCachedKeyColumns(this.pivotTable, this.groupColumn);
|
|
10507
10538
|
}
|
|
10508
10539
|
get totalsColumns() {
|
|
10509
10540
|
return this.getCachedTotalsColumns(
|
|
10510
10541
|
this.pivotTable,
|
|
10511
|
-
this.snapshotValueSources
|
|
10542
|
+
this.snapshotValueSources,
|
|
10543
|
+
this.groupColumn
|
|
10512
10544
|
);
|
|
10513
10545
|
}
|
|
10514
10546
|
get virtualColumns() {
|
|
10515
|
-
return this.getCachedVirtualColumns(
|
|
10547
|
+
return this.getCachedVirtualColumns(
|
|
10548
|
+
this.groupColumn,
|
|
10549
|
+
this.keyColumns,
|
|
10550
|
+
this.totalsColumns
|
|
10551
|
+
);
|
|
10516
10552
|
}
|
|
10517
|
-
|
|
10518
|
-
|
|
10553
|
+
getParsedColumnHeaderData() {
|
|
10554
|
+
return this.getCachedParsedColumnHeaderData(
|
|
10519
10555
|
this.snapshotColumns,
|
|
10520
|
-
this.
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
this.getCachedFormattedString(this.formatter, value2, type, "")
|
|
10524
|
-
)
|
|
10556
|
+
this.groupColumn,
|
|
10557
|
+
this.formatter,
|
|
10558
|
+
this.isRootColumnExpanded
|
|
10525
10559
|
);
|
|
10526
|
-
|
|
10527
|
-
|
|
10560
|
+
}
|
|
10561
|
+
get initialColumnHeaderGroups() {
|
|
10562
|
+
return this.columnHeaderGroups;
|
|
10528
10563
|
}
|
|
10529
10564
|
get columnHeaderMaxDepth() {
|
|
10530
|
-
|
|
10565
|
+
const { maxDepth } = this.getParsedColumnHeaderData();
|
|
10566
|
+
return maxDepth;
|
|
10531
10567
|
}
|
|
10532
|
-
|
|
10533
|
-
|
|
10568
|
+
get columnHeaderParentMap() {
|
|
10569
|
+
const { parentMap } = this.getParsedColumnHeaderData();
|
|
10570
|
+
return parentMap;
|
|
10534
10571
|
}
|
|
10535
10572
|
get columnHeaderGroupMap() {
|
|
10536
|
-
this.
|
|
10537
|
-
return
|
|
10573
|
+
const { groupMap } = this.getParsedColumnHeaderData();
|
|
10574
|
+
return groupMap;
|
|
10538
10575
|
}
|
|
10539
10576
|
get columnHeaderGroups() {
|
|
10540
|
-
this.
|
|
10541
|
-
return
|
|
10577
|
+
const { groups } = this.getParsedColumnHeaderData();
|
|
10578
|
+
return groups;
|
|
10542
10579
|
}
|
|
10543
10580
|
set columnHeaderGroups(_groups) {
|
|
10544
10581
|
}
|
|
10545
|
-
setInternalColumnHeaderGroups(groups) {
|
|
10546
|
-
if (groups === this._columnHeaderGroups) {
|
|
10547
|
-
return;
|
|
10548
|
-
}
|
|
10549
|
-
const {
|
|
10550
|
-
groups: newGroups,
|
|
10551
|
-
maxDepth,
|
|
10552
|
-
parentMap,
|
|
10553
|
-
groupMap
|
|
10554
|
-
} = irisGrid.IrisGridUtils.parseColumnHeaderGroups(
|
|
10555
|
-
this,
|
|
10556
|
-
groups,
|
|
10557
|
-
(args) => new ExpandableColumnHeaderGroup(args)
|
|
10558
|
-
);
|
|
10559
|
-
this._columnHeaderGroups = newGroups;
|
|
10560
|
-
this.columnHeaderMaxDepth = maxDepth;
|
|
10561
|
-
this.columnHeaderParentMap = parentMap;
|
|
10562
|
-
this._columnHeaderGroupMap = groupMap;
|
|
10563
|
-
this._isColumnHeaderGroupsInitialized = true;
|
|
10564
|
-
}
|
|
10565
|
-
initializeColumnHeaderGroups() {
|
|
10566
|
-
if (!this._isColumnHeaderGroupsInitialized) {
|
|
10567
|
-
this.setInternalColumnHeaderGroups(this.initialColumnHeaderGroups);
|
|
10568
|
-
}
|
|
10569
|
-
}
|
|
10570
10582
|
textForColumnHeader(x, depth = 0) {
|
|
10571
10583
|
const header = this.columnAtDepth(x, depth);
|
|
10572
|
-
if (
|
|
10584
|
+
if (isPivotColumnHeaderGroup(header)) {
|
|
10573
10585
|
return header.isNew ? "" : header.displayName ?? header.name;
|
|
10574
10586
|
}
|
|
10575
10587
|
return (header == null ? void 0 : header.displayName) ?? (header == null ? void 0 : header.name);
|
|
10576
10588
|
}
|
|
10577
10589
|
colorForColumnHeader(x, depth = 0, theme = {}) {
|
|
10578
10590
|
const column = this.columnAtDepth(x, depth);
|
|
10579
|
-
if (
|
|
10591
|
+
if (isPivotColumnHeaderGroup(column)) {
|
|
10580
10592
|
if (column.isTotalGroup != null && column.isTotalGroup) {
|
|
10581
10593
|
return theme.totalsHeaderBackground ?? null;
|
|
10582
10594
|
}
|
|
@@ -10588,7 +10600,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10588
10600
|
}
|
|
10589
10601
|
getColumnHeaderGroup(modelIndex, depth) {
|
|
10590
10602
|
const group = this.columnAtDepth(modelIndex, depth);
|
|
10591
|
-
if (
|
|
10603
|
+
if (isPivotColumnHeaderGroup(group)) {
|
|
10592
10604
|
return group;
|
|
10593
10605
|
}
|
|
10594
10606
|
return void 0;
|
|
@@ -10625,6 +10637,10 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10625
10637
|
get initialMovedColumns() {
|
|
10626
10638
|
return EMPTY_ARRAY;
|
|
10627
10639
|
}
|
|
10640
|
+
/**
|
|
10641
|
+
* Get the columns in the pivot model.
|
|
10642
|
+
* Returned array includes column sources with negative indexes.
|
|
10643
|
+
*/
|
|
10628
10644
|
get columns() {
|
|
10629
10645
|
return this.getCachedColumns(
|
|
10630
10646
|
this.snapshotColumns,
|
|
@@ -10651,10 +10667,12 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10651
10667
|
return false;
|
|
10652
10668
|
}
|
|
10653
10669
|
isFilterable(columnIndex) {
|
|
10654
|
-
|
|
10670
|
+
var _a;
|
|
10671
|
+
return ((_a = this.columns[columnIndex]) == null ? void 0 : _a.isFilterable) ?? false;
|
|
10655
10672
|
}
|
|
10656
10673
|
isColumnSortable(columnIndex) {
|
|
10657
|
-
|
|
10674
|
+
var _a;
|
|
10675
|
+
return ((_a = this.columns[columnIndex]) == null ? void 0 : _a.isSortable) ?? false;
|
|
10658
10676
|
}
|
|
10659
10677
|
get isTotalsAvailable() {
|
|
10660
10678
|
return false;
|
|
@@ -10706,7 +10724,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10706
10724
|
}
|
|
10707
10725
|
}
|
|
10708
10726
|
handleModelEvent(event) {
|
|
10709
|
-
log$
|
|
10727
|
+
log$4.debug2("handleModelEvent", event);
|
|
10710
10728
|
const { detail, type } = event;
|
|
10711
10729
|
this.dispatchEvent(new EventShimCustomEvent(type, { detail }));
|
|
10712
10730
|
}
|
|
@@ -10720,10 +10738,10 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10720
10738
|
this.formattedStringData = [];
|
|
10721
10739
|
this.viewportData = this.extractSnapshotData(snapshot);
|
|
10722
10740
|
this.updatePendingExpandCollapseState();
|
|
10723
|
-
|
|
10724
|
-
log$3.debug2("Pivot updated", {
|
|
10741
|
+
log$4.debug2("Pivot updated", {
|
|
10725
10742
|
columns: this.columns,
|
|
10726
|
-
snapshot
|
|
10743
|
+
snapshot,
|
|
10744
|
+
snapshotColumns: this.snapshotColumns,
|
|
10727
10745
|
viewport: (_a = this.viewportData) == null ? void 0 : _a.rowTotalCount,
|
|
10728
10746
|
columnCount: this.columnCount,
|
|
10729
10747
|
rowCount: this.rowCount
|
|
@@ -10735,7 +10753,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10735
10753
|
})
|
|
10736
10754
|
);
|
|
10737
10755
|
} else {
|
|
10738
|
-
log$
|
|
10756
|
+
log$4.debug2("Pivot columns did not change in the update");
|
|
10739
10757
|
}
|
|
10740
10758
|
this.dispatchEvent(new EventShimCustomEvent(irisGrid.IrisGridModel.EVENT.UPDATED));
|
|
10741
10759
|
}
|
|
@@ -10774,10 +10792,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10774
10792
|
const keyData = /* @__PURE__ */ new Map();
|
|
10775
10793
|
const totalsData = /* @__PURE__ */ new Map();
|
|
10776
10794
|
for (let c = 0; c < keys2.length; c += 1) {
|
|
10777
|
-
keyData.set(c, {
|
|
10778
|
-
// Only render the value for the deepest level
|
|
10779
|
-
value: c === depth - 1 ? keys2[c] : void 0
|
|
10780
|
-
});
|
|
10795
|
+
keyData.set(c, { value: keys2[c] });
|
|
10781
10796
|
}
|
|
10782
10797
|
for (let v = 0; v < snapshot.valueSources.length; v += 1) {
|
|
10783
10798
|
totalsData.set(v, {
|
|
@@ -10888,7 +10903,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10888
10903
|
}
|
|
10889
10904
|
}
|
|
10890
10905
|
close() {
|
|
10891
|
-
log$
|
|
10906
|
+
log$4.debug("close");
|
|
10892
10907
|
this.pivotTable.close();
|
|
10893
10908
|
}
|
|
10894
10909
|
get formatter() {
|
|
@@ -10980,49 +10995,41 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10980
10995
|
return true;
|
|
10981
10996
|
}
|
|
10982
10997
|
expandAllColumns() {
|
|
10983
|
-
log$
|
|
10998
|
+
log$4.debug("expandAllColumns");
|
|
10984
10999
|
this.setColumnExpanded(this.keyColumns.length, true, true);
|
|
10985
11000
|
}
|
|
10986
11001
|
collapseAllColumns() {
|
|
10987
|
-
log$
|
|
11002
|
+
log$4.debug("collapseAllColumns");
|
|
10988
11003
|
this.setColumnExpanded(this.keyColumns.length, false, true);
|
|
10989
11004
|
}
|
|
10990
11005
|
isColumnExpandable(x, depth) {
|
|
10991
|
-
var _a
|
|
10992
|
-
|
|
10993
|
-
x,
|
|
10994
|
-
depth,
|
|
10995
|
-
name: (_a = this.columns[x]) == null ? void 0 : _a.name,
|
|
10996
|
-
v: this.virtualColumns,
|
|
10997
|
-
cC: this.columnCount,
|
|
10998
|
-
c: this.columns
|
|
10999
|
-
});
|
|
11000
|
-
if (x >= this.keyColumns.length && x < this.virtualColumns.length) {
|
|
11006
|
+
var _a;
|
|
11007
|
+
if (this.isGrandTotalsColumn(x)) {
|
|
11001
11008
|
return !this.isRootColumnExpanded || this.columns.length > this.virtualColumns.length;
|
|
11002
11009
|
}
|
|
11003
11010
|
if (x < this.keyColumns.length) {
|
|
11004
11011
|
return false;
|
|
11005
11012
|
}
|
|
11006
|
-
return ((
|
|
11013
|
+
return ((_a = this.columns[x]) == null ? void 0 : _a.hasChildren) ?? false;
|
|
11014
|
+
}
|
|
11015
|
+
isGrandTotalsColumn(x) {
|
|
11016
|
+
const totalsStartIndex = this.keyColumns.length + (this.groupColumn == null ? 0 : 1);
|
|
11017
|
+
return x >= totalsStartIndex && x < this.virtualColumns.length;
|
|
11007
11018
|
}
|
|
11008
11019
|
isColumnExpanded(x) {
|
|
11009
11020
|
var _a;
|
|
11010
|
-
if (
|
|
11021
|
+
if (this.isGrandTotalsColumn(x)) {
|
|
11011
11022
|
return this.isRootColumnExpanded;
|
|
11012
11023
|
}
|
|
11013
11024
|
return ((_a = this.columns[x]) == null ? void 0 : _a.isExpanded) ?? false;
|
|
11014
11025
|
}
|
|
11015
11026
|
setColumnExpanded(x, isExpanded, expandDescendants = false) {
|
|
11016
|
-
|
|
11017
|
-
log$3.debug2("[0] setColumnExpanded", {
|
|
11027
|
+
log$4.debug2("setColumnExpanded", {
|
|
11018
11028
|
x,
|
|
11019
11029
|
isExpanded,
|
|
11020
|
-
|
|
11021
|
-
v: this.virtualColumns,
|
|
11022
|
-
cC: this.columnCount,
|
|
11023
|
-
c: this.columns
|
|
11030
|
+
expandDescendants
|
|
11024
11031
|
});
|
|
11025
|
-
if (
|
|
11032
|
+
if (this.isGrandTotalsColumn(x)) {
|
|
11026
11033
|
this.pivotTable.setRootColumnExpanded(isExpanded, expandDescendants);
|
|
11027
11034
|
this.isRootColumnExpanded = isExpanded;
|
|
11028
11035
|
return;
|
|
@@ -11088,15 +11095,27 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
11088
11095
|
this.formattedStringData[x][y] = text;
|
|
11089
11096
|
}
|
|
11090
11097
|
dataForCell(x, y) {
|
|
11091
|
-
var _a, _b, _c;
|
|
11098
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11092
11099
|
const keyCount = this.keyColumns.length;
|
|
11093
|
-
|
|
11094
|
-
|
|
11100
|
+
const groupOffset = this.groupColumn == null ? 0 : 1;
|
|
11101
|
+
if (groupOffset === 1 && x === 0) {
|
|
11102
|
+
const rowDepth = ((_a = this.row(y)) == null ? void 0 : _a.depth) ?? 2;
|
|
11103
|
+
return y === 0 ? (
|
|
11104
|
+
// Empty value for the group cell in the totals row
|
|
11105
|
+
{ value: "" }
|
|
11106
|
+
) : {
|
|
11107
|
+
// Render all key values except the last one in the group column
|
|
11108
|
+
// to match the Rollup UI
|
|
11109
|
+
value: rowDepth < keyCount ? (_c = (_b = this.row(y)) == null ? void 0 : _b.keyData.get(rowDepth - 1)) == null ? void 0 : _c.value : ""
|
|
11110
|
+
};
|
|
11111
|
+
}
|
|
11112
|
+
if (x < keyCount + groupOffset) {
|
|
11113
|
+
return (_d = this.row(y)) == null ? void 0 : _d.keyData.get(x - groupOffset);
|
|
11095
11114
|
}
|
|
11096
11115
|
if (x < this.virtualColumns.length) {
|
|
11097
|
-
return (
|
|
11116
|
+
return (_e = this.row(y)) == null ? void 0 : _e.totalsData.get(x - keyCount - groupOffset);
|
|
11098
11117
|
}
|
|
11099
|
-
return (
|
|
11118
|
+
return (_f = this.row(y)) == null ? void 0 : _f.data.get(x - this.virtualColumns.length);
|
|
11100
11119
|
}
|
|
11101
11120
|
formatForCell(x, y) {
|
|
11102
11121
|
var _a;
|
|
@@ -11139,7 +11158,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
11139
11158
|
this.virtualColumns.length,
|
|
11140
11159
|
this.snapshotValueSources.length
|
|
11141
11160
|
);
|
|
11142
|
-
log$
|
|
11161
|
+
log$4.debug2("applyBufferedViewport", {
|
|
11143
11162
|
top,
|
|
11144
11163
|
bottom,
|
|
11145
11164
|
columns,
|
|
@@ -11169,8 +11188,8 @@ function useIrisGridPivotModel(fetch) {
|
|
|
11169
11188
|
[model]
|
|
11170
11189
|
);
|
|
11171
11190
|
const makeModel = React.useCallback(async () => {
|
|
11172
|
-
const
|
|
11173
|
-
return new IrisGridPivotModel(dh,
|
|
11191
|
+
const pivotTable = await fetch();
|
|
11192
|
+
return new IrisGridPivotModel(dh, pivotTable);
|
|
11174
11193
|
}, [dh, fetch]);
|
|
11175
11194
|
const reload = React.useCallback(async () => {
|
|
11176
11195
|
setIsLoading(true);
|
|
@@ -11218,6 +11237,22 @@ function useIrisGridPivotModel(fetch) {
|
|
|
11218
11237
|
}
|
|
11219
11238
|
throw new Error("Invalid state");
|
|
11220
11239
|
}
|
|
11240
|
+
const log$3 = Log.module("@deephaven/js-plugin-pivot/usePivotTableFetch");
|
|
11241
|
+
function usePivotTableFetch(fetch) {
|
|
11242
|
+
const api = jsapiBootstrap.useApi();
|
|
11243
|
+
return React.useCallback(
|
|
11244
|
+
() => fetch().then((widget) => {
|
|
11245
|
+
log$3.debug("Pivot fetch result:", widget);
|
|
11246
|
+
if (!isCorePlusDh(api)) {
|
|
11247
|
+
throw new Error("CorePlus is not available");
|
|
11248
|
+
}
|
|
11249
|
+
const pivotTable = new api.coreplus.pivot.PivotTable(widget);
|
|
11250
|
+
log$3.debug("Created pivot table:", pivotTable);
|
|
11251
|
+
return pivotTable;
|
|
11252
|
+
}),
|
|
11253
|
+
[api, fetch]
|
|
11254
|
+
);
|
|
11255
|
+
}
|
|
11221
11256
|
class PivotColumnGroupMouseHandler extends GridMouseHandler {
|
|
11222
11257
|
constructor(irisGrid2) {
|
|
11223
11258
|
super();
|
|
@@ -11233,6 +11268,26 @@ class PivotColumnGroupMouseHandler extends GridMouseHandler {
|
|
|
11233
11268
|
}
|
|
11234
11269
|
return null;
|
|
11235
11270
|
}
|
|
11271
|
+
setCursor(gridPoint, grid) {
|
|
11272
|
+
const { column, columnHeaderDepth } = gridPoint;
|
|
11273
|
+
if (this.isExpandableColumnGroup(column, columnHeaderDepth)) {
|
|
11274
|
+
this.cursor = "pointer";
|
|
11275
|
+
return { stopPropagation: false, preventDefault: false };
|
|
11276
|
+
}
|
|
11277
|
+
this.cursor = null;
|
|
11278
|
+
return false;
|
|
11279
|
+
}
|
|
11280
|
+
isExpandableColumnGroup(column, columnHeaderDepth = 0) {
|
|
11281
|
+
const { model } = this.irisGrid.props;
|
|
11282
|
+
if (column == null || model == null) {
|
|
11283
|
+
return false;
|
|
11284
|
+
}
|
|
11285
|
+
const group = model.getColumnHeaderGroup(column, columnHeaderDepth);
|
|
11286
|
+
return group != null && isPivotColumnHeaderGroup(group) && group.isExpandable;
|
|
11287
|
+
}
|
|
11288
|
+
onMove(gridPoint, grid) {
|
|
11289
|
+
return this.setCursor(gridPoint, grid);
|
|
11290
|
+
}
|
|
11236
11291
|
// We need to remember where the down started, because the canvas element will trigger a click wherever mouseUp is
|
|
11237
11292
|
onDown(gridPoint) {
|
|
11238
11293
|
this.column = this.getColumnGroupFromGridPoint(gridPoint);
|
|
@@ -11240,177 +11295,365 @@ class PivotColumnGroupMouseHandler extends GridMouseHandler {
|
|
|
11240
11295
|
}
|
|
11241
11296
|
onClick(gridPoint, grid, event) {
|
|
11242
11297
|
const column = this.getColumnGroupFromGridPoint(gridPoint);
|
|
11243
|
-
if (column != null && column === this.column) {
|
|
11244
|
-
this.irisGrid.toggleExpandColumn(
|
|
11298
|
+
if (column != null && column === this.column && this.isExpandableColumnGroup(column, gridPoint.columnHeaderDepth)) {
|
|
11299
|
+
this.irisGrid.toggleExpandColumn(
|
|
11300
|
+
column,
|
|
11301
|
+
GridUtils.isModifierKeyDown(event)
|
|
11302
|
+
);
|
|
11245
11303
|
return true;
|
|
11246
11304
|
}
|
|
11247
11305
|
return false;
|
|
11248
11306
|
}
|
|
11249
11307
|
}
|
|
11250
|
-
function
|
|
11251
|
-
|
|
11252
|
-
|
|
11308
|
+
function getColumnWidth(column, metrics, themeColumnWidth) {
|
|
11309
|
+
const {
|
|
11310
|
+
firstColumn,
|
|
11311
|
+
allColumnWidths,
|
|
11312
|
+
calculatedColumnWidths,
|
|
11313
|
+
userColumnWidths,
|
|
11314
|
+
treePaddingX
|
|
11315
|
+
} = metrics;
|
|
11316
|
+
const modelColumn = GridUtils.getModelIndex(column, metrics.movedColumns);
|
|
11317
|
+
return userColumnWidths.get(modelColumn) ?? allColumnWidths.get(column) ?? (calculatedColumnWidths.has(modelColumn) ? (calculatedColumnWidths.get(modelColumn) ?? 0) + (column === firstColumn ? treePaddingX : 0) : void 0) ?? themeColumnWidth;
|
|
11318
|
+
}
|
|
11319
|
+
function getColumnHeaderCoordinates(state, group) {
|
|
11320
|
+
const { metrics, theme } = state;
|
|
11321
|
+
const { childIndexes, depth } = group;
|
|
11322
|
+
const firstChildIndex = childIndexes[0];
|
|
11323
|
+
const lastChildIndex = childIndexes[childIndexes.length - 1];
|
|
11324
|
+
if (firstChildIndex == null || lastChildIndex == null) {
|
|
11325
|
+
throw new Error("Group has no child columns");
|
|
11326
|
+
}
|
|
11327
|
+
const { left, right, allColumnXs, allColumnWidths, gridX, gridY } = metrics;
|
|
11328
|
+
const {
|
|
11329
|
+
filterBarHeight,
|
|
11330
|
+
columnHeaderHeight,
|
|
11331
|
+
columnWidth: themeColumnWidth
|
|
11332
|
+
} = theme;
|
|
11333
|
+
const firstVisible = Math.max(left, firstChildIndex);
|
|
11334
|
+
const lastVisible = Math.min(right, lastChildIndex);
|
|
11335
|
+
if (firstVisible > lastChildIndex || lastVisible < firstChildIndex) {
|
|
11336
|
+
return null;
|
|
11337
|
+
}
|
|
11338
|
+
const firstVisibleX = allColumnXs.get(firstVisible);
|
|
11339
|
+
if (firstVisibleX == null) {
|
|
11340
|
+
return null;
|
|
11341
|
+
}
|
|
11342
|
+
let groupX1 = firstVisibleX;
|
|
11343
|
+
for (let i = firstChildIndex; i < firstVisible; i += 1) {
|
|
11344
|
+
groupX1 -= getColumnWidth(i, metrics, themeColumnWidth);
|
|
11345
|
+
}
|
|
11346
|
+
const lastColumnX = allColumnXs.get(lastVisible);
|
|
11347
|
+
const lastColumnWidth = allColumnWidths.get(lastVisible);
|
|
11348
|
+
if (lastColumnX == null || lastColumnWidth == null) {
|
|
11349
|
+
return null;
|
|
11350
|
+
}
|
|
11351
|
+
let groupX2 = lastColumnX + lastColumnWidth;
|
|
11352
|
+
for (let i = lastVisible + 1; i <= lastChildIndex; i += 1) {
|
|
11353
|
+
groupX2 += getColumnWidth(i, metrics, themeColumnWidth);
|
|
11354
|
+
}
|
|
11355
|
+
return {
|
|
11356
|
+
x1: gridX + groupX1,
|
|
11357
|
+
y1: gridY - filterBarHeight - (depth + 1) * columnHeaderHeight,
|
|
11358
|
+
x2: gridX + groupX2,
|
|
11359
|
+
y2: gridY - filterBarHeight - depth * columnHeaderHeight
|
|
11360
|
+
};
|
|
11253
11361
|
}
|
|
11254
|
-
class
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
const {
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
headerSeparatorColor,
|
|
11286
|
-
headerSeparatorHoverColor
|
|
11287
|
-
} = theme;
|
|
11288
|
-
const hiddenSeparatorHeight = columnHeaderHeight * 0.5;
|
|
11289
|
-
const hiddenY = columnHeaderHeight * (columnHeaderMaxDepth - 1) + columnHeaderHeight * 0.5 - hiddenSeparatorHeight * 0.5;
|
|
11290
|
-
const containsFrozenColumns = floatingLeftColumnCount > 0;
|
|
11291
|
-
if (!isExpandableColumnGridModel(model)) {
|
|
11292
|
-
throw new Error("Unsupported model type");
|
|
11362
|
+
class IrisGridPivotMetricCalculator extends irisGrid.IrisGridMetricCalculator {
|
|
11363
|
+
constructor() {
|
|
11364
|
+
super(...arguments);
|
|
11365
|
+
// Initialize with null to ensure the first check always triggers reset
|
|
11366
|
+
__publicField(this, "cachedIsFilterBarShown", null);
|
|
11367
|
+
__publicField(this, "getCachedColumnSourceLabelWidth", memoizeOne(
|
|
11368
|
+
(keyColumnGroups, headerHorizontalPadding, maxColumnWidth, state) => {
|
|
11369
|
+
let result = 0;
|
|
11370
|
+
keyColumnGroups.forEach((group) => {
|
|
11371
|
+
const sourceIndex = -group.depth;
|
|
11372
|
+
const width = this.getColumnHeaderGroupWidth(
|
|
11373
|
+
sourceIndex,
|
|
11374
|
+
0,
|
|
11375
|
+
state,
|
|
11376
|
+
maxColumnWidth
|
|
11377
|
+
);
|
|
11378
|
+
result = Math.max(result, width + headerHorizontalPadding);
|
|
11379
|
+
});
|
|
11380
|
+
return result;
|
|
11381
|
+
}
|
|
11382
|
+
));
|
|
11383
|
+
}
|
|
11384
|
+
/**
|
|
11385
|
+
* Resets column width caches if filter bar visibility has changed
|
|
11386
|
+
* to adjust for the minimum filter box width.
|
|
11387
|
+
* @param state The current IrisGridPivotMetricState
|
|
11388
|
+
*/
|
|
11389
|
+
resetHeaderWidthsIfFilterBarChanged(state) {
|
|
11390
|
+
const { isFilterBarShown } = state;
|
|
11391
|
+
if (this.cachedIsFilterBarShown !== isFilterBarShown) {
|
|
11392
|
+
this.resetCalculatedHeaderGroupWidths();
|
|
11293
11393
|
}
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11394
|
+
this.cachedIsFilterBarShown = isFilterBarShown;
|
|
11395
|
+
}
|
|
11396
|
+
getColumnHeaderGroupWidth(modelColumn, depth, state, maxColumnWidth) {
|
|
11397
|
+
const baseWidth = super.getColumnHeaderGroupWidth(
|
|
11398
|
+
modelColumn,
|
|
11399
|
+
depth,
|
|
11297
11400
|
state,
|
|
11298
|
-
|
|
11299
|
-
{
|
|
11300
|
-
minX: gridX + floatingLeftWidth,
|
|
11301
|
-
maxX: width - floatingRightWidth
|
|
11302
|
-
}
|
|
11401
|
+
maxColumnWidth
|
|
11303
11402
|
);
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
state,
|
|
11308
|
-
[floatingColumns[0], floatingColumns[floatingColumns.length - 1]],
|
|
11309
|
-
{
|
|
11310
|
-
minX: gridX,
|
|
11311
|
-
maxX: gridX + floatingLeftWidth
|
|
11312
|
-
}
|
|
11313
|
-
);
|
|
11314
|
-
}
|
|
11315
|
-
if (headerSeparatorColor) {
|
|
11316
|
-
context.strokeStyle = headerSeparatorColor;
|
|
11317
|
-
const hiddenColumns = [...allColumnWidths.entries()].filter(([_, w]) => w === 0).map(([index]) => index);
|
|
11318
|
-
context.beginPath();
|
|
11319
|
-
context.fillStyle = headerSeparatorColor;
|
|
11320
|
-
for (let i = 0; i < hiddenColumns.length; i += 1) {
|
|
11321
|
-
const column = hiddenColumns[i];
|
|
11322
|
-
const columnX = getOrThrow(allColumnXs, column);
|
|
11323
|
-
const columnWidth = getOrThrow(allColumnWidths, column);
|
|
11324
|
-
const minX = gridX + columnX + columnWidth + 0.5 - headerHiddenSeparatorSize * 0.5;
|
|
11325
|
-
context.rect(
|
|
11326
|
-
minX,
|
|
11327
|
-
hiddenY,
|
|
11328
|
-
headerHiddenSeparatorSize,
|
|
11329
|
-
hiddenSeparatorHeight
|
|
11330
|
-
);
|
|
11331
|
-
}
|
|
11332
|
-
context.fill();
|
|
11403
|
+
const { isFilterBarShown, model } = state;
|
|
11404
|
+
if (!isFilterBarShown) {
|
|
11405
|
+
return baseWidth;
|
|
11333
11406
|
}
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
const separator = GridColumnSeparatorMouseHandler$1.getColumnSeparator(
|
|
11338
|
-
GridUtils.getGridPointFromXY(mouseX, mouseY, metrics),
|
|
11339
|
-
metrics,
|
|
11340
|
-
model,
|
|
11341
|
-
theme
|
|
11342
|
-
);
|
|
11343
|
-
highlightedSeparator = separator == null ? void 0 : separator.index;
|
|
11344
|
-
depth = separator == null ? void 0 : separator.depth;
|
|
11345
|
-
}
|
|
11346
|
-
let shouldDrawSeparator;
|
|
11347
|
-
if (highlightedSeparator == null) {
|
|
11348
|
-
shouldDrawSeparator = false;
|
|
11349
|
-
} else {
|
|
11350
|
-
const columnIndex = modelColumns.get(highlightedSeparator);
|
|
11351
|
-
const nextColumnIndex = modelColumns.get(highlightedSeparator + 1);
|
|
11352
|
-
if (columnIndex == null || nextColumnIndex == null) {
|
|
11353
|
-
shouldDrawSeparator = false;
|
|
11354
|
-
} else {
|
|
11355
|
-
shouldDrawSeparator = getColumnGroupName(model, columnIndex, depth) !== getColumnGroupName(model, nextColumnIndex, depth);
|
|
11356
|
-
}
|
|
11357
|
-
}
|
|
11358
|
-
if (shouldDrawSeparator && highlightedSeparator != null && depth != null && (!isDragging || draggingColumnSeparator != null)) {
|
|
11359
|
-
context.strokeStyle = headerSeparatorHoverColor;
|
|
11360
|
-
const columnX = getOrThrow(allColumnXs, highlightedSeparator);
|
|
11361
|
-
const columnWidth = getOrThrow(allColumnWidths, highlightedSeparator);
|
|
11362
|
-
const x = gridX + columnX + columnWidth + 0.5;
|
|
11363
|
-
const visibleColumnIndex = visibleColumns.indexOf(highlightedSeparator);
|
|
11364
|
-
const nextColumn = visibleColumnIndex < visibleColumns.length - 1 ? visibleColumns[visibleColumnIndex + 1] : null;
|
|
11365
|
-
const nextColumnWidth = nextColumn != null ? allColumnWidths.get(nextColumn) : null;
|
|
11366
|
-
const isColumnHidden = columnWidth === 0;
|
|
11367
|
-
const isNextColumnHidden = nextColumnWidth != null && nextColumnWidth === 0;
|
|
11368
|
-
if (isColumnHidden) {
|
|
11369
|
-
context.strokeStyle = headerHiddenSeparatorHoverColor;
|
|
11370
|
-
context.fillStyle = headerHiddenSeparatorHoverColor;
|
|
11371
|
-
context.fillRect(
|
|
11372
|
-
x,
|
|
11373
|
-
hiddenY,
|
|
11374
|
-
headerHiddenSeparatorSize * 0.5,
|
|
11375
|
-
hiddenSeparatorHeight
|
|
11376
|
-
);
|
|
11377
|
-
} else if (isNextColumnHidden) {
|
|
11378
|
-
context.fillStyle = headerSeparatorHoverColor;
|
|
11379
|
-
context.fillRect(
|
|
11380
|
-
x - headerHiddenSeparatorSize * 0.5,
|
|
11381
|
-
hiddenY,
|
|
11382
|
-
headerHiddenSeparatorSize * 0.5,
|
|
11383
|
-
hiddenSeparatorHeight
|
|
11384
|
-
);
|
|
11385
|
-
}
|
|
11386
|
-
context.beginPath();
|
|
11387
|
-
context.moveTo(
|
|
11388
|
-
x,
|
|
11389
|
-
(columnHeaderMaxDepth - depth - 1) * columnHeaderHeight
|
|
11390
|
-
);
|
|
11391
|
-
context.lineTo(
|
|
11392
|
-
x,
|
|
11393
|
-
(columnHeaderMaxDepth - depth) * columnHeaderHeight - 1
|
|
11394
|
-
);
|
|
11395
|
-
context.stroke();
|
|
11396
|
-
}
|
|
11407
|
+
const group = model.getColumnHeaderGroup(modelColumn, depth);
|
|
11408
|
+
if (!isPivotColumnHeaderGroup(group) || !group.isKeyColumnGroup) {
|
|
11409
|
+
return baseWidth;
|
|
11397
11410
|
}
|
|
11398
|
-
|
|
11411
|
+
const { theme } = state;
|
|
11412
|
+
const { columnSourceFilterMinWidth } = theme;
|
|
11413
|
+
return baseWidth + columnSourceFilterMinWidth;
|
|
11399
11414
|
}
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11415
|
+
/**
|
|
11416
|
+
* Calculate the width needed for the column source labels
|
|
11417
|
+
* @param model The IrisGridPivotModel instance
|
|
11418
|
+
* @param state The current IrisGridPivotMetricState
|
|
11419
|
+
* @returns The calculated width for the column source labels
|
|
11420
|
+
*/
|
|
11421
|
+
calculateColumnSourceLabelWidth(model, state) {
|
|
11422
|
+
const { theme } = state;
|
|
11423
|
+
const { headerHorizontalPadding, maxColumnWidth } = theme;
|
|
11424
|
+
const keyColumnGroups = getKeyColumnGroups(model);
|
|
11425
|
+
return this.getCachedColumnSourceLabelWidth(
|
|
11426
|
+
keyColumnGroups,
|
|
11427
|
+
headerHorizontalPadding,
|
|
11428
|
+
maxColumnWidth,
|
|
11429
|
+
state
|
|
11430
|
+
);
|
|
11431
|
+
}
|
|
11432
|
+
/**
|
|
11433
|
+
* Gets the metrics for the current state. This method has to be called before setColumnSize or resetColumnSize.
|
|
11434
|
+
* @param state The current IrisGridPivotMetricState
|
|
11435
|
+
* @returns The metrics for the current state
|
|
11436
|
+
*/
|
|
11437
|
+
getMetrics(state) {
|
|
11438
|
+
const { model } = state;
|
|
11439
|
+
if (!isIrisGridPivotModel(model)) {
|
|
11440
|
+
throw new Error("Model is not an IrisGridPivotModel");
|
|
11441
|
+
}
|
|
11442
|
+
const columnSourceLabelWidth = this.calculateColumnSourceLabelWidth(
|
|
11443
|
+
model,
|
|
11444
|
+
state
|
|
11445
|
+
);
|
|
11446
|
+
this.resetHeaderWidthsIfFilterBarChanged(state);
|
|
11447
|
+
return {
|
|
11448
|
+
...super.getMetrics(state),
|
|
11449
|
+
columnSourceLabelWidth
|
|
11450
|
+
};
|
|
11451
|
+
}
|
|
11452
|
+
/**
|
|
11453
|
+
* Get metrics for positioning the filter bar input field.
|
|
11454
|
+
* @param index The visible index of the column to get the filter box coordinates for
|
|
11455
|
+
* @param state The current IrisGridMetricState
|
|
11456
|
+
* @param metrics The grid metrics
|
|
11457
|
+
* @returns Coordinates for the filter input field, or null if positioning cannot be calculated
|
|
11458
|
+
*/
|
|
11459
|
+
// eslint-disable-next-line class-methods-use-this
|
|
11460
|
+
getFilterInputCoordinates(index, state, metrics) {
|
|
11461
|
+
if (index >= 0) {
|
|
11462
|
+
return super.getFilterInputCoordinates(index, state, metrics);
|
|
11463
|
+
}
|
|
11464
|
+
const { model, theme } = state;
|
|
11465
|
+
if (!isIrisGridPivotModel(model)) {
|
|
11466
|
+
return null;
|
|
11467
|
+
}
|
|
11468
|
+
const { gridY, columnSourceLabelWidth } = metrics;
|
|
11469
|
+
const { columnSourceFilterMinWidth, filterBarHeight } = theme;
|
|
11470
|
+
const depth = -index;
|
|
11471
|
+
const keyColumnGroup = model.getColumnHeaderGroup(0, depth);
|
|
11472
|
+
if (keyColumnGroup == null || !isPivotColumnHeaderGroup(keyColumnGroup) || !keyColumnGroup.isKeyColumnGroup) {
|
|
11473
|
+
return null;
|
|
11474
|
+
}
|
|
11475
|
+
const groupCoords = getColumnHeaderCoordinates(
|
|
11476
|
+
{ metrics, theme, model },
|
|
11477
|
+
keyColumnGroup
|
|
11478
|
+
);
|
|
11479
|
+
if (groupCoords == null) {
|
|
11480
|
+
return null;
|
|
11481
|
+
}
|
|
11482
|
+
const { x1, x2 } = groupCoords;
|
|
11483
|
+
const columnSourceFilterWidth = Math.max(
|
|
11484
|
+
columnSourceFilterMinWidth,
|
|
11485
|
+
x2 - x1 - columnSourceLabelWidth
|
|
11486
|
+
);
|
|
11487
|
+
const x = x2 - columnSourceFilterWidth;
|
|
11488
|
+
const y = gridY - theme.columnHeaderHeight - (1 - index) * (filterBarHeight ?? 0);
|
|
11489
|
+
return {
|
|
11490
|
+
x,
|
|
11491
|
+
y,
|
|
11492
|
+
width: columnSourceFilterWidth + 1,
|
|
11493
|
+
// cover right border
|
|
11494
|
+
height: (filterBarHeight ?? 0) - 1
|
|
11495
|
+
// remove bottom border
|
|
11496
|
+
};
|
|
11497
|
+
}
|
|
11498
|
+
/**
|
|
11499
|
+
* Calculate the new left index to bring the given column into view.
|
|
11500
|
+
* @param column The column that should be scrolled into view
|
|
11501
|
+
* @param state The current IrisGridMetricState
|
|
11502
|
+
* @param metrics The grid metrics
|
|
11503
|
+
* @returns The left column index to scroll to, or null if no scroll is needed
|
|
11504
|
+
*/
|
|
11505
|
+
getScrollLeftForColumn(column, state, metrics) {
|
|
11506
|
+
if (column < 0) {
|
|
11507
|
+
return null;
|
|
11508
|
+
}
|
|
11509
|
+
return super.getScrollLeftForColumn(column, state, metrics);
|
|
11510
|
+
}
|
|
11511
|
+
}
|
|
11512
|
+
function getColumnSourceHeaderFromGridPoint(model, gridPoint) {
|
|
11513
|
+
const { column, row, columnHeaderDepth } = gridPoint;
|
|
11514
|
+
const sourceIndex = columnHeaderDepth != null ? -columnHeaderDepth : null;
|
|
11515
|
+
if (column == null || row !== null || columnHeaderDepth == null) {
|
|
11516
|
+
return null;
|
|
11517
|
+
}
|
|
11518
|
+
const group = model.getColumnHeaderGroup(column, columnHeaderDepth);
|
|
11519
|
+
if (sourceIndex != null && sourceIndex < 0 && isIrisGridPivotModel(model) && isPivotColumnHeaderGroup(group) && group.isKeyColumnGroup) {
|
|
11520
|
+
return sourceIndex;
|
|
11521
|
+
}
|
|
11522
|
+
return null;
|
|
11523
|
+
}
|
|
11524
|
+
function isGridPointInColumnSourceFilterBox(model, gridPoint, metrics, theme) {
|
|
11525
|
+
if (!isIrisGridPivotModel(model)) {
|
|
11526
|
+
return false;
|
|
11527
|
+
}
|
|
11528
|
+
const { column, row, columnHeaderDepth } = gridPoint;
|
|
11529
|
+
if (column == null || row !== null || columnHeaderDepth == null) {
|
|
11530
|
+
return false;
|
|
11531
|
+
}
|
|
11532
|
+
const sourceIndex = getColumnSourceHeaderFromGridPoint(model, gridPoint);
|
|
11533
|
+
if (sourceIndex == null) {
|
|
11534
|
+
return false;
|
|
11535
|
+
}
|
|
11536
|
+
const group = model.getColumnHeaderGroup(column, columnHeaderDepth);
|
|
11537
|
+
if (!isPivotColumnHeaderGroup(group)) {
|
|
11538
|
+
return false;
|
|
11539
|
+
}
|
|
11540
|
+
const coords = getColumnHeaderCoordinates(
|
|
11541
|
+
{ metrics, theme, model },
|
|
11542
|
+
group
|
|
11543
|
+
);
|
|
11544
|
+
if (coords == null) {
|
|
11545
|
+
return false;
|
|
11546
|
+
}
|
|
11547
|
+
const { columnSourceFilterMinWidth } = theme;
|
|
11548
|
+
const { columnSourceLabelWidth } = metrics;
|
|
11549
|
+
const { x1, x2 } = coords;
|
|
11550
|
+
const columnSourceFilterWidth = Math.max(
|
|
11551
|
+
x2 - x1 - columnSourceLabelWidth,
|
|
11552
|
+
columnSourceFilterMinWidth
|
|
11553
|
+
);
|
|
11554
|
+
return gridPoint.x > x2 - columnSourceFilterWidth;
|
|
11555
|
+
}
|
|
11556
|
+
const log$2 = Log.module("@deephaven/js-plugin-pivot/PivotSortMouseHandler");
|
|
11557
|
+
class PivotSortMouseHandler extends GridMouseHandler {
|
|
11558
|
+
constructor(irisGrid2) {
|
|
11559
|
+
super();
|
|
11560
|
+
__publicField(this, "columnSource");
|
|
11561
|
+
__publicField(this, "irisGrid");
|
|
11562
|
+
this.columnSource = null;
|
|
11563
|
+
this.irisGrid = irisGrid2;
|
|
11564
|
+
}
|
|
11565
|
+
// We need to remember where the down started, because the canvas element will trigger a click where mouseUp is
|
|
11566
|
+
onDown(gridPoint, grid, event) {
|
|
11567
|
+
const { model } = this.irisGrid.props;
|
|
11568
|
+
assertNotNull(model);
|
|
11569
|
+
this.columnSource = getColumnSourceHeaderFromGridPoint(model, gridPoint);
|
|
11570
|
+
log$2.debug("onDown", gridPoint, this.columnSource);
|
|
11571
|
+
return false;
|
|
11572
|
+
}
|
|
11573
|
+
onClick(gridPoint, grid, event) {
|
|
11574
|
+
const { model } = this.irisGrid.props;
|
|
11575
|
+
assertNotNull(model);
|
|
11576
|
+
const columnSource = getColumnSourceHeaderFromGridPoint(model, gridPoint);
|
|
11577
|
+
if (columnSource != null && columnSource === this.columnSource && model.isColumnSortable(columnSource)) {
|
|
11578
|
+
const addToExisting = components.ContextActionUtils.isModifierKeyDown(event);
|
|
11579
|
+
this.irisGrid.toggleSort(columnSource, addToExisting);
|
|
11580
|
+
return true;
|
|
11581
|
+
}
|
|
11582
|
+
return false;
|
|
11583
|
+
}
|
|
11584
|
+
}
|
|
11585
|
+
function isPivotGridMetrics(metrics) {
|
|
11586
|
+
return metrics.columnSourceLabelWidth !== void 0;
|
|
11587
|
+
}
|
|
11588
|
+
class PivotFilterMouseHandler extends GridMouseHandler {
|
|
11589
|
+
constructor(irisGrid2) {
|
|
11590
|
+
super();
|
|
11591
|
+
__publicField(this, "irisGrid");
|
|
11592
|
+
this.irisGrid = irisGrid2;
|
|
11593
|
+
}
|
|
11594
|
+
onDown(gridPoint) {
|
|
11595
|
+
const { model } = this.irisGrid.props;
|
|
11596
|
+
const { isFilterBarShown, metrics } = this.irisGrid.state;
|
|
11597
|
+
const sourceIndex = getColumnSourceHeaderFromGridPoint(model, gridPoint);
|
|
11598
|
+
if (sourceIndex != null) {
|
|
11599
|
+
assertNotNull(metrics, "Metrics not set");
|
|
11600
|
+
if (!isPivotGridMetrics(metrics)) {
|
|
11601
|
+
throw new Error("PivotGridMetrics required");
|
|
11602
|
+
}
|
|
11603
|
+
const theme = this.irisGrid.getTheme();
|
|
11604
|
+
if (isFilterBarShown && theme.columnHeaderHeight != null && theme.filterBarHeight != null && isGridPointInColumnSourceFilterBox(model, gridPoint, metrics, theme)) {
|
|
11605
|
+
this.irisGrid.focusFilterBar(sourceIndex);
|
|
11606
|
+
return true;
|
|
11607
|
+
}
|
|
11608
|
+
}
|
|
11609
|
+
return false;
|
|
11610
|
+
}
|
|
11611
|
+
onClick(gridPoint, grid, event) {
|
|
11612
|
+
const { model } = this.irisGrid.props;
|
|
11613
|
+
const { isFilterBarShown, metrics } = this.irisGrid.state;
|
|
11614
|
+
const sourceIndex = getColumnSourceHeaderFromGridPoint(model, gridPoint);
|
|
11615
|
+
if (sourceIndex != null) {
|
|
11616
|
+
assertNotNull(metrics, "Metrics not set");
|
|
11617
|
+
if (!isPivotGridMetrics(metrics)) {
|
|
11618
|
+
throw new Error("PivotGridMetrics required");
|
|
11619
|
+
}
|
|
11620
|
+
const theme = this.irisGrid.getTheme();
|
|
11621
|
+
if (isFilterBarShown && theme.columnHeaderHeight != null && theme.filterBarHeight != null && isGridPointInColumnSourceFilterBox(model, gridPoint, metrics, theme)) {
|
|
11622
|
+
return true;
|
|
11623
|
+
}
|
|
11624
|
+
}
|
|
11625
|
+
return false;
|
|
11626
|
+
}
|
|
11627
|
+
}
|
|
11628
|
+
function usePivotMouseHandlers() {
|
|
11629
|
+
return React.useMemo(
|
|
11630
|
+
() => [
|
|
11631
|
+
(irisGrid2) => new PivotColumnGroupMouseHandler(irisGrid2),
|
|
11632
|
+
// Filter handler should consume events before sort
|
|
11633
|
+
(irisGrid2) => new PivotFilterMouseHandler(irisGrid2),
|
|
11634
|
+
(irisGrid2) => new PivotSortMouseHandler(irisGrid2)
|
|
11635
|
+
],
|
|
11636
|
+
[]
|
|
11637
|
+
);
|
|
11638
|
+
}
|
|
11639
|
+
function getColumnGroupName(model, modelColumn, depth) {
|
|
11640
|
+
var _a;
|
|
11641
|
+
return (_a = model.getColumnHeaderGroup(modelColumn, depth ?? 0)) == null ? void 0 : _a.name;
|
|
11642
|
+
}
|
|
11643
|
+
class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
11644
|
+
drawColumnHeaders(context, state) {
|
|
11645
|
+
super.drawColumnHeaders(context, state);
|
|
11646
|
+
this.drawColumnSourceFilters(context, state);
|
|
11647
|
+
}
|
|
11648
|
+
drawColumnHeadersAtDepth(context, state, range, bounds, depth) {
|
|
11649
|
+
const { isFilterBarShown, metrics, model, theme } = state;
|
|
11650
|
+
if (!isIrisGridPivotModel(model)) {
|
|
11651
|
+
throw new Error("Unsupported model type");
|
|
11652
|
+
}
|
|
11653
|
+
const { modelColumns } = metrics;
|
|
11654
|
+
const { columnHeaderHeight } = theme;
|
|
11411
11655
|
const { columnHeaderMaxDepth } = model;
|
|
11412
11656
|
const { minX, maxX } = bounds;
|
|
11413
|
-
const visibleWidth = maxX - minX;
|
|
11414
11657
|
if (columnHeaderMaxDepth === 0) {
|
|
11415
11658
|
return;
|
|
11416
11659
|
}
|
|
@@ -11430,66 +11673,61 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11430
11673
|
if (depth > 0) {
|
|
11431
11674
|
let columnIndex = startIndex;
|
|
11432
11675
|
while (columnIndex <= endIndex) {
|
|
11433
|
-
const { columnCount } = metrics;
|
|
11434
11676
|
const modelColumn = getOrThrow(modelColumns, columnIndex);
|
|
11435
|
-
const columnGroupColor =
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
const
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
const isFullWidth = columnGroupRight - columnGroupLeft >= visibleWidth;
|
|
11465
|
-
let x = columnGroupLeft;
|
|
11466
|
-
if (isFullWidth) {
|
|
11467
|
-
if (columnGroupRight < maxX) {
|
|
11468
|
-
x = columnGroupRight - visibleWidth;
|
|
11469
|
-
} else if (columnGroupLeft < minX) {
|
|
11470
|
-
x = minX;
|
|
11677
|
+
const columnGroupColor = model.colorForColumnHeader(
|
|
11678
|
+
modelColumn,
|
|
11679
|
+
depth,
|
|
11680
|
+
theme
|
|
11681
|
+
);
|
|
11682
|
+
const headerGroup = model.getColumnHeaderGroup(modelColumn, depth);
|
|
11683
|
+
const isExpandable = isPivotColumnHeaderGroup(headerGroup) && headerGroup.isExpandable;
|
|
11684
|
+
const isExpanded = isPivotColumnHeaderGroup(headerGroup) && headerGroup.isExpanded;
|
|
11685
|
+
const groupName = getColumnGroupName(model, modelColumn, depth);
|
|
11686
|
+
if (groupName != null && isPivotColumnHeaderGroup(headerGroup)) {
|
|
11687
|
+
const coords = getColumnHeaderCoordinates(state, headerGroup);
|
|
11688
|
+
if (coords != null) {
|
|
11689
|
+
const { x1: columnGroupLeft, x2: columnGroupRight } = coords;
|
|
11690
|
+
columnIndex = headerGroup.childIndexes[headerGroup.childIndexes.length - 1];
|
|
11691
|
+
const columnWidth = columnGroupRight - columnGroupLeft;
|
|
11692
|
+
let headerRightPadding;
|
|
11693
|
+
if (isPivotColumnHeaderGroup(headerGroup) && headerGroup.isKeyColumnGroup === true && theme.columnSourceFilterMinWidth != null) {
|
|
11694
|
+
if (isFilterBarShown) {
|
|
11695
|
+
headerRightPadding = Math.max(
|
|
11696
|
+
theme.columnSourceFilterMinWidth,
|
|
11697
|
+
columnWidth - metrics.columnSourceLabelWidth
|
|
11698
|
+
);
|
|
11699
|
+
} else {
|
|
11700
|
+
const { advancedFilters, quickFilters } = state;
|
|
11701
|
+
const { filterBarCollapsedHeight } = theme;
|
|
11702
|
+
if (advancedFilters.size > 0 || quickFilters.size > 0) {
|
|
11703
|
+
headerRightPadding = filterBarCollapsedHeight;
|
|
11704
|
+
}
|
|
11705
|
+
}
|
|
11471
11706
|
}
|
|
11707
|
+
const sort = jsapiUtils.TableUtils.getSortForColumn(model.sort, groupName);
|
|
11708
|
+
this.drawColumnHeader(
|
|
11709
|
+
context,
|
|
11710
|
+
state,
|
|
11711
|
+
model.textForColumnHeader(modelColumn, depth) ?? "",
|
|
11712
|
+
columnGroupLeft,
|
|
11713
|
+
columnWidth,
|
|
11714
|
+
{
|
|
11715
|
+
backgroundColor: columnGroupColor ?? void 0
|
|
11716
|
+
},
|
|
11717
|
+
bounds,
|
|
11718
|
+
isExpandable,
|
|
11719
|
+
isExpanded,
|
|
11720
|
+
sort,
|
|
11721
|
+
headerRightPadding
|
|
11722
|
+
);
|
|
11472
11723
|
}
|
|
11473
|
-
this.drawColumnHeader(
|
|
11474
|
-
context,
|
|
11475
|
-
state,
|
|
11476
|
-
model.textForColumnHeader(modelColumn, depth) ?? "",
|
|
11477
|
-
x,
|
|
11478
|
-
Math.min(columnGroupRight - columnGroupLeft, visibleWidth),
|
|
11479
|
-
{
|
|
11480
|
-
backgroundColor: columnGroupColor ?? void 0
|
|
11481
|
-
},
|
|
11482
|
-
bounds,
|
|
11483
|
-
isExpandable,
|
|
11484
|
-
isExpanded
|
|
11485
|
-
);
|
|
11486
11724
|
}
|
|
11487
11725
|
columnIndex += 1;
|
|
11488
11726
|
}
|
|
11489
11727
|
}
|
|
11490
11728
|
context.restore();
|
|
11491
11729
|
}
|
|
11492
|
-
drawColumnHeader(context, state, columnText, columnX, columnWidth, style, bounds, isExpandable = false, isExpanded = false) {
|
|
11730
|
+
drawColumnHeader(context, state, columnText, columnX, columnWidth, style, bounds, isExpandable = false, isExpanded = false, sort = null, headerRightPadding) {
|
|
11493
11731
|
if (columnWidth <= 0) {
|
|
11494
11732
|
return;
|
|
11495
11733
|
}
|
|
@@ -11505,7 +11743,7 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11505
11743
|
white
|
|
11506
11744
|
} = theme;
|
|
11507
11745
|
const { fontWidthsLower, fontWidthsUpper, width } = metrics;
|
|
11508
|
-
const
|
|
11746
|
+
const maxLabelWidth = columnWidth - headerHorizontalPadding * 2 - (headerRightPadding ?? 0);
|
|
11509
11747
|
const {
|
|
11510
11748
|
backgroundColor = headerBackgroundColor,
|
|
11511
11749
|
separatorColor = headerSeparatorColor
|
|
@@ -11551,7 +11789,7 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11551
11789
|
const renderText = this.textCellRenderer.getCachedTruncatedString(
|
|
11552
11790
|
context,
|
|
11553
11791
|
columnText,
|
|
11554
|
-
|
|
11792
|
+
maxLabelWidth,
|
|
11555
11793
|
fontWidthLower,
|
|
11556
11794
|
fontWidthUpper
|
|
11557
11795
|
);
|
|
@@ -11561,15 +11799,15 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11561
11799
|
maxX -= headerHorizontalPadding;
|
|
11562
11800
|
const treeMarkerPadding = isExpandable ? iconSize : 0;
|
|
11563
11801
|
const contentLeft = columnX + headerHorizontalPadding;
|
|
11564
|
-
const
|
|
11565
|
-
const contentRight = columnX + columnWidth - headerHorizontalPadding;
|
|
11566
|
-
const
|
|
11567
|
-
const
|
|
11802
|
+
const contentViewportLeft = lodash_clamp(contentLeft, minX, maxX);
|
|
11803
|
+
const contentRight = columnX + columnWidth - headerHorizontalPadding - (headerRightPadding ?? 0);
|
|
11804
|
+
const contentViewportRight = lodash_clamp(contentRight, minX, maxX);
|
|
11805
|
+
const contentViewportWidth = contentViewportRight - contentViewportLeft;
|
|
11568
11806
|
const textWidth = this.getCachedHeaderWidth(context, renderText);
|
|
11569
11807
|
const contentWidth = textWidth + treeMarkerPadding;
|
|
11570
11808
|
const isBeyondLeft = contentLeft < minX;
|
|
11571
11809
|
if (isBeyondLeft) {
|
|
11572
|
-
if (contentWidth <
|
|
11810
|
+
if (contentWidth < contentViewportWidth) {
|
|
11573
11811
|
x = minX;
|
|
11574
11812
|
} else {
|
|
11575
11813
|
x = contentRight - contentWidth;
|
|
@@ -11597,6 +11835,15 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11597
11835
|
isExpanded
|
|
11598
11836
|
);
|
|
11599
11837
|
}
|
|
11838
|
+
this.drawColumnSourceSortIndicator(
|
|
11839
|
+
context,
|
|
11840
|
+
state,
|
|
11841
|
+
sort,
|
|
11842
|
+
columnText,
|
|
11843
|
+
columnX,
|
|
11844
|
+
columnWidth,
|
|
11845
|
+
{ minX, maxX }
|
|
11846
|
+
);
|
|
11600
11847
|
context.restore();
|
|
11601
11848
|
}
|
|
11602
11849
|
drawColumnHeaderTreeMarker(context, state, columnX, columnWidth, headerY, headerHeight, treeBox, isExpanded) {
|
|
@@ -11624,39 +11871,287 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11624
11871
|
isExpanded
|
|
11625
11872
|
);
|
|
11626
11873
|
}
|
|
11874
|
+
drawColumnSourceSortIndicator(context, state, sort, columnText, columnX, columnWidth, bounds) {
|
|
11875
|
+
const { isFilterBarShown, metrics, theme, quickFilters, advancedFilters } = state;
|
|
11876
|
+
const { gridX, columnHeaderHeight, columnSourceLabelWidth } = metrics;
|
|
11877
|
+
const {
|
|
11878
|
+
iconSize: themeIconSize,
|
|
11879
|
+
columnSourceFilterMinWidth,
|
|
11880
|
+
filterBarCollapsedHeight
|
|
11881
|
+
} = theme;
|
|
11882
|
+
const iconSize = Math.round(themeIconSize * 0.75);
|
|
11883
|
+
if (sort == null) {
|
|
11884
|
+
return;
|
|
11885
|
+
}
|
|
11886
|
+
const icon = this.getSortIcon(sort, iconSize);
|
|
11887
|
+
if (!icon) {
|
|
11888
|
+
return;
|
|
11889
|
+
}
|
|
11890
|
+
if (columnSourceFilterMinWidth == null || columnSourceFilterMinWidth <= 0) {
|
|
11891
|
+
return;
|
|
11892
|
+
}
|
|
11893
|
+
const expandedFilterWidth = Math.max(
|
|
11894
|
+
columnWidth - columnSourceLabelWidth,
|
|
11895
|
+
columnSourceFilterMinWidth
|
|
11896
|
+
);
|
|
11897
|
+
const collapsedFilterWidth = advancedFilters.size > 0 || quickFilters.size > 0 ? filterBarCollapsedHeight : 0;
|
|
11898
|
+
const x = gridX + columnX + columnWidth - iconSize - (isFilterBarShown ? expandedFilterWidth : collapsedFilterWidth) - 1;
|
|
11899
|
+
const y = (columnHeaderHeight - iconSize) * 0.5;
|
|
11900
|
+
context.save();
|
|
11901
|
+
context.fillStyle = theme.headerSortBarColor;
|
|
11902
|
+
context.translate(x, y);
|
|
11903
|
+
context.fill(icon);
|
|
11904
|
+
context.restore();
|
|
11905
|
+
}
|
|
11906
|
+
drawColumnSourceFilters(context, state) {
|
|
11907
|
+
const { isFilterBarShown, quickFilters, advancedFilters } = state;
|
|
11908
|
+
if (isFilterBarShown) {
|
|
11909
|
+
this.drawExpandedColumnSourceFilters(context, state);
|
|
11910
|
+
} else if (quickFilters != null && quickFilters.size > 0 || advancedFilters != null && advancedFilters.size > 0) {
|
|
11911
|
+
this.drawCollapsedColumnSourceFilters(context, state);
|
|
11912
|
+
}
|
|
11913
|
+
}
|
|
11914
|
+
drawExpandedColumnSourceFilters(context, state) {
|
|
11915
|
+
const { model, metrics, theme, quickFilters, advancedFilters } = state;
|
|
11916
|
+
const { columnSourceFilterMinWidth } = theme;
|
|
11917
|
+
if (columnSourceFilterMinWidth == null || columnSourceFilterMinWidth <= 0) {
|
|
11918
|
+
return;
|
|
11919
|
+
}
|
|
11920
|
+
const { columnSourceLabelWidth } = metrics;
|
|
11921
|
+
const filterBoxes = getKeyColumnGroups(model).map((group) => {
|
|
11922
|
+
const coords = getColumnHeaderCoordinates(state, group);
|
|
11923
|
+
if (coords == null) {
|
|
11924
|
+
return null;
|
|
11925
|
+
}
|
|
11926
|
+
const { x1, y1, x2, y2 } = coords;
|
|
11927
|
+
const columnSourceFilterWidth = Math.max(
|
|
11928
|
+
x2 - x1 - columnSourceLabelWidth,
|
|
11929
|
+
columnSourceFilterMinWidth
|
|
11930
|
+
);
|
|
11931
|
+
return {
|
|
11932
|
+
depth: group.depth,
|
|
11933
|
+
x1: x2 - columnSourceFilterWidth,
|
|
11934
|
+
y1,
|
|
11935
|
+
x2,
|
|
11936
|
+
y2
|
|
11937
|
+
};
|
|
11938
|
+
}).filter(isNotNullOrUndefined);
|
|
11939
|
+
if (filterBoxes.length === 0) {
|
|
11940
|
+
return;
|
|
11941
|
+
}
|
|
11942
|
+
context.save();
|
|
11943
|
+
context.font = theme.filterBarFont;
|
|
11944
|
+
context.textAlign = "left";
|
|
11945
|
+
if (quickFilters != null && quickFilters.size > 0 || advancedFilters != null && advancedFilters.size > 0) {
|
|
11946
|
+
context.fillStyle = theme.filterBarExpandedActiveBackgroundColor;
|
|
11947
|
+
} else {
|
|
11948
|
+
context.fillStyle = theme.filterBarExpandedBackgroundColor;
|
|
11949
|
+
}
|
|
11950
|
+
context.fillRect(
|
|
11951
|
+
filterBoxes[0].x1,
|
|
11952
|
+
filterBoxes[filterBoxes.length - 1].y1,
|
|
11953
|
+
filterBoxes[0].x2 - filterBoxes[0].x1,
|
|
11954
|
+
filterBoxes[0].y2 - filterBoxes[filterBoxes.length - 1].y1
|
|
11955
|
+
);
|
|
11956
|
+
context.strokeStyle = theme.filterBarSeparatorColor;
|
|
11957
|
+
context.beginPath();
|
|
11958
|
+
filterBoxes.forEach(({ x1, y1, x2, y2 }) => {
|
|
11959
|
+
const w = x2 - x1;
|
|
11960
|
+
const h = y2 - y1;
|
|
11961
|
+
context.rect(x1 + 0.5, y1 + 0.5, w, h - 2);
|
|
11962
|
+
});
|
|
11963
|
+
context.stroke();
|
|
11964
|
+
filterBoxes.forEach(({ x1, x2, depth }) => {
|
|
11965
|
+
this.drawExpandedColumnSourceFilter(context, state, depth, x1, x2 - x1);
|
|
11966
|
+
});
|
|
11967
|
+
context.restore();
|
|
11968
|
+
}
|
|
11969
|
+
drawExpandedColumnSourceFilter(context, state, headerDepth, inputX, inputWidth) {
|
|
11970
|
+
if (inputWidth <= 0) {
|
|
11971
|
+
return;
|
|
11972
|
+
}
|
|
11973
|
+
const { metrics, theme, quickFilters, advancedFilters } = state;
|
|
11974
|
+
const {
|
|
11975
|
+
filterBarHeight,
|
|
11976
|
+
filterBarExpandedActiveCellBackgroundColor,
|
|
11977
|
+
filterBarErrorColor,
|
|
11978
|
+
filterBarHorizontalPadding,
|
|
11979
|
+
headerColor
|
|
11980
|
+
} = theme;
|
|
11981
|
+
const { columnHeaderHeight, gridY } = metrics;
|
|
11982
|
+
const filterIndex = -headerDepth;
|
|
11983
|
+
const quickFilter = quickFilters.get(filterIndex);
|
|
11984
|
+
const advancedFilter = advancedFilters.get(filterIndex);
|
|
11985
|
+
if (quickFilter == null && advancedFilter == null) {
|
|
11986
|
+
return;
|
|
11987
|
+
}
|
|
11988
|
+
let text = null;
|
|
11989
|
+
if (quickFilter != null) {
|
|
11990
|
+
const { text: filterText } = quickFilter;
|
|
11991
|
+
text = filterText;
|
|
11992
|
+
if (text == null || text === "") {
|
|
11993
|
+
text = jsapiUtils.TableUtils.getFilterText(quickFilter.filter);
|
|
11994
|
+
}
|
|
11995
|
+
if (text != null) {
|
|
11996
|
+
const { fontWidthsLower, fontWidthsUpper } = metrics;
|
|
11997
|
+
const fontWidthLower = fontWidthsLower.get(context.font);
|
|
11998
|
+
const fontWidthUpper = fontWidthsUpper.get(context.font);
|
|
11999
|
+
const maxLength = inputWidth - filterBarHorizontalPadding * 2;
|
|
12000
|
+
text = this.textCellRenderer.getCachedTruncatedString(
|
|
12001
|
+
context,
|
|
12002
|
+
text,
|
|
12003
|
+
maxLength,
|
|
12004
|
+
fontWidthLower,
|
|
12005
|
+
fontWidthUpper
|
|
12006
|
+
);
|
|
12007
|
+
}
|
|
12008
|
+
}
|
|
12009
|
+
const inputY = gridY - filterBarHeight - columnHeaderHeight - columnHeaderHeight * headerDepth;
|
|
12010
|
+
const isFilterValid = irisGrid.IrisGridRenderer.isFilterValid(
|
|
12011
|
+
advancedFilter,
|
|
12012
|
+
quickFilter
|
|
12013
|
+
);
|
|
12014
|
+
context.save();
|
|
12015
|
+
if (isFilterValid && filterBarExpandedActiveCellBackgroundColor != null) {
|
|
12016
|
+
context.fillStyle = filterBarExpandedActiveCellBackgroundColor;
|
|
12017
|
+
context.fillRect(
|
|
12018
|
+
inputX + 1,
|
|
12019
|
+
// +1 left border
|
|
12020
|
+
inputY + 1,
|
|
12021
|
+
// +1 top border
|
|
12022
|
+
inputWidth - 1,
|
|
12023
|
+
// -1 right border
|
|
12024
|
+
filterBarHeight - 3
|
|
12025
|
+
// -3 top, bottom border and bottom casing
|
|
12026
|
+
);
|
|
12027
|
+
} else if (filterBarErrorColor != null) {
|
|
12028
|
+
context.fillStyle = filterBarErrorColor;
|
|
12029
|
+
context.lineWidth = 2;
|
|
12030
|
+
context.strokeStyle = filterBarErrorColor;
|
|
12031
|
+
const rectLeft = inputX + 2;
|
|
12032
|
+
const rectTop = inputY + 2;
|
|
12033
|
+
const rectWidth = inputWidth - 3;
|
|
12034
|
+
const rectHeight = filterBarHeight - 5;
|
|
12035
|
+
context.strokeRect(rectLeft, rectTop, rectWidth, rectHeight);
|
|
12036
|
+
}
|
|
12037
|
+
if (text != null && text !== "") {
|
|
12038
|
+
const textX = inputX + filterBarHorizontalPadding;
|
|
12039
|
+
const textY = inputY + filterBarHeight * 0.5 + 1;
|
|
12040
|
+
context.fillStyle = headerColor;
|
|
12041
|
+
context.fillText(text, textX, textY);
|
|
12042
|
+
}
|
|
12043
|
+
context.restore();
|
|
12044
|
+
}
|
|
12045
|
+
drawCollapsedColumnSourceFilters(context, state) {
|
|
12046
|
+
const { metrics, model, theme } = state;
|
|
12047
|
+
const { gridX, gridY, columnHeaderHeight, columnHeaderMaxDepth } = metrics;
|
|
12048
|
+
const { headerSeparatorColor, filterBarCollapsedHeight } = theme;
|
|
12049
|
+
if (filterBarCollapsedHeight <= 0) {
|
|
12050
|
+
return;
|
|
12051
|
+
}
|
|
12052
|
+
const filterBoxes = getKeyColumnGroups(model).map((group) => {
|
|
12053
|
+
const coords = getColumnHeaderCoordinates(state, group);
|
|
12054
|
+
if (coords == null) {
|
|
12055
|
+
return null;
|
|
12056
|
+
}
|
|
12057
|
+
const { x2: x22, y1, y2 } = coords;
|
|
12058
|
+
return {
|
|
12059
|
+
depth: group.depth,
|
|
12060
|
+
x1: x22 - filterBarCollapsedHeight,
|
|
12061
|
+
y1,
|
|
12062
|
+
x2: x22,
|
|
12063
|
+
y2
|
|
12064
|
+
};
|
|
12065
|
+
}).filter(isNotNullOrUndefined);
|
|
12066
|
+
if (filterBoxes.length === 0) {
|
|
12067
|
+
return;
|
|
12068
|
+
}
|
|
12069
|
+
context.save();
|
|
12070
|
+
const { x2 } = filterBoxes[filterBoxes.length - 1];
|
|
12071
|
+
context.fillStyle = headerSeparatorColor;
|
|
12072
|
+
context.fillRect(
|
|
12073
|
+
gridX + x2 - filterBarCollapsedHeight,
|
|
12074
|
+
gridY - columnHeaderHeight * columnHeaderMaxDepth - filterBarCollapsedHeight,
|
|
12075
|
+
filterBarCollapsedHeight,
|
|
12076
|
+
columnHeaderHeight * (columnHeaderMaxDepth - 1)
|
|
12077
|
+
);
|
|
12078
|
+
filterBoxes.forEach(({ x2: columnRight, depth }) => {
|
|
12079
|
+
this.drawCollapsedColumnSourceFilter(context, state, depth, columnRight);
|
|
12080
|
+
});
|
|
12081
|
+
context.restore();
|
|
12082
|
+
}
|
|
12083
|
+
// eslint-disable-next-line class-methods-use-this
|
|
12084
|
+
drawCollapsedColumnSourceFilter(context, state, headerDepth, columnRight) {
|
|
12085
|
+
if (columnRight <= 0) {
|
|
12086
|
+
return;
|
|
12087
|
+
}
|
|
12088
|
+
const { metrics, theme, quickFilters, advancedFilters } = state;
|
|
12089
|
+
const { columnHeaderHeight, gridY } = metrics;
|
|
12090
|
+
const filterIndex = -headerDepth;
|
|
12091
|
+
const quickFilter = quickFilters.get(filterIndex);
|
|
12092
|
+
const advancedFilter = advancedFilters.get(filterIndex);
|
|
12093
|
+
const {
|
|
12094
|
+
filterBarCollapsedHeight,
|
|
12095
|
+
filterBarActiveColor,
|
|
12096
|
+
filterBarActiveBackgroundColor,
|
|
12097
|
+
filterBarErrorColor
|
|
12098
|
+
} = theme;
|
|
12099
|
+
context.save();
|
|
12100
|
+
const isFilterValid = irisGrid.IrisGridRenderer.isFilterValid(
|
|
12101
|
+
advancedFilter,
|
|
12102
|
+
quickFilter
|
|
12103
|
+
);
|
|
12104
|
+
if (filterBarActiveBackgroundColor != null && quickFilter == null && advancedFilter == null) {
|
|
12105
|
+
context.fillStyle = filterBarActiveBackgroundColor;
|
|
12106
|
+
} else if (filterBarActiveColor != null && isFilterValid) {
|
|
12107
|
+
context.fillStyle = filterBarActiveColor;
|
|
12108
|
+
} else if (filterBarErrorColor != null) {
|
|
12109
|
+
context.fillStyle = filterBarErrorColor;
|
|
12110
|
+
}
|
|
12111
|
+
const x = columnRight - filterBarCollapsedHeight + 1;
|
|
12112
|
+
const y = gridY - filterBarCollapsedHeight - columnHeaderHeight - columnHeaderHeight * headerDepth;
|
|
12113
|
+
const rectWidth = filterBarCollapsedHeight - 1;
|
|
12114
|
+
const rectHeight = columnHeaderHeight - 1;
|
|
12115
|
+
context.fillRect(x, y, rectWidth, rectHeight);
|
|
12116
|
+
context.restore();
|
|
12117
|
+
}
|
|
12118
|
+
}
|
|
12119
|
+
function usePivotRenderer() {
|
|
12120
|
+
return React.useMemo(() => new IrisGridPivotRenderer(), []);
|
|
11627
12121
|
}
|
|
11628
|
-
const
|
|
12122
|
+
const IrisGridPivotThemeColors = Object.freeze({
|
|
11629
12123
|
columnSourceHeaderBackground: "var(--dh-color-grid-bg)",
|
|
11630
12124
|
totalsHeaderBackground: "var(--dh-color-grid-bg)"
|
|
11631
12125
|
});
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
);
|
|
11641
|
-
const renderer = React.useMemo(() => new IrisGridPivotRenderer(), []);
|
|
12126
|
+
function getIrisGridPivotTheme() {
|
|
12127
|
+
return Object.freeze({
|
|
12128
|
+
...components.resolveCssVariablesInRecord(IrisGridPivotThemeColors),
|
|
12129
|
+
columnSourceFilterMinWidth: 120
|
|
12130
|
+
});
|
|
12131
|
+
}
|
|
12132
|
+
const log$1 = Log.module("@deephaven/js-plugin-pivot/usePivotTheme");
|
|
12133
|
+
function usePivotTheme() {
|
|
11642
12134
|
const theme = components.useTheme();
|
|
11643
|
-
|
|
11644
|
-
log$
|
|
11645
|
-
return
|
|
12135
|
+
return React.useMemo(() => {
|
|
12136
|
+
log$1.debug("Theme changed, updating pivot theme", theme);
|
|
12137
|
+
return getIrisGridPivotTheme();
|
|
11646
12138
|
}, [theme]);
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
}
|
|
11653
|
-
const pivot = new dh.coreplus.pivot.PivotTable(result);
|
|
11654
|
-
log$2.debug("Created pivot table:", pivot);
|
|
11655
|
-
return pivot;
|
|
11656
|
-
}),
|
|
11657
|
-
[dh, fetch]
|
|
12139
|
+
}
|
|
12140
|
+
function usePivotMetricCalculatorFactory() {
|
|
12141
|
+
return React.useMemo(
|
|
12142
|
+
() => (...args) => new IrisGridPivotMetricCalculator(...args),
|
|
12143
|
+
[]
|
|
11658
12144
|
);
|
|
11659
|
-
|
|
12145
|
+
}
|
|
12146
|
+
function PivotWidget({
|
|
12147
|
+
fetch
|
|
12148
|
+
}) {
|
|
12149
|
+
const pivotFetch = usePivotTableFetch(fetch);
|
|
12150
|
+
const mouseHandlers = usePivotMouseHandlers();
|
|
12151
|
+
const renderer = usePivotRenderer();
|
|
12152
|
+
const pivotTheme = usePivotTheme();
|
|
12153
|
+
const getPivotMetricCalculator = usePivotMetricCalculatorFactory();
|
|
12154
|
+
const fetchResult = useIrisGridPivotModel(pivotFetch);
|
|
11660
12155
|
if (fetchResult.status === "loading") {
|
|
11661
12156
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(components.LoadingOverlay, { isLoading: true });
|
|
11662
12157
|
}
|
|
@@ -11676,74 +12171,89 @@ function PivotWidget({
|
|
|
11676
12171
|
model,
|
|
11677
12172
|
mouseHandlers,
|
|
11678
12173
|
renderer,
|
|
11679
|
-
theme: pivotTheme
|
|
12174
|
+
theme: pivotTheme,
|
|
12175
|
+
getMetricCalculator: getPivotMetricCalculator
|
|
11680
12176
|
}
|
|
11681
12177
|
);
|
|
11682
12178
|
}
|
|
11683
|
-
const log
|
|
11684
|
-
function useHydratePivotGrid(
|
|
12179
|
+
const log = Log.module("@deephaven/js-plugin-pivot/useHydratePivotGrid");
|
|
12180
|
+
function useHydratePivotGrid(id, metadata) {
|
|
12181
|
+
assertNotNull(metadata, "Missing Pivot metadata");
|
|
12182
|
+
const objectFetch = jsapiBootstrap.useObjectFetch(metadata);
|
|
11685
12183
|
const api = jsapiBootstrap.useApi();
|
|
11686
12184
|
const loadPlugin = dashboardCorePlugins.useLoadTablePlugin();
|
|
11687
|
-
const
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
const
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
return components.resolveCssVariablesInRecord(IrisGridPivotTheme);
|
|
11708
|
-
}, [theme]);
|
|
11709
|
-
const hydratedProps = React.useMemo(
|
|
11710
|
-
() => ({
|
|
12185
|
+
const mouseHandlers = usePivotMouseHandlers();
|
|
12186
|
+
const renderer = usePivotRenderer();
|
|
12187
|
+
const theme = usePivotTheme();
|
|
12188
|
+
const getMetricCalculator = usePivotMetricCalculatorFactory();
|
|
12189
|
+
const { status } = objectFetch;
|
|
12190
|
+
if (status === "loading") {
|
|
12191
|
+
log.debug("Widget is loading");
|
|
12192
|
+
return { status: "loading" };
|
|
12193
|
+
}
|
|
12194
|
+
if (status === "error") {
|
|
12195
|
+
log.debug("Error fetching widget:", objectFetch.error);
|
|
12196
|
+
return {
|
|
12197
|
+
status: "error",
|
|
12198
|
+
error: objectFetch.error
|
|
12199
|
+
};
|
|
12200
|
+
}
|
|
12201
|
+
const { fetch } = objectFetch;
|
|
12202
|
+
return {
|
|
12203
|
+
status: "success",
|
|
12204
|
+
props: {
|
|
11711
12205
|
loadPlugin,
|
|
11712
12206
|
localDashboardId: id,
|
|
11713
|
-
makeModel: async ()
|
|
11714
|
-
|
|
11715
|
-
|
|
12207
|
+
makeModel: async function makeModel() {
|
|
12208
|
+
log.debug("Fetching pivot widget");
|
|
12209
|
+
const widget = await fetch();
|
|
12210
|
+
log.debug("Pivot fetch result:", widget);
|
|
12211
|
+
if (!isCorePlusDh(api)) {
|
|
12212
|
+
throw new Error("CorePlus is not available");
|
|
12213
|
+
}
|
|
12214
|
+
const pivotTable = new api.coreplus.pivot.PivotTable(widget);
|
|
12215
|
+
log.debug("Created pivot table:", pivotTable);
|
|
12216
|
+
return new IrisGridPivotModel(api, pivotTable);
|
|
11716
12217
|
},
|
|
11717
12218
|
metadata,
|
|
11718
12219
|
mouseHandlers,
|
|
11719
12220
|
renderer,
|
|
11720
|
-
theme
|
|
11721
|
-
|
|
11722
|
-
[
|
|
11723
|
-
api,
|
|
11724
|
-
fetchTable,
|
|
11725
|
-
id,
|
|
11726
|
-
loadPlugin,
|
|
11727
|
-
metadata,
|
|
11728
|
-
mouseHandlers,
|
|
11729
|
-
renderer,
|
|
11730
|
-
pivotTheme
|
|
11731
|
-
]
|
|
11732
|
-
);
|
|
11733
|
-
return hydratedProps;
|
|
11734
|
-
}
|
|
11735
|
-
function PivotPanel(props) {
|
|
11736
|
-
const { localDashboardId, fetch, metadata } = props;
|
|
11737
|
-
const hydratedProps = useHydratePivotGrid(fetch, localDashboardId, metadata);
|
|
11738
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11739
|
-
dashboardCorePlugins.IrisGridPanel,
|
|
11740
|
-
{
|
|
11741
|
-
...props,
|
|
11742
|
-
...hydratedProps
|
|
12221
|
+
theme,
|
|
12222
|
+
getMetricCalculator
|
|
11743
12223
|
}
|
|
11744
|
-
|
|
12224
|
+
};
|
|
11745
12225
|
}
|
|
11746
|
-
PivotPanel
|
|
12226
|
+
const PivotPanel = React.forwardRef(
|
|
12227
|
+
// Unconnected IrisGridPanel type is not exported from dashboard-core-plugins
|
|
12228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12229
|
+
(panelProps, ref) => {
|
|
12230
|
+
const { localDashboardId, metadata, panelState, ...props } = panelProps;
|
|
12231
|
+
const hydrateResult = useHydratePivotGrid(localDashboardId, metadata);
|
|
12232
|
+
if (hydrateResult.status === "loading") {
|
|
12233
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(components.LoadingOverlay, { isLoading: true });
|
|
12234
|
+
}
|
|
12235
|
+
if (hydrateResult.status === "error") {
|
|
12236
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
12237
|
+
components.LoadingOverlay,
|
|
12238
|
+
{
|
|
12239
|
+
errorMessage: getErrorMessage(hydrateResult.error),
|
|
12240
|
+
isLoading: false
|
|
12241
|
+
}
|
|
12242
|
+
);
|
|
12243
|
+
}
|
|
12244
|
+
const { props: hydratedProps } = hydrateResult;
|
|
12245
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
12246
|
+
dashboardCorePlugins.IrisGridPanel,
|
|
12247
|
+
{
|
|
12248
|
+
ref,
|
|
12249
|
+
...props,
|
|
12250
|
+
...hydratedProps,
|
|
12251
|
+
panelState
|
|
12252
|
+
}
|
|
12253
|
+
);
|
|
12254
|
+
}
|
|
12255
|
+
);
|
|
12256
|
+
PivotPanel.displayName = "PivotPanel";
|
|
11747
12257
|
const PivotPlugin = {
|
|
11748
12258
|
name: "@deephaven/js-plugin-pivot",
|
|
11749
12259
|
type: plugin.PluginType.WIDGET_PLUGIN,
|
|
@@ -11753,62 +12263,15 @@ const PivotPlugin = {
|
|
|
11753
12263
|
icon: icons.dhTable,
|
|
11754
12264
|
title: "Pivot Table"
|
|
11755
12265
|
};
|
|
11756
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
11757
|
-
let nanoid = (size = 21) => {
|
|
11758
|
-
let id = "";
|
|
11759
|
-
let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
|
|
11760
|
-
while (size--) {
|
|
11761
|
-
id += urlAlphabet[bytes[size] & 63];
|
|
11762
|
-
}
|
|
11763
|
-
return id;
|
|
11764
|
-
};
|
|
11765
12266
|
const VARIABLE_TYPE = "PivotTable";
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
dragEvent,
|
|
11775
|
-
fetch,
|
|
11776
|
-
metadata = {},
|
|
11777
|
-
panelId = nanoid(),
|
|
11778
|
-
widget
|
|
11779
|
-
}) => {
|
|
11780
|
-
const { name, type } = widget;
|
|
11781
|
-
if (type !== VARIABLE_TYPE) {
|
|
11782
|
-
return;
|
|
11783
|
-
}
|
|
11784
|
-
log.info("Panel opened of type", type);
|
|
11785
|
-
const config = {
|
|
11786
|
-
type: "react-component",
|
|
11787
|
-
component: PivotPanel.COMPONENT,
|
|
11788
|
-
props: {
|
|
11789
|
-
localDashboardId: id,
|
|
11790
|
-
id: panelId,
|
|
11791
|
-
metadata: {
|
|
11792
|
-
...metadata,
|
|
11793
|
-
...widget
|
|
11794
|
-
},
|
|
11795
|
-
fetch
|
|
11796
|
-
},
|
|
11797
|
-
title: name ?? void 0,
|
|
11798
|
-
id: panelId
|
|
11799
|
-
};
|
|
11800
|
-
const { root: root2 } = layout;
|
|
11801
|
-
dashboard.LayoutUtils.openComponent({ root: root2, config, dragEvent });
|
|
11802
|
-
},
|
|
11803
|
-
[id, layout]
|
|
11804
|
-
);
|
|
11805
|
-
React.useEffect(() => {
|
|
11806
|
-
const cleanups = [registerComponent(PivotPanel.COMPONENT, PivotPanel)];
|
|
11807
|
-
return () => {
|
|
11808
|
-
cleanups.forEach((cleanup) => cleanup());
|
|
11809
|
-
};
|
|
11810
|
-
}, [registerComponent]);
|
|
11811
|
-
dashboard.useListener(layout.eventHub, "PanelEvent.OPEN", handlePanelOpen);
|
|
12267
|
+
function DashboardPlugin(dashboardProps) {
|
|
12268
|
+
assertNotNull(PivotPanel.displayName);
|
|
12269
|
+
dashboard.useDashboardPanel({
|
|
12270
|
+
dashboardProps,
|
|
12271
|
+
componentName: PivotPanel.displayName,
|
|
12272
|
+
supportedTypes: VARIABLE_TYPE,
|
|
12273
|
+
component: PivotPanel
|
|
12274
|
+
});
|
|
11812
12275
|
return null;
|
|
11813
12276
|
}
|
|
11814
12277
|
exports.DashboardPlugin = DashboardPlugin;
|