@infinite-table/infinite-react 0.5.0 → 0.5.2
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/README.md +104 -0
- package/index.css +896 -0
- package/index.d.ts +2264 -0
- package/index.esm.css +896 -0
- package/index.esm.js +15404 -0
- package/index.js +15240 -0
- package/package.json +9 -94
- package/.vscode/settings.json +0 -3
- package/API.md +0 -0
- package/build/buildPackageJson.js +0 -43
- package/build/scripts/test.js +0 -37
- package/bundler.config.js +0 -25
- package/globals.d.ts +0 -7
- package/rollup.config.js +0 -15
- package/run-build-deepmap.js +0 -47
- package/run-build.js +0 -45
- package/run-dts-concat.js +0 -21
- package/src/components/CSSVariableWatch.tsx +0 -82
- package/src/components/DataSource/BooleanCollectionState.ts +0 -214
- package/src/components/DataSource/BooleanDeepCollectionState.ts +0 -208
- package/src/components/DataSource/DataSourceContext.ts +0 -20
- package/src/components/DataSource/GroupRowsState.ts +0 -74
- package/src/components/DataSource/Indexer.ts +0 -27
- package/src/components/DataSource/RowSelectionState.ts +0 -763
- package/src/components/DataSource/defaultFilterTypes.ts +0 -64
- package/src/components/DataSource/index.tsx +0 -108
- package/src/components/DataSource/privateHooks/getChangeDetect.ts +0 -7
- package/src/components/DataSource/privateHooks/useLoadData.ts +0 -783
- package/src/components/DataSource/publicHooks/useDataSource.ts +0 -19
- package/src/components/DataSource/publicHooks/useDataSourceActions.ts +0 -14
- package/src/components/DataSource/state/getInitialState.ts +0 -494
- package/src/components/DataSource/state/normalizeSortInfo.ts +0 -35
- package/src/components/DataSource/state/reducer.ts +0 -466
- package/src/components/DataSource/state/rowInfoStatus.ts +0 -27
- package/src/components/DataSource/types.ts +0 -548
- package/src/components/HeadlessTable/HeadlessTableWithPinnedContainers.tsx +0 -142
- package/src/components/HeadlessTable/MappedCells.ts +0 -251
- package/src/components/HeadlessTable/RawTable.tsx +0 -98
- package/src/components/HeadlessTable/ReactHeadlessTableRenderer.tsx +0 -1516
- package/src/components/HeadlessTable/index.tsx +0 -234
- package/src/components/InfiniteTable/InfiniteCls.css.ts +0 -164
- package/src/components/InfiniteTable/InfiniteTableContext.ts +0 -16
- package/src/components/InfiniteTable/api/getImperativeApi.ts +0 -391
- package/src/components/InfiniteTable/api/getSelectionApi.ts +0 -364
- package/src/components/InfiniteTable/api/type.ts +0 -11
- package/src/components/InfiniteTable/components/ActiveCellIndicator.css.ts +0 -51
- package/src/components/InfiniteTable/components/ActiveCellIndicator.tsx +0 -116
- package/src/components/InfiniteTable/components/ActiveRowIndicator.css.ts +0 -56
- package/src/components/InfiniteTable/components/ActiveRowIndicator.tsx +0 -94
- package/src/components/InfiniteTable/components/CheckBox.css.ts +0 -13
- package/src/components/InfiniteTable/components/CheckBox.tsx +0 -96
- package/src/components/InfiniteTable/components/FilterEditors.tsx +0 -52
- package/src/components/InfiniteTable/components/InfiniteTableBody/InfiniteTableBody.tsx +0 -27
- package/src/components/InfiniteTable/components/InfiniteTableBody/index.tsx +0 -1
- package/src/components/InfiniteTable/components/InfiniteTableFooter/InfiniteTableFooter.tsx +0 -31
- package/src/components/InfiniteTable/components/InfiniteTableFooter/index.tsx +0 -1
- package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableColumnHeaderFilter.tsx +0 -102
- package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx +0 -163
- package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx +0 -574
- package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderGroup.tsx +0 -79
- package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderTypes.tsx +0 -25
- package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderWrapper.tsx +0 -185
- package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/GroupResizeHandle.tsx +0 -159
- package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/ResizeHandle.css.ts +0 -124
- package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/columnResizer.ts +0 -166
- package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/index.tsx +0 -146
- package/src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts +0 -240
- package/src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts +0 -358
- package/src/components/InfiniteTable/components/InfiniteTableHeader/index.tsx +0 -1
- package/src/components/InfiniteTable/components/InfiniteTableHeader/useColumnGroupResizeHandle.tsx +0 -114
- package/src/components/InfiniteTable/components/InfiniteTableHeader/useColumnResizeHandle.tsx +0 -146
- package/src/components/InfiniteTable/components/InfiniteTableLicenseFooter/footer.css.ts +0 -7
- package/src/components/InfiniteTable/components/InfiniteTableLicenseFooter/index.tsx +0 -110
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx +0 -120
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCellTypes.ts +0 -74
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableColumnCell.tsx +0 -457
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRow.tsx +0 -107
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowClassName.ts +0 -6
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowTypes.ts +0 -32
- package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowUnvirtualized.tsx +0 -75
- package/src/components/InfiniteTable/components/InfiniteTableRow/columnRendering.tsx +0 -263
- package/src/components/InfiniteTable/components/InfiniteTableRow/index.tsx +0 -1
- package/src/components/InfiniteTable/components/InfiniteTableRow/row.css.ts +0 -74
- package/src/components/InfiniteTable/components/InfiniteTableRow/useRowDOMProps.ts +0 -199
- package/src/components/InfiniteTable/components/LoadMask.css.ts +0 -34
- package/src/components/InfiniteTable/components/LoadMask.tsx +0 -27
- package/src/components/InfiniteTable/components/ScrollbarPlaceholder.tsx +0 -56
- package/src/components/InfiniteTable/components/cell.css.ts +0 -192
- package/src/components/InfiniteTable/components/icons/ArrowDown.tsx +0 -14
- package/src/components/InfiniteTable/components/icons/ArrowUp.tsx +0 -14
- package/src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts +0 -31
- package/src/components/InfiniteTable/components/icons/ExpanderIcon.tsx +0 -63
- package/src/components/InfiniteTable/components/icons/Icon.tsx +0 -18
- package/src/components/InfiniteTable/components/icons/InfiniteTableIconClassName.ts +0 -1
- package/src/components/InfiniteTable/components/icons/LoadingIcon.css.ts +0 -8
- package/src/components/InfiniteTable/components/icons/LoadingIcon.tsx +0 -45
- package/src/components/InfiniteTable/components/icons/MenuIcon.tsx +0 -50
- package/src/components/InfiniteTable/components/icons/SortIcon.tsx +0 -113
- package/src/components/InfiniteTable/eventHandlers/eventHandlerTypes.ts +0 -57
- package/src/components/InfiniteTable/eventHandlers/index.ts +0 -95
- package/src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts +0 -232
- package/src/components/InfiniteTable/eventHandlers/keyboardSelection.ts +0 -110
- package/src/components/InfiniteTable/eventHandlers/onCellClick.ts +0 -94
- package/src/components/InfiniteTable/eventHandlers/onKeyDown.ts +0 -25
- package/src/components/InfiniteTable/hooks/adjustColumnOrderForAllColumns.ts +0 -70
- package/src/components/InfiniteTable/hooks/reorderColumnsOnDrag.ts +0 -476
- package/src/components/InfiniteTable/hooks/useAutoSizeColumns.ts +0 -206
- package/src/components/InfiniteTable/hooks/useCellClassName.ts +0 -80
- package/src/components/InfiniteTable/hooks/useCellRendering.tsx +0 -217
- package/src/components/InfiniteTable/hooks/useColumnGroups.ts +0 -71
- package/src/components/InfiniteTable/hooks/useColumnMenu.ts +0 -72
- package/src/components/InfiniteTable/hooks/useColumnPointerEvents.ts +0 -258
- package/src/components/InfiniteTable/hooks/useColumnRowspan.ts +0 -43
- package/src/components/InfiniteTable/hooks/useColumnSizeFn.ts +0 -24
- package/src/components/InfiniteTable/hooks/useColumnsWhen.ts +0 -582
- package/src/components/InfiniteTable/hooks/useComputed.ts +0 -186
- package/src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts +0 -219
- package/src/components/InfiniteTable/hooks/useDOMProps.ts +0 -306
- package/src/components/InfiniteTable/hooks/useEffectWithRaf.ts +0 -47
- package/src/components/InfiniteTable/hooks/useInfiniteTable.ts +0 -10
- package/src/components/InfiniteTable/hooks/useInfiniteTableState.ts +0 -11
- package/src/components/InfiniteTable/hooks/useInternalProps.ts +0 -8
- package/src/components/InfiniteTable/hooks/useLicense/LicenseDetails.ts +0 -13
- package/src/components/InfiniteTable/hooks/useLicense/crc32.ts +0 -56
- package/src/components/InfiniteTable/hooks/useLicense/decode.ts +0 -147
- package/src/components/InfiniteTable/hooks/useLicense/useLicense.ts +0 -39
- package/src/components/InfiniteTable/hooks/useRerenderOnKeyChange.ts +0 -21
- package/src/components/InfiniteTable/hooks/useRowHover.ts +0 -18
- package/src/components/InfiniteTable/hooks/useScrollToActiveCell.ts +0 -48
- package/src/components/InfiniteTable/hooks/useScrollToActiveRow.ts +0 -44
- package/src/components/InfiniteTable/hooks/useScrollbars.ts +0 -51
- package/src/components/InfiniteTable/hooks/useToggleGroupRow.ts +0 -56
- package/src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx +0 -165
- package/src/components/InfiniteTable/hooks/useYourBrain.ts +0 -55
- package/src/components/InfiniteTable/index.tsx +0 -352
- package/src/components/InfiniteTable/internalProps.ts +0 -4
- package/src/components/InfiniteTable/state/computeColumnGroupsDepths.ts +0 -29
- package/src/components/InfiniteTable/state/getColumnVisibilityForHideEmptyGroupColumns.ts +0 -127
- package/src/components/InfiniteTable/state/getInitialState.ts +0 -375
- package/src/components/InfiniteTable/theme.css.ts +0 -556
- package/src/components/InfiniteTable/types/InfiniteTableAction.ts +0 -6
- package/src/components/InfiniteTable/types/InfiniteTableActionType.ts +0 -12
- package/src/components/InfiniteTable/types/InfiniteTableColumn.ts +0 -478
- package/src/components/InfiniteTable/types/InfiniteTableComputedValues.ts +0 -43
- package/src/components/InfiniteTable/types/InfiniteTableContextValue.ts +0 -12
- package/src/components/InfiniteTable/types/InfiniteTableInternalProps.ts +0 -3
- package/src/components/InfiniteTable/types/InfiniteTableProps.ts +0 -511
- package/src/components/InfiniteTable/types/InfiniteTableState.ts +0 -195
- package/src/components/InfiniteTable/types/Utility.ts +0 -35
- package/src/components/InfiniteTable/types/index.ts +0 -96
- package/src/components/InfiniteTable/utilities.css.ts +0 -179
- package/src/components/InfiniteTable/utils/MultiRowSelector.ts +0 -111
- package/src/components/InfiniteTable/utils/RenderHookComponentForInfinite.tsx +0 -52
- package/src/components/InfiniteTable/utils/adjustColumnOrderForPinning.ts +0 -33
- package/src/components/InfiniteTable/utils/assignFiltered.ts +0 -29
- package/src/components/InfiniteTable/utils/defaultGetColumContextMenuItems.tsx +0 -108
- package/src/components/InfiniteTable/utils/getColumnComputedType.ts +0 -33
- package/src/components/InfiniteTable/utils/getColumnForGroupBy.tsx +0 -313
- package/src/components/InfiniteTable/utils/getComputedVisibleColumns.ts +0 -773
- package/src/components/InfiniteTable/utils/getContextMenuForColumn.tsx +0 -72
- package/src/components/InfiniteTable/utils/infiniteDOMUtils.ts +0 -189
- package/src/components/InfiniteTable/utils/mapToObject.ts +0 -20
- package/src/components/InfiniteTable/utils/moveXatY.ts +0 -25
- package/src/components/InfiniteTable/utils/objectValuesExcept.ts +0 -9
- package/src/components/InfiniteTable/utils/progressiveSpeedScroller.ts +0 -158
- package/src/components/InfiniteTable/utils/rafFn.ts +0 -13
- package/src/components/InfiniteTable/utils/toCSSVarName.ts +0 -1
- package/src/components/InfiniteTable/utils/toMap.ts +0 -24
- package/src/components/Menu/Menu.tsx +0 -750
- package/src/components/Menu/MenuCls.css.ts +0 -139
- package/src/components/Menu/MenuContext.ts +0 -10
- package/src/components/Menu/MenuContextValue.ts +0 -15
- package/src/components/Menu/MenuProps.ts +0 -98
- package/src/components/Menu/MenuState.ts +0 -56
- package/src/components/Menu/MenuTriangleContext.ts +0 -352
- package/src/components/Menu/childrenToRuntimeItems.tsx +0 -103
- package/src/components/Menu/getMenuState.tsx +0 -119
- package/src/components/Menu/index.tsx +0 -88
- package/src/components/Menu/propToIdentifyMenu.ts +0 -1
- package/src/components/RawList/AvoidReactDiff.tsx +0 -48
- package/src/components/RawList/MappedItems.ts +0 -143
- package/src/components/RawList/ReactVirtualRenderer.tsx +0 -307
- package/src/components/RawList/index.tsx +0 -42
- package/src/components/RawList/types.ts +0 -23
- package/src/components/RawList/useVirtualRenderer.ts +0 -36
- package/src/components/RenderHookComponent.tsx +0 -10
- package/src/components/ResizeObserver/index.tsx +0 -170
- package/src/components/VirtualBrain/MatrixBrain.ts +0 -1621
- package/src/components/VirtualBrain/ScrollListener.ts +0 -39
- package/src/components/VirtualBrain/index.ts +0 -664
- package/src/components/VirtualList/ColumnListWithExternalScrolling.tsx +0 -78
- package/src/components/VirtualList/InfiniteListRootClassName.ts +0 -1
- package/src/components/VirtualList/RowListWithExternalScrolling.tsx +0 -120
- package/src/components/VirtualList/SpacePlaceholder.tsx +0 -32
- package/src/components/VirtualList/VirtualList.css.ts +0 -29
- package/src/components/VirtualList/VirtualList.tsx +0 -141
- package/src/components/VirtualList/VirtualRowList.tsx +0 -34
- package/src/components/VirtualList/types.ts +0 -56
- package/src/components/VirtualList/useCorrectHeightForRowElements.ts +0 -14
- package/src/components/VirtualScrollContainer/VirtualScrollContainer.css.ts +0 -51
- package/src/components/VirtualScrollContainer/getScrollableClassName.ts +0 -30
- package/src/components/VirtualScrollContainer/index.tsx +0 -63
- package/src/components/flexbox/index.ts +0 -562
- package/src/components/hooks/useComponentState/index.tsx +0 -562
- package/src/components/hooks/useComponentState/types.ts +0 -32
- package/src/components/hooks/useEffectOnceWithProperUnmount.ts +0 -33
- package/src/components/hooks/useEffectWithChanges.ts +0 -56
- package/src/components/hooks/useImmutableRef.ts +0 -7
- package/src/components/hooks/useInterceptedMap.ts +0 -71
- package/src/components/hooks/useLatest.tsx +0 -8
- package/src/components/hooks/useLazyLatest.ts +0 -23
- package/src/components/hooks/useMemoShallowObjectMerge.ts +0 -16
- package/src/components/hooks/useMounted.ts +0 -18
- package/src/components/hooks/useOnMount.ts +0 -21
- package/src/components/hooks/useOnScroll.ts +0 -34
- package/src/components/hooks/useOnce.ts +0 -10
- package/src/components/hooks/useOverlay/index.tsx +0 -418
- package/src/components/hooks/usePrevious.ts +0 -8
- package/src/components/hooks/usePropertyOld.ts +0 -168
- package/src/components/hooks/useRerender.ts +0 -12
- package/src/components/hooks/xuseProperty.ts +0 -165
- package/src/components/types/CellPosition.ts +0 -4
- package/src/components/types/NonUndefined.ts +0 -1
- package/src/components/types/RemoveObject.ts +0 -22
- package/src/components/types/Renderable.ts +0 -3
- package/src/components/types/ScrollPosition.ts +0 -7
- package/src/components/types/Setter.ts +0 -2
- package/src/components/types/Size.ts +0 -6
- package/src/components/types/SubscriptionCallback.ts +0 -10
- package/src/components/types/VoidFn.ts +0 -1
- package/src/components/utils/buildSubscriptionCallback.tsx +0 -60
- package/src/components/utils/clamp.ts +0 -3
- package/src/components/utils/debounce.ts +0 -16
- package/src/components/utils/decamelize.ts +0 -11
- package/src/components/utils/discardCallsWithEqualArg.ts +0 -42
- package/src/components/utils/getRenderIndexes.ts +0 -33
- package/src/components/utils/getScrollbarWidth.ts +0 -31
- package/src/components/utils/getVirtualRenderCount.ts +0 -21
- package/src/components/utils/isControlled.ts +0 -12
- package/src/components/utils/isControlledValue.ts +0 -5
- package/src/index.tsx +0 -34
- package/src/test.tsx +0 -18
- package/src/utils/DeepMap/index.ts +0 -588
- package/src/utils/DeepMap/once.ts +0 -16
- package/src/utils/DeepMap/sortAscending.ts +0 -1
- package/src/utils/DeepMap/tsconfig.deepmap.json +0 -17
- package/src/utils/DeepMap/xpackage.json +0 -26
- package/src/utils/debug.ts +0 -40
- package/src/utils/deepClone.ts +0 -38
- package/src/utils/getGlobal.ts +0 -3
- package/src/utils/groupAndPivot/defaultToKey.ts +0 -3
- package/src/utils/groupAndPivot/getGroupKeysForDataItem.ts +0 -19
- package/src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts +0 -361
- package/src/utils/groupAndPivot/index.ts +0 -1229
- package/src/utils/groupAndPivot/types.ts +0 -10
- package/src/utils/join.ts +0 -4
- package/src/utils/mathIntersection.ts +0 -21
- package/src/utils/minified.d.ts +0 -2
- package/src/utils/minified.js +0 -6
- package/src/utils/multisort/index.ts +0 -151
- package/src/utils/multisort/sortTypes.ts +0 -25
- package/src/utils/notes-status.md +0 -92
- package/src/utils/pageGeometry/ConvexPoly.ts +0 -34
- package/src/utils/pageGeometry/Point.ts +0 -51
- package/src/utils/pageGeometry/PolyWithPoints.ts +0 -52
- package/src/utils/pageGeometry/Rectangle.ts +0 -98
- package/src/utils/pageGeometry/Triangle.ts +0 -16
- package/src/utils/pageGeometry/alignment/index.ts +0 -221
- package/src/utils/pageGeometry/polyContainsPoint.ts +0 -182
- package/src/utils/pageGeometry/types.ts +0 -3
- package/src/utils/proxyFnCall.ts +0 -46
- package/src/utils/raf.ts +0 -13
- package/src/utils/selectParent.ts +0 -18
- package/src/utils/shallowEqualObjects.ts +0 -49
- package/src/utils/stripVar.ts +0 -3
- package/src/utils/toUpperFirst.ts +0 -5
- package/todo.md +0 -2
- package/tsconfig.build.json +0 -8
- package/tsconfig.dev.json +0 -7
- package/tsconfig.json +0 -30
- package/tsconfig.typebundler.json +0 -13
- package/typedoc.json +0 -4
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useDataSourceContextValue } from '../../DataSource/publicHooks/useDataSource';
|
|
4
|
-
import { MatrixBrainOptions } from '../../VirtualBrain/MatrixBrain';
|
|
5
|
-
import { InfiniteTableComputedColumn } from '../types';
|
|
6
|
-
|
|
7
|
-
export function useColumnRowspan<T>(
|
|
8
|
-
computedVisibleColumns: InfiniteTableComputedColumn<T>[],
|
|
9
|
-
) {
|
|
10
|
-
const { getState: getDataSourceState } = useDataSourceContextValue<T>();
|
|
11
|
-
|
|
12
|
-
const rowspan = useMemo<MatrixBrainOptions['rowspan']>(() => {
|
|
13
|
-
const colsWithRowspan = computedVisibleColumns.filter(
|
|
14
|
-
(col) => typeof col.rowspan === 'function',
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
return colsWithRowspan.length
|
|
18
|
-
? ({ rowIndex, colIndex }) => {
|
|
19
|
-
const dataArray = getDataSourceState().dataArray;
|
|
20
|
-
const rowInfo = dataArray[rowIndex];
|
|
21
|
-
if (!rowInfo) {
|
|
22
|
-
return 1;
|
|
23
|
-
}
|
|
24
|
-
const data = rowInfo.data;
|
|
25
|
-
|
|
26
|
-
const column = computedVisibleColumns[colIndex];
|
|
27
|
-
|
|
28
|
-
if (!column || !column.rowspan) {
|
|
29
|
-
return 1;
|
|
30
|
-
}
|
|
31
|
-
return column.rowspan({
|
|
32
|
-
column,
|
|
33
|
-
data,
|
|
34
|
-
dataArray,
|
|
35
|
-
rowInfo,
|
|
36
|
-
rowIndex,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
: undefined;
|
|
40
|
-
}, [computedVisibleColumns]);
|
|
41
|
-
|
|
42
|
-
return rowspan;
|
|
43
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { dbg } from '../../../utils/debug';
|
|
3
|
-
import { InfiniteTableComputedColumn } from '../types';
|
|
4
|
-
|
|
5
|
-
const debug = dbg('useColumnSizeFn');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns a function that can be used to retrieve the width of a column column, by the column index
|
|
9
|
-
*/
|
|
10
|
-
export function useColumnSizeFn<T>(columns: InfiniteTableComputedColumn<T>[]) {
|
|
11
|
-
const columnSize = useCallback(
|
|
12
|
-
(index: number) => {
|
|
13
|
-
const column = columns[index];
|
|
14
|
-
if (__DEV__ && !column) {
|
|
15
|
-
debug('cannot find column at index', index, columns);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return column ? column.computedWidth : 0;
|
|
19
|
-
},
|
|
20
|
-
[columns],
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return columnSize;
|
|
24
|
-
}
|
|
@@ -1,582 +0,0 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import type { InfiniteTableColumn, InfiniteTableState } from '..';
|
|
4
|
-
import { shallowEqualObjects } from '../../../utils/shallowEqualObjects';
|
|
5
|
-
import type {
|
|
6
|
-
DataSourceGroupBy,
|
|
7
|
-
DataSourcePivotBy,
|
|
8
|
-
DataSourcePropGroupBy,
|
|
9
|
-
DataSourcePropSelectionMode,
|
|
10
|
-
} from '../../DataSource';
|
|
11
|
-
import { useDataSourceContextValue } from '../../DataSource/publicHooks/useDataSource';
|
|
12
|
-
import { useComponentState } from '../../hooks/useComponentState';
|
|
13
|
-
import { interceptMap } from '../../hooks/useInterceptedMap';
|
|
14
|
-
import { getGroupByMap } from '../state/getInitialState';
|
|
15
|
-
import {
|
|
16
|
-
getColumnVisibilityForHideEmptyGroupColumns,
|
|
17
|
-
getGroupColumnsMapForComputedColumns,
|
|
18
|
-
} from '../state/getColumnVisibilityForHideEmptyGroupColumns';
|
|
19
|
-
|
|
20
|
-
import type {
|
|
21
|
-
InfiniteTableComputedPivotFinalColumn,
|
|
22
|
-
InfiniteTableGeneratedGroupColumn,
|
|
23
|
-
InfiniteTablePivotColumn,
|
|
24
|
-
} from '../types/InfiniteTableColumn';
|
|
25
|
-
import type {
|
|
26
|
-
InfiniteTablePropGroupRenderStrategy,
|
|
27
|
-
InfiniteTableProps,
|
|
28
|
-
} from '../types/InfiniteTableProps';
|
|
29
|
-
import { GroupByMap } from '../types/InfiniteTableState';
|
|
30
|
-
import {
|
|
31
|
-
getColumnForGroupBy,
|
|
32
|
-
getGroupColumnRender,
|
|
33
|
-
getGroupColumnRenderGroupIcon,
|
|
34
|
-
getSingleGroupColumn,
|
|
35
|
-
} from '../utils/getColumnForGroupBy';
|
|
36
|
-
|
|
37
|
-
import { ToggleGroupRowFn, useToggleGroupRow } from './useToggleGroupRow';
|
|
38
|
-
|
|
39
|
-
function useGroupByMap<T>(groupBy: DataSourcePropGroupBy<T>) {
|
|
40
|
-
return useMemo(() => getGroupByMap(groupBy), [groupBy]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function useColumnsWhen<T>() {
|
|
44
|
-
const {
|
|
45
|
-
componentState: { groupBy },
|
|
46
|
-
componentActions: dataSourceActions,
|
|
47
|
-
} = useDataSourceContextValue<T>();
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
componentState: {
|
|
51
|
-
groupRenderStrategy,
|
|
52
|
-
pivotTotalColumnPosition,
|
|
53
|
-
pivotGrandTotalColumnPosition,
|
|
54
|
-
},
|
|
55
|
-
} = useComponentState<InfiniteTableState<T>>();
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
dataSourceActions.generateGroupRows = groupRenderStrategy !== 'inline';
|
|
59
|
-
}, [groupRenderStrategy]);
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
dataSourceActions.pivotTotalColumnPosition = pivotTotalColumnPosition;
|
|
63
|
-
}, [pivotTotalColumnPosition]);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (pivotGrandTotalColumnPosition != undefined) {
|
|
67
|
-
dataSourceActions.pivotGrandTotalColumnPosition =
|
|
68
|
-
pivotGrandTotalColumnPosition;
|
|
69
|
-
}
|
|
70
|
-
}, [pivotGrandTotalColumnPosition]);
|
|
71
|
-
|
|
72
|
-
const groupByMap = useGroupByMap(groupBy);
|
|
73
|
-
|
|
74
|
-
useColumnsWhenInlineGroupRenderStrategy<T>(groupByMap);
|
|
75
|
-
const { toggleGroupRow } = useColumnsWhenGrouping<T>();
|
|
76
|
-
|
|
77
|
-
useHideColumns<T>(groupByMap);
|
|
78
|
-
|
|
79
|
-
return { toggleGroupRow };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function useColumnsWhenInlineGroupRenderStrategy<T>(groupByMap: GroupByMap<T>) {
|
|
83
|
-
const toggleGroupRow = useToggleGroupRow();
|
|
84
|
-
|
|
85
|
-
const {
|
|
86
|
-
componentActions,
|
|
87
|
-
componentState: { columns, groupRenderStrategy },
|
|
88
|
-
} = useComponentState<InfiniteTableState<T>>();
|
|
89
|
-
|
|
90
|
-
function computeColumnsWhenInlineGroupRenderStrategy(
|
|
91
|
-
columns: Map<string, InfiniteTableColumn<T>>,
|
|
92
|
-
groupByMap: GroupByMap<T>,
|
|
93
|
-
groupRenderStrategy: InfiniteTablePropGroupRenderStrategy,
|
|
94
|
-
toggleGroupRow: ToggleGroupRowFn,
|
|
95
|
-
) {
|
|
96
|
-
const computedColumns = new Map<string, InfiniteTableColumn<T>>();
|
|
97
|
-
|
|
98
|
-
if (groupRenderStrategy !== 'inline') {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
columns.forEach((column, id) => {
|
|
103
|
-
let base: Partial<InfiniteTableGeneratedGroupColumn<T>> = {};
|
|
104
|
-
const groupByForColumn = groupByMap.get(column.field!);
|
|
105
|
-
if (groupByForColumn && groupRenderStrategy === 'inline') {
|
|
106
|
-
const { groupIndex } = groupByForColumn;
|
|
107
|
-
const field = groupByForColumn.groupBy.field;
|
|
108
|
-
base = {
|
|
109
|
-
groupByField: field as string,
|
|
110
|
-
field: field,
|
|
111
|
-
valueFormatter: ({ rowInfo }) => {
|
|
112
|
-
return rowInfo.isGroupRow
|
|
113
|
-
? rowInfo.groupKeys?.[groupIndex]
|
|
114
|
-
: rowInfo.value;
|
|
115
|
-
},
|
|
116
|
-
rowspan: ({ rowInfo, dataArray }) => {
|
|
117
|
-
if (!rowInfo.isGroupRow) {
|
|
118
|
-
return 1;
|
|
119
|
-
}
|
|
120
|
-
const prevRowInfo = dataArray[rowInfo.indexInAll - 1] || {
|
|
121
|
-
indexInParentGroups: [],
|
|
122
|
-
};
|
|
123
|
-
if (!prevRowInfo || !prevRowInfo.dataSourceHasGrouping) {
|
|
124
|
-
return 1;
|
|
125
|
-
}
|
|
126
|
-
const prevIndexes = prevRowInfo.indexInParentGroups! || [];
|
|
127
|
-
const currentIndexes = rowInfo.indexInParentGroups! || [];
|
|
128
|
-
|
|
129
|
-
let computeSpan = false;
|
|
130
|
-
for (let i = 0; i <= groupIndex; i++) {
|
|
131
|
-
const prev = prevIndexes[i];
|
|
132
|
-
const current = currentIndexes[i];
|
|
133
|
-
|
|
134
|
-
if (current !== prev) {
|
|
135
|
-
computeSpan = true;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!computeSpan) {
|
|
141
|
-
return 1;
|
|
142
|
-
}
|
|
143
|
-
const parentGroup = rowInfo.parents![groupIndex];
|
|
144
|
-
|
|
145
|
-
const rowspan = parentGroup
|
|
146
|
-
? parentGroup.groupCount -
|
|
147
|
-
(parentGroup.collapsedChildrenCount || 0) +
|
|
148
|
-
(parentGroup.collapsedGroupsCount || 0)
|
|
149
|
-
: 1;
|
|
150
|
-
|
|
151
|
-
return rowspan;
|
|
152
|
-
},
|
|
153
|
-
renderGroupIcon: getGroupColumnRenderGroupIcon({
|
|
154
|
-
groupIndexForColumn: groupIndex,
|
|
155
|
-
groupRenderStrategy,
|
|
156
|
-
toggleGroupRow,
|
|
157
|
-
initialRenderGroupIcon: column.renderGroupIcon,
|
|
158
|
-
}),
|
|
159
|
-
render: getGroupColumnRender({
|
|
160
|
-
groupIndexForColumn: groupIndex,
|
|
161
|
-
groupRenderStrategy,
|
|
162
|
-
}),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
const clone = { ...base, ...column } as InfiniteTableColumn<T>;
|
|
166
|
-
|
|
167
|
-
computedColumns.set(id, clone);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
return computedColumns.size === 0 ? undefined : computedColumns;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
const update = () => {
|
|
175
|
-
componentActions.columnsWhenInlineGroupRenderStrategy =
|
|
176
|
-
computeColumnsWhenInlineGroupRenderStrategy(
|
|
177
|
-
columns,
|
|
178
|
-
groupByMap,
|
|
179
|
-
groupRenderStrategy,
|
|
180
|
-
toggleGroupRow,
|
|
181
|
-
);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
update();
|
|
185
|
-
|
|
186
|
-
return interceptMap(columns, {
|
|
187
|
-
set: update,
|
|
188
|
-
delete: update,
|
|
189
|
-
clear: update,
|
|
190
|
-
});
|
|
191
|
-
}, [columns, groupByMap, groupRenderStrategy, toggleGroupRow]);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function useColumnsWhenGrouping<T>() {
|
|
195
|
-
const {
|
|
196
|
-
componentState: { groupBy, pivotBy, selectionMode },
|
|
197
|
-
} = useDataSourceContextValue<T>();
|
|
198
|
-
|
|
199
|
-
const {
|
|
200
|
-
componentActions,
|
|
201
|
-
componentState: {
|
|
202
|
-
columns,
|
|
203
|
-
groupColumn,
|
|
204
|
-
hideColumnWhenGrouped,
|
|
205
|
-
groupRenderStrategy,
|
|
206
|
-
pivotColumns,
|
|
207
|
-
pivotColumn,
|
|
208
|
-
pivotTotalColumnPosition,
|
|
209
|
-
pivotGrandTotalColumnPosition,
|
|
210
|
-
},
|
|
211
|
-
getComponentState,
|
|
212
|
-
} = useComponentState<InfiniteTableState<T>>();
|
|
213
|
-
|
|
214
|
-
const toggleGroupRow = useToggleGroupRow();
|
|
215
|
-
|
|
216
|
-
useEffect(() => {
|
|
217
|
-
const update = () => {
|
|
218
|
-
const { columns: columnsWhenGrouping, groupColumnIds } =
|
|
219
|
-
getColumnsWhenGrouping({
|
|
220
|
-
columns,
|
|
221
|
-
groupColumn,
|
|
222
|
-
pivotColumn,
|
|
223
|
-
pivotTotalColumnPosition,
|
|
224
|
-
pivotGrandTotalColumnPosition,
|
|
225
|
-
groupRenderStrategy:
|
|
226
|
-
groupRenderStrategy === 'inline'
|
|
227
|
-
? 'single-column'
|
|
228
|
-
: groupRenderStrategy,
|
|
229
|
-
groupBy,
|
|
230
|
-
pivotBy,
|
|
231
|
-
pivotColumns,
|
|
232
|
-
toggleGroupRow,
|
|
233
|
-
selectionMode,
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
componentActions.columnsWhenGrouping = columnsWhenGrouping;
|
|
237
|
-
|
|
238
|
-
let currentColumnOrder = getComponentState().columnOrder;
|
|
239
|
-
if (groupColumnIds.length && Array.isArray(currentColumnOrder)) {
|
|
240
|
-
const colOrder = new Set(currentColumnOrder);
|
|
241
|
-
let shouldUpdate = false;
|
|
242
|
-
groupColumnIds.forEach((groupColId) => {
|
|
243
|
-
if (!colOrder.has(groupColId)) {
|
|
244
|
-
shouldUpdate = true;
|
|
245
|
-
currentColumnOrder = [
|
|
246
|
-
groupColId,
|
|
247
|
-
...(currentColumnOrder as string[]),
|
|
248
|
-
];
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
if (shouldUpdate) {
|
|
252
|
-
componentActions.columnOrder = currentColumnOrder;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
update();
|
|
258
|
-
|
|
259
|
-
return interceptMap(columns, {
|
|
260
|
-
set: update,
|
|
261
|
-
delete: update,
|
|
262
|
-
clear: update,
|
|
263
|
-
});
|
|
264
|
-
}, [
|
|
265
|
-
columns,
|
|
266
|
-
groupBy,
|
|
267
|
-
pivotBy,
|
|
268
|
-
selectionMode,
|
|
269
|
-
hideColumnWhenGrouped,
|
|
270
|
-
groupColumn,
|
|
271
|
-
groupRenderStrategy,
|
|
272
|
-
pivotColumns,
|
|
273
|
-
pivotTotalColumnPosition,
|
|
274
|
-
pivotColumn,
|
|
275
|
-
]);
|
|
276
|
-
|
|
277
|
-
return { toggleGroupRow };
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function useHideColumns<T>(groupByMap: GroupByMap<T>) {
|
|
281
|
-
const {
|
|
282
|
-
componentState: {
|
|
283
|
-
dataArray,
|
|
284
|
-
groupRowsIndexesInDataArray: groupRowsIndexesInDataArray,
|
|
285
|
-
groupBy,
|
|
286
|
-
groupRowsState,
|
|
287
|
-
originalLazyGroupDataChangeDetect,
|
|
288
|
-
},
|
|
289
|
-
getState: getDataSourceState,
|
|
290
|
-
} = useDataSourceContextValue<T>();
|
|
291
|
-
|
|
292
|
-
const {
|
|
293
|
-
getComponentState,
|
|
294
|
-
componentActions,
|
|
295
|
-
componentState: {
|
|
296
|
-
columnTypes,
|
|
297
|
-
computedColumns,
|
|
298
|
-
|
|
299
|
-
hideColumnWhenGrouped,
|
|
300
|
-
hideEmptyGroupColumns,
|
|
301
|
-
|
|
302
|
-
groupRenderStrategy,
|
|
303
|
-
},
|
|
304
|
-
} = useComponentState<InfiniteTableState<T>>();
|
|
305
|
-
|
|
306
|
-
// implements hideEmptyGroupColumns
|
|
307
|
-
useLayoutEffect(() => {
|
|
308
|
-
if (groupRenderStrategy !== 'multi-column') {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const currentState = getComponentState();
|
|
312
|
-
|
|
313
|
-
const computedGroupColumns = getGroupColumnsMapForComputedColumns(
|
|
314
|
-
computedColumns,
|
|
315
|
-
groupByMap,
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
const newColumnVisibility = getColumnVisibilityForHideEmptyGroupColumns({
|
|
319
|
-
computedGroupColumns,
|
|
320
|
-
columnVisibility: currentState.columnVisibility,
|
|
321
|
-
hideEmptyGroupColumns,
|
|
322
|
-
groupRowsIndexesInDataArray,
|
|
323
|
-
dataArray,
|
|
324
|
-
groupBy,
|
|
325
|
-
groupByMap,
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
if (
|
|
329
|
-
!shallowEqualObjects(currentState.columnVisibility, newColumnVisibility)
|
|
330
|
-
) {
|
|
331
|
-
componentActions.columnVisibility = newColumnVisibility;
|
|
332
|
-
}
|
|
333
|
-
}, [
|
|
334
|
-
getDataSourceState,
|
|
335
|
-
groupRenderStrategy,
|
|
336
|
-
originalLazyGroupDataChangeDetect,
|
|
337
|
-
groupBy,
|
|
338
|
-
groupByMap,
|
|
339
|
-
computedColumns,
|
|
340
|
-
|
|
341
|
-
hideEmptyGroupColumns ? dataArray : null,
|
|
342
|
-
hideEmptyGroupColumns ? groupRowsState : null,
|
|
343
|
-
hideEmptyGroupColumns ? groupRowsIndexesInDataArray : null,
|
|
344
|
-
hideEmptyGroupColumns,
|
|
345
|
-
]);
|
|
346
|
-
|
|
347
|
-
// implements the functionality of column.defaultHiddenWhenGrouped and hideColumnWhenGrouped
|
|
348
|
-
useEffect(() => {
|
|
349
|
-
const isGrouped = groupBy.length > 0;
|
|
350
|
-
const currentState = getComponentState();
|
|
351
|
-
|
|
352
|
-
const {
|
|
353
|
-
columnVisibility,
|
|
354
|
-
columnVisibilityForGrouping,
|
|
355
|
-
hideColumnWhenGrouped,
|
|
356
|
-
} = currentState;
|
|
357
|
-
|
|
358
|
-
const newColumnVisibility = { ...columnVisibility };
|
|
359
|
-
let newColumnVisibilityForGrouping = { ...columnVisibilityForGrouping };
|
|
360
|
-
|
|
361
|
-
let updatedVisibilityWhenGrouping = false;
|
|
362
|
-
|
|
363
|
-
let newlyHiddenColumns = new Set<string>();
|
|
364
|
-
let newlyDisplayedColumns = new Set<string>();
|
|
365
|
-
|
|
366
|
-
computedColumns.forEach((col, id) => {
|
|
367
|
-
if (col.defaultHiddenWhenGroupedBy || hideColumnWhenGrouped != null) {
|
|
368
|
-
const hideWhenGrouped =
|
|
369
|
-
(col.defaultHiddenWhenGroupedBy === '*' && isGrouped) ||
|
|
370
|
-
((col.defaultHiddenWhenGroupedBy === true || hideColumnWhenGrouped) &&
|
|
371
|
-
col.field &&
|
|
372
|
-
groupByMap.get(col.field)) ||
|
|
373
|
-
(typeof col.defaultHiddenWhenGroupedBy === 'string' &&
|
|
374
|
-
groupByMap.get(col.defaultHiddenWhenGroupedBy as keyof T)) ||
|
|
375
|
-
(typeof col.defaultHiddenWhenGroupedBy === 'object' &&
|
|
376
|
-
Object.keys(col.defaultHiddenWhenGroupedBy).reduce(
|
|
377
|
-
(acc: boolean, field) => acc || groupByMap.has(field as keyof T),
|
|
378
|
-
false,
|
|
379
|
-
));
|
|
380
|
-
|
|
381
|
-
if (hideWhenGrouped) {
|
|
382
|
-
if (newColumnVisibilityForGrouping[id] !== false) {
|
|
383
|
-
if (columnVisibility[id] === false) {
|
|
384
|
-
// if the column is already specified as invisible,
|
|
385
|
-
// dont put it in the list of cols made invisible due to grouping rules
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
// should be hidden and was not already
|
|
389
|
-
newColumnVisibilityForGrouping[id] = false;
|
|
390
|
-
updatedVisibilityWhenGrouping = true;
|
|
391
|
-
newlyHiddenColumns.add(id);
|
|
392
|
-
}
|
|
393
|
-
} else {
|
|
394
|
-
if (newColumnVisibilityForGrouping[id] === false) {
|
|
395
|
-
//should be visible and was not already
|
|
396
|
-
delete newColumnVisibilityForGrouping[id];
|
|
397
|
-
updatedVisibilityWhenGrouping = true;
|
|
398
|
-
newlyDisplayedColumns.add(id);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
if (updatedVisibilityWhenGrouping) {
|
|
405
|
-
componentActions.columnVisibilityForGrouping =
|
|
406
|
-
newColumnVisibilityForGrouping;
|
|
407
|
-
|
|
408
|
-
newlyDisplayedColumns.forEach((colId) => {
|
|
409
|
-
delete newColumnVisibility[colId];
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
newlyHiddenColumns.forEach((colId) => {
|
|
413
|
-
newColumnVisibility[colId] = false;
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
componentActions.columnVisibility = newColumnVisibility;
|
|
417
|
-
}
|
|
418
|
-
}, [
|
|
419
|
-
computedColumns,
|
|
420
|
-
columnTypes,
|
|
421
|
-
groupBy,
|
|
422
|
-
groupByMap,
|
|
423
|
-
hideColumnWhenGrouped,
|
|
424
|
-
]);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
export function getColumnsWhenGrouping<T>(params: {
|
|
428
|
-
columns: Map<string, InfiniteTableColumn<T>>;
|
|
429
|
-
groupBy: DataSourceGroupBy<T>[];
|
|
430
|
-
selectionMode: DataSourcePropSelectionMode;
|
|
431
|
-
pivotBy?: DataSourcePivotBy<T>[];
|
|
432
|
-
toggleGroupRow: (groupKeys: any[]) => void;
|
|
433
|
-
pivotTotalColumnPosition: InfiniteTableState<T>['pivotTotalColumnPosition'];
|
|
434
|
-
pivotGrandTotalColumnPosition: InfiniteTableState<T>['pivotGrandTotalColumnPosition'];
|
|
435
|
-
groupColumn: InfiniteTableProps<T>['groupColumn'];
|
|
436
|
-
groupRenderStrategy: InfiniteTablePropGroupRenderStrategy;
|
|
437
|
-
pivotColumns: InfiniteTableProps<T>['pivotColumns'];
|
|
438
|
-
pivotColumn: InfiniteTableProps<T>['pivotColumn'];
|
|
439
|
-
}): {
|
|
440
|
-
columns: Map<string, InfiniteTableColumn<T>> | undefined;
|
|
441
|
-
groupColumnIds: string[];
|
|
442
|
-
} {
|
|
443
|
-
const {
|
|
444
|
-
pivotColumns,
|
|
445
|
-
groupBy,
|
|
446
|
-
pivotBy,
|
|
447
|
-
selectionMode,
|
|
448
|
-
groupColumn,
|
|
449
|
-
pivotTotalColumnPosition,
|
|
450
|
-
pivotGrandTotalColumnPosition,
|
|
451
|
-
pivotColumn,
|
|
452
|
-
groupRenderStrategy,
|
|
453
|
-
toggleGroupRow,
|
|
454
|
-
columns,
|
|
455
|
-
} = params;
|
|
456
|
-
|
|
457
|
-
if (groupRenderStrategy === 'inline') {
|
|
458
|
-
return { columns: undefined, groupColumnIds: [] };
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
const computedColumns = new Map<string, InfiniteTableColumn<T>>();
|
|
462
|
-
|
|
463
|
-
const groupColumnIds: string[] = [];
|
|
464
|
-
|
|
465
|
-
if (groupRenderStrategy === 'multi-column') {
|
|
466
|
-
groupBy.forEach((groupByForColumn, groupIndexForColumn, arr) => {
|
|
467
|
-
const generatedGroupColumn = getColumnForGroupBy<T>(
|
|
468
|
-
{
|
|
469
|
-
groupByForColumn,
|
|
470
|
-
groupBy,
|
|
471
|
-
pivotBy,
|
|
472
|
-
groupIndexForColumn,
|
|
473
|
-
groupCount: arr.length,
|
|
474
|
-
groupRenderStrategy,
|
|
475
|
-
selectionMode,
|
|
476
|
-
},
|
|
477
|
-
toggleGroupRow,
|
|
478
|
-
groupColumn,
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
const groupColumnId =
|
|
482
|
-
generatedGroupColumn.id || `group-by-${groupByForColumn.field}`;
|
|
483
|
-
|
|
484
|
-
groupColumnIds.push(groupColumnId);
|
|
485
|
-
computedColumns.set(groupColumnId, generatedGroupColumn);
|
|
486
|
-
});
|
|
487
|
-
} else if (groupRenderStrategy === 'single-column' && groupBy.length) {
|
|
488
|
-
// } else if (
|
|
489
|
-
// (groupRenderStrategy === 'single-column' ||
|
|
490
|
-
// groupRenderStrategy === 'single-column-extended') &&
|
|
491
|
-
// groupBy.length
|
|
492
|
-
// ) {
|
|
493
|
-
const singleGroupColumn = getSingleGroupColumn(
|
|
494
|
-
{
|
|
495
|
-
groupCount: groupBy.length,
|
|
496
|
-
groupBy,
|
|
497
|
-
pivotBy,
|
|
498
|
-
groupRenderStrategy,
|
|
499
|
-
selectionMode,
|
|
500
|
-
},
|
|
501
|
-
toggleGroupRow,
|
|
502
|
-
groupColumn,
|
|
503
|
-
);
|
|
504
|
-
|
|
505
|
-
const groupColumnId = singleGroupColumn.id || 'group-by';
|
|
506
|
-
groupColumnIds.push(groupColumnId);
|
|
507
|
-
computedColumns.set(groupColumnId, singleGroupColumn);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
if (pivotColumns) {
|
|
511
|
-
const columnsByField: Partial<Record<keyof T, InfiniteTableColumn<T>>> = {};
|
|
512
|
-
|
|
513
|
-
columns.forEach((col) => {
|
|
514
|
-
if (col.field) {
|
|
515
|
-
columnsByField[col.field] = col;
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
pivotColumns.forEach((col, key) => {
|
|
520
|
-
const isSimpleTotalColumn = col.pivotTotalColumn && col.columnGroup;
|
|
521
|
-
const isGrandTotalColumn = col.pivotTotalColumn && !col.columnGroup;
|
|
522
|
-
|
|
523
|
-
if (isSimpleTotalColumn && pivotTotalColumnPosition === false) {
|
|
524
|
-
// don't include the total columns if specified as false
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
if (isGrandTotalColumn && pivotGrandTotalColumnPosition === false) {
|
|
528
|
-
// don't include the grand total columns if specified as false
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
let column: InfiniteTablePivotColumn<T> = { ...col };
|
|
533
|
-
|
|
534
|
-
// const isPivotRowLabelsColumn =
|
|
535
|
-
// !column.pivotColumn && !column.pivotTotalColumn;
|
|
536
|
-
|
|
537
|
-
// if (!isPivotRowLabelsColumn) {
|
|
538
|
-
if (pivotColumn) {
|
|
539
|
-
if (typeof pivotColumn === 'function') {
|
|
540
|
-
column = {
|
|
541
|
-
...column,
|
|
542
|
-
...pivotColumn({
|
|
543
|
-
column: column as InfiniteTableComputedPivotFinalColumn<T>,
|
|
544
|
-
pivotBy: pivotBy!,
|
|
545
|
-
groupBy,
|
|
546
|
-
}),
|
|
547
|
-
} as InfiniteTablePivotColumn<T>;
|
|
548
|
-
} else {
|
|
549
|
-
column = {
|
|
550
|
-
...column,
|
|
551
|
-
...pivotColumn,
|
|
552
|
-
} as InfiniteTablePivotColumn<T>;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (column.inheritFromColumn !== false) {
|
|
556
|
-
const colToInheritFrom =
|
|
557
|
-
typeof column.inheritFromColumn === 'string'
|
|
558
|
-
? columns.get(column.inheritFromColumn)
|
|
559
|
-
: column.pivotAggregator?.field
|
|
560
|
-
? columnsByField[column.pivotAggregator?.field]
|
|
561
|
-
: undefined;
|
|
562
|
-
column = { ...colToInheritFrom, ...column };
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
if (!column.render && column.renderValue) {
|
|
566
|
-
column.render = (renderOptions) => {
|
|
567
|
-
return column.renderValue!(renderOptions);
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
computedColumns.set(key, column);
|
|
571
|
-
});
|
|
572
|
-
} else {
|
|
573
|
-
columns.forEach((col, colId) => {
|
|
574
|
-
computedColumns.set(colId, col);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
return {
|
|
579
|
-
columns: computedColumns.size ? computedColumns : undefined,
|
|
580
|
-
groupColumnIds,
|
|
581
|
-
};
|
|
582
|
-
}
|