@deephaven/js-plugin-pivot 0.0.3-dev.984 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +82 -75
- package/package.json +11 -6
package/dist/index.js
CHANGED
|
@@ -9920,10 +9920,10 @@ _defineProperty(GridRenderer, "getCachedColorWithAlpha", memoizeClear$1(GridColo
|
|
|
9920
9920
|
_defineProperty(GridRenderer, "getCachedColorIsDark", memoizeClear$1(ColorUtils$1.isDark, {
|
|
9921
9921
|
max: 1e3
|
|
9922
9922
|
}));
|
|
9923
|
-
function
|
|
9924
|
-
return group instanceof
|
|
9923
|
+
function isPivotColumnHeaderGroup(group) {
|
|
9924
|
+
return group instanceof PivotColumnHeaderGroup;
|
|
9925
9925
|
}
|
|
9926
|
-
class
|
|
9926
|
+
class PivotColumnHeaderGroup extends irisGrid.ColumnHeaderGroup {
|
|
9927
9927
|
constructor({
|
|
9928
9928
|
name,
|
|
9929
9929
|
displayName,
|
|
@@ -10022,10 +10022,10 @@ function makeGrandTotalColumnName(valueSource) {
|
|
|
10022
10022
|
return `__GRAND_TOTAL/${valueSource.name}`;
|
|
10023
10023
|
}
|
|
10024
10024
|
function makeColumnName(keys2, depth) {
|
|
10025
|
-
return keys2.slice(0, depth + 1).filter((k) => k != null).join("/");
|
|
10025
|
+
return keys2.slice(0, depth + 1).filter((k) => k != null).map((k) => encodeURIComponent(String(k))).join("/");
|
|
10026
10026
|
}
|
|
10027
10027
|
function makeColumnGroupName(keys2, columnSources, depth) {
|
|
10028
|
-
return keys2.slice(0, depth + 1).map((k, i) => k == null ? columnSources[i].name : k).join("/");
|
|
10028
|
+
return keys2.slice(0, depth + 1).map((k, i) => k == null ? columnSources[i].name : k).map((k) => encodeURIComponent(String(k))).join("/");
|
|
10029
10029
|
}
|
|
10030
10030
|
function makeValueSourceColumnName(columnName, valueSource) {
|
|
10031
10031
|
return `${columnName}/${valueSource.name}`;
|
|
@@ -10072,11 +10072,11 @@ function checkColumnsChanged(prevColumns, newColumns) {
|
|
|
10072
10072
|
}
|
|
10073
10073
|
function getKeyColumnGroups(columnSources, rowSources) {
|
|
10074
10074
|
const groups = columnSources.length === 0 ? [
|
|
10075
|
-
new
|
|
10076
|
-
|
|
10077
|
-
name: "__All",
|
|
10075
|
+
new PivotColumnHeaderGroup({
|
|
10076
|
+
name: "/",
|
|
10078
10077
|
displayName: "",
|
|
10079
|
-
//
|
|
10078
|
+
// For empty row sources we will render a "dead column"
|
|
10079
|
+
// or a Groups column, depending on the table settings
|
|
10080
10080
|
children: rowSources.map((c) => c.name),
|
|
10081
10081
|
childIndexes: [],
|
|
10082
10082
|
isKeyColumnGroup: true,
|
|
@@ -10084,7 +10084,7 @@ function getKeyColumnGroups(columnSources, rowSources) {
|
|
|
10084
10084
|
isExpandable: false
|
|
10085
10085
|
})
|
|
10086
10086
|
] : columnSources.map(
|
|
10087
|
-
(source, i) => new
|
|
10087
|
+
(source, i) => new PivotColumnHeaderGroup({
|
|
10088
10088
|
name: source.name,
|
|
10089
10089
|
displayName: source.name,
|
|
10090
10090
|
children: i === columnSources.length - 1 ? rowSources.map((c) => c.name) : [columnSources[i + 1].name],
|
|
@@ -10102,20 +10102,15 @@ function getKeyColumnGroups(columnSources, rowSources) {
|
|
|
10102
10102
|
function getTotalsColumnGroups(columnSources, valueSources, isRootColumnExpanded) {
|
|
10103
10103
|
const groupName = pluralize(valueSources.length, GRAND_TOTALS_GROUP_NAME);
|
|
10104
10104
|
return columnSources.length === 0 ? [
|
|
10105
|
-
new
|
|
10106
|
-
|
|
10107
|
-
name: "TMP__GrandTotals",
|
|
10105
|
+
new PivotColumnHeaderGroup({
|
|
10106
|
+
name: "/GrandTotals",
|
|
10108
10107
|
displayName: groupName,
|
|
10109
10108
|
children: valueSources.map((v) => makeGrandTotalColumnName(v)),
|
|
10110
10109
|
childIndexes: [],
|
|
10111
10110
|
depth: 1
|
|
10112
|
-
// Only the top level is expandable
|
|
10113
|
-
// TODO:
|
|
10114
|
-
// isExpandable: i === 0,
|
|
10115
|
-
// isExpanded: isRootColumnExpanded,
|
|
10116
10111
|
})
|
|
10117
10112
|
] : columnSources.map(
|
|
10118
|
-
(source, i) => new
|
|
10113
|
+
(source, i) => new PivotColumnHeaderGroup({
|
|
10119
10114
|
name: makeGrandTotalColumnName(source),
|
|
10120
10115
|
displayName: i === 0 ? groupName : "",
|
|
10121
10116
|
children: i === columnSources.length - 1 ? valueSources.map((v) => makeGrandTotalColumnName(v)) : [makeGrandTotalColumnName(columnSources[i + 1])],
|
|
@@ -10141,7 +10136,7 @@ function getSnapshotColumnGroups(snapshotColumns, columnSources, valueSources, f
|
|
|
10141
10136
|
const isTotalGroup = keys2[i] == null;
|
|
10142
10137
|
const parentKey = i > 0 ? keys2[i - 1] : null;
|
|
10143
10138
|
const totalsGroupDisplayName = parentKey == null ? "" : groupName;
|
|
10144
|
-
const group = groupMap.get(name) ?? new
|
|
10139
|
+
const group = groupMap.get(name) ?? new PivotColumnHeaderGroup({
|
|
10145
10140
|
name,
|
|
10146
10141
|
displayName: isTotalGroup ? totalsGroupDisplayName : keys2[i],
|
|
10147
10142
|
isTotalGroup,
|
|
@@ -10189,6 +10184,9 @@ const SET_VIEWPORT_THROTTLE = 150;
|
|
|
10189
10184
|
const APPLY_VIEWPORT_THROTTLE = 0;
|
|
10190
10185
|
const ROW_BUFFER_PAGES = 1;
|
|
10191
10186
|
const COLUMN_BUFFER_PAGES = 1;
|
|
10187
|
+
function isIrisGridPivotModel(model) {
|
|
10188
|
+
return typeof model === "object" && model !== null && "pivotTable" in model && "keyColumns" in model && "expandAll" in model && "collapseAll" in model && "hasExpandableRows" in model && "hasExpandableColumns" in model;
|
|
10189
|
+
}
|
|
10192
10190
|
class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
10193
10191
|
constructor(dh, pivotTable, formatter = new jsapiUtils.Formatter(dh), config = {}) {
|
|
10194
10192
|
if (!isCorePlusDh(dh)) {
|
|
@@ -10484,27 +10482,6 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10484
10482
|
async export() {
|
|
10485
10483
|
throw new Error("Method not implemented.");
|
|
10486
10484
|
}
|
|
10487
|
-
async showFilter() {
|
|
10488
|
-
throw new Error("Method not implemented.");
|
|
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.");
|
|
10498
|
-
}
|
|
10499
|
-
async clearFilter() {
|
|
10500
|
-
throw new Error("Method not implemented.");
|
|
10501
|
-
}
|
|
10502
|
-
async applyFilter() {
|
|
10503
|
-
throw new Error("Method not implemented.");
|
|
10504
|
-
}
|
|
10505
|
-
async copy() {
|
|
10506
|
-
throw new Error("Method not implemented.");
|
|
10507
|
-
}
|
|
10508
10485
|
get totalsColumns() {
|
|
10509
10486
|
return this.getCachedTotalsColumns(
|
|
10510
10487
|
this.pivotTable,
|
|
@@ -10554,7 +10531,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10554
10531
|
} = irisGrid.IrisGridUtils.parseColumnHeaderGroups(
|
|
10555
10532
|
this,
|
|
10556
10533
|
groups,
|
|
10557
|
-
(args) => new
|
|
10534
|
+
(args) => new PivotColumnHeaderGroup(args)
|
|
10558
10535
|
);
|
|
10559
10536
|
this._columnHeaderGroups = newGroups;
|
|
10560
10537
|
this.columnHeaderMaxDepth = maxDepth;
|
|
@@ -10569,14 +10546,14 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10569
10546
|
}
|
|
10570
10547
|
textForColumnHeader(x, depth = 0) {
|
|
10571
10548
|
const header = this.columnAtDepth(x, depth);
|
|
10572
|
-
if (
|
|
10549
|
+
if (isPivotColumnHeaderGroup(header)) {
|
|
10573
10550
|
return header.isNew ? "" : header.displayName ?? header.name;
|
|
10574
10551
|
}
|
|
10575
10552
|
return (header == null ? void 0 : header.displayName) ?? (header == null ? void 0 : header.name);
|
|
10576
10553
|
}
|
|
10577
10554
|
colorForColumnHeader(x, depth = 0, theme = {}) {
|
|
10578
10555
|
const column = this.columnAtDepth(x, depth);
|
|
10579
|
-
if (
|
|
10556
|
+
if (isPivotColumnHeaderGroup(column)) {
|
|
10580
10557
|
if (column.isTotalGroup != null && column.isTotalGroup) {
|
|
10581
10558
|
return theme.totalsHeaderBackground ?? null;
|
|
10582
10559
|
}
|
|
@@ -10588,7 +10565,7 @@ class IrisGridPivotModel extends irisGrid.IrisGridModel {
|
|
|
10588
10565
|
}
|
|
10589
10566
|
getColumnHeaderGroup(modelIndex, depth) {
|
|
10590
10567
|
const group = this.columnAtDepth(modelIndex, depth);
|
|
10591
|
-
if (
|
|
10568
|
+
if (isPivotColumnHeaderGroup(group)) {
|
|
10592
10569
|
return group;
|
|
10593
10570
|
}
|
|
10594
10571
|
return void 0;
|
|
@@ -11233,6 +11210,26 @@ class PivotColumnGroupMouseHandler extends GridMouseHandler {
|
|
|
11233
11210
|
}
|
|
11234
11211
|
return null;
|
|
11235
11212
|
}
|
|
11213
|
+
setCursor(gridPoint, grid) {
|
|
11214
|
+
const { column, columnHeaderDepth } = gridPoint;
|
|
11215
|
+
if (this.isExpandableColumnGroup(column, columnHeaderDepth)) {
|
|
11216
|
+
this.cursor = "pointer";
|
|
11217
|
+
return { stopPropagation: false, preventDefault: false };
|
|
11218
|
+
}
|
|
11219
|
+
this.cursor = null;
|
|
11220
|
+
return false;
|
|
11221
|
+
}
|
|
11222
|
+
isExpandableColumnGroup(column, columnHeaderDepth = 0) {
|
|
11223
|
+
const { model } = this.irisGrid.props;
|
|
11224
|
+
if (column == null || model == null) {
|
|
11225
|
+
return false;
|
|
11226
|
+
}
|
|
11227
|
+
const group = model.getColumnHeaderGroup(column, columnHeaderDepth);
|
|
11228
|
+
return group != null && isPivotColumnHeaderGroup(group) && group.isExpandable;
|
|
11229
|
+
}
|
|
11230
|
+
onMove(gridPoint, grid) {
|
|
11231
|
+
return this.setCursor(gridPoint, grid);
|
|
11232
|
+
}
|
|
11236
11233
|
// We need to remember where the down started, because the canvas element will trigger a click wherever mouseUp is
|
|
11237
11234
|
onDown(gridPoint) {
|
|
11238
11235
|
this.column = this.getColumnGroupFromGridPoint(gridPoint);
|
|
@@ -11240,7 +11237,7 @@ class PivotColumnGroupMouseHandler extends GridMouseHandler {
|
|
|
11240
11237
|
}
|
|
11241
11238
|
onClick(gridPoint, grid, event) {
|
|
11242
11239
|
const column = this.getColumnGroupFromGridPoint(gridPoint);
|
|
11243
|
-
if (column != null && column === this.column) {
|
|
11240
|
+
if (column != null && column === this.column && this.isExpandableColumnGroup(column, gridPoint.columnHeaderDepth)) {
|
|
11244
11241
|
this.irisGrid.toggleExpandColumn(column);
|
|
11245
11242
|
return true;
|
|
11246
11243
|
}
|
|
@@ -11399,6 +11396,9 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11399
11396
|
}
|
|
11400
11397
|
drawColumnHeadersAtDepth(context, state, range, bounds, depth) {
|
|
11401
11398
|
const { metrics, model, theme } = state;
|
|
11399
|
+
if (!isIrisGridPivotModel(model)) {
|
|
11400
|
+
throw new Error("Unsupported model type");
|
|
11401
|
+
}
|
|
11402
11402
|
const {
|
|
11403
11403
|
modelColumns,
|
|
11404
11404
|
allColumnXs,
|
|
@@ -11432,10 +11432,14 @@ class IrisGridPivotRenderer extends irisGrid.IrisGridRenderer {
|
|
|
11432
11432
|
while (columnIndex <= endIndex) {
|
|
11433
11433
|
const { columnCount } = metrics;
|
|
11434
11434
|
const modelColumn = getOrThrow(modelColumns, columnIndex);
|
|
11435
|
-
const columnGroupColor =
|
|
11435
|
+
const columnGroupColor = model.colorForColumnHeader(
|
|
11436
|
+
modelColumn,
|
|
11437
|
+
depth,
|
|
11438
|
+
theme
|
|
11439
|
+
);
|
|
11436
11440
|
const headerGroup = model.getColumnHeaderGroup(modelColumn, depth ?? 0);
|
|
11437
|
-
const isExpandable =
|
|
11438
|
-
const isExpanded =
|
|
11441
|
+
const isExpandable = isPivotColumnHeaderGroup(headerGroup) && headerGroup.isExpandable;
|
|
11442
|
+
const isExpanded = isPivotColumnHeaderGroup(headerGroup) && headerGroup.isExpanded;
|
|
11439
11443
|
const columnGroupName = getColumnGroupName(model, modelColumn, depth);
|
|
11440
11444
|
let columnGroupLeft = getOrThrow(allColumnXs, columnIndex) + gridX;
|
|
11441
11445
|
let columnGroupRight = columnGroupLeft + getOrThrow(allColumnWidths, columnIndex);
|
|
@@ -11686,7 +11690,7 @@ function useHydratePivotGrid(fetch, id, metadata) {
|
|
|
11686
11690
|
const loadPlugin = dashboardCorePlugins.useLoadTablePlugin();
|
|
11687
11691
|
const fetchTable = React.useCallback(
|
|
11688
11692
|
() => fetch().then((result) => {
|
|
11689
|
-
log$1.debug("
|
|
11693
|
+
log$1.debug("Pivot fetch result:", result);
|
|
11690
11694
|
if (!isCorePlusDh(api)) {
|
|
11691
11695
|
throw new Error("CorePlus is not available");
|
|
11692
11696
|
}
|
|
@@ -11716,34 +11720,36 @@ function useHydratePivotGrid(fetch, id, metadata) {
|
|
|
11716
11720
|
},
|
|
11717
11721
|
metadata,
|
|
11718
11722
|
mouseHandlers,
|
|
11719
|
-
renderer
|
|
11720
|
-
theme: pivotTheme
|
|
11723
|
+
renderer
|
|
11721
11724
|
}),
|
|
11722
|
-
[
|
|
11723
|
-
api,
|
|
11724
|
-
fetchTable,
|
|
11725
|
-
id,
|
|
11726
|
-
loadPlugin,
|
|
11727
|
-
metadata,
|
|
11728
|
-
mouseHandlers,
|
|
11729
|
-
renderer,
|
|
11730
|
-
pivotTheme
|
|
11731
|
-
]
|
|
11725
|
+
[api, fetchTable, id, loadPlugin, metadata, mouseHandlers, renderer]
|
|
11732
11726
|
);
|
|
11733
|
-
|
|
11734
|
-
}
|
|
11735
|
-
|
|
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
|
|
11743
|
-
}
|
|
11727
|
+
const hydratedPropsWithTheme = React.useMemo(
|
|
11728
|
+
() => ({ ...hydratedProps, theme: pivotTheme }),
|
|
11729
|
+
[hydratedProps, pivotTheme]
|
|
11744
11730
|
);
|
|
11731
|
+
return hydratedPropsWithTheme;
|
|
11745
11732
|
}
|
|
11746
|
-
PivotPanel
|
|
11733
|
+
const PivotPanel = React.forwardRef(
|
|
11734
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11735
|
+
(props, ref) => {
|
|
11736
|
+
const { localDashboardId, fetch, metadata } = props;
|
|
11737
|
+
const hydratedProps = useHydratePivotGrid(
|
|
11738
|
+
fetch,
|
|
11739
|
+
localDashboardId,
|
|
11740
|
+
metadata
|
|
11741
|
+
);
|
|
11742
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11743
|
+
dashboardCorePlugins.IrisGridPanel,
|
|
11744
|
+
{
|
|
11745
|
+
ref,
|
|
11746
|
+
...props,
|
|
11747
|
+
...hydratedProps
|
|
11748
|
+
}
|
|
11749
|
+
);
|
|
11750
|
+
}
|
|
11751
|
+
);
|
|
11752
|
+
PivotPanel.displayName = "PivotPanel";
|
|
11747
11753
|
const PivotPlugin = {
|
|
11748
11754
|
name: "@deephaven/js-plugin-pivot",
|
|
11749
11755
|
type: plugin.PluginType.WIDGET_PLUGIN,
|
|
@@ -11784,7 +11790,7 @@ function DashboardPlugin({
|
|
|
11784
11790
|
log.info("Panel opened of type", type);
|
|
11785
11791
|
const config = {
|
|
11786
11792
|
type: "react-component",
|
|
11787
|
-
component: PivotPanel.
|
|
11793
|
+
component: PivotPanel.displayName,
|
|
11788
11794
|
props: {
|
|
11789
11795
|
localDashboardId: id,
|
|
11790
11796
|
id: panelId,
|
|
@@ -11803,7 +11809,8 @@ function DashboardPlugin({
|
|
|
11803
11809
|
[id, layout]
|
|
11804
11810
|
);
|
|
11805
11811
|
React.useEffect(() => {
|
|
11806
|
-
|
|
11812
|
+
assertNotNull(PivotPanel.displayName);
|
|
11813
|
+
const cleanups = [registerComponent(PivotPanel.displayName, PivotPanel)];
|
|
11807
11814
|
return () => {
|
|
11808
11815
|
cleanups.forEach((cleanup) => cleanup());
|
|
11809
11816
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/js-plugin-pivot",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pivot plugin for Deephaven",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Deephaven",
|
|
7
|
-
"plugin"
|
|
7
|
+
"plugin",
|
|
8
|
+
"deephaven-js-plugin",
|
|
9
|
+
"pivot"
|
|
8
10
|
],
|
|
9
|
-
"author": "Deephaven Data Labs",
|
|
11
|
+
"author": "Deephaven Data Labs LLC",
|
|
10
12
|
"license": "Apache-2.0",
|
|
11
13
|
"main": "dist/index.js",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/deephaven/deephaven-plugins"
|
|
17
|
+
},
|
|
12
18
|
"scripts": {
|
|
13
19
|
"start": "vite build --watch",
|
|
14
20
|
"build": "vite build"
|
|
@@ -48,11 +54,10 @@
|
|
|
48
54
|
"nanoid": "^5.1.5"
|
|
49
55
|
},
|
|
50
56
|
"publishConfig": {
|
|
51
|
-
"access": "public"
|
|
52
|
-
"provenance": false
|
|
57
|
+
"access": "public"
|
|
53
58
|
},
|
|
54
59
|
"files": [
|
|
55
60
|
"dist/index.js"
|
|
56
61
|
],
|
|
57
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "457bb8bac2d812477ce1907e642b310c854a4e7e"
|
|
58
63
|
}
|