@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,773 +0,0 @@
|
|
|
1
|
-
import { err } from '../../../utils/debug';
|
|
2
|
-
import type {
|
|
3
|
-
DataSourceFilterValueItem,
|
|
4
|
-
DataSourcePropFilterValue,
|
|
5
|
-
DataSourceSingleSortInfo,
|
|
6
|
-
} from '../../DataSource/types';
|
|
7
|
-
import { computeFlex } from '../../flexbox';
|
|
8
|
-
import type { Size } from '../../types/Size';
|
|
9
|
-
import { getScrollbarWidth } from '../../utils/getScrollbarWidth';
|
|
10
|
-
import type {
|
|
11
|
-
InfiniteTableColumn,
|
|
12
|
-
InfiniteTableComputedColumn,
|
|
13
|
-
InfiniteTableGeneratedGroupColumn,
|
|
14
|
-
RequireAtLeastOne,
|
|
15
|
-
} from '../types/InfiniteTableColumn';
|
|
16
|
-
import type {
|
|
17
|
-
InfiniteTableColumnPinnedValues,
|
|
18
|
-
InfiniteTableColumnSizingOptions,
|
|
19
|
-
InfiniteTablePropColumnOrder,
|
|
20
|
-
InfiniteTablePropColumnOrderNormalized,
|
|
21
|
-
InfiniteTablePropColumnPinning,
|
|
22
|
-
InfiniteTablePropColumnSizing,
|
|
23
|
-
InfiniteTablePropColumnTypes,
|
|
24
|
-
InfiniteTablePropColumnVisibility,
|
|
25
|
-
} from '../types/InfiniteTableProps';
|
|
26
|
-
|
|
27
|
-
import { adjustColumnOrderForPinning } from './adjustColumnOrderForPinning';
|
|
28
|
-
import { assignNonNull } from './assignFiltered';
|
|
29
|
-
import { getColumnComputedType } from './getColumnComputedType';
|
|
30
|
-
|
|
31
|
-
const logError = err('getComputedVisibleColumns');
|
|
32
|
-
|
|
33
|
-
export type SortInfoMap<T> = {
|
|
34
|
-
[key: string]: {
|
|
35
|
-
sortInfo: DataSourceSingleSortInfo<T>;
|
|
36
|
-
index: number;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const isColumnVisible = (
|
|
41
|
-
columnVisibility: InfiniteTablePropColumnVisibility,
|
|
42
|
-
_columnVisibilityAssumeVisible: boolean,
|
|
43
|
-
|
|
44
|
-
colId: string,
|
|
45
|
-
) => {
|
|
46
|
-
// if (_columnVisibilityAssumeVisible) {
|
|
47
|
-
return columnVisibility[colId] !== false;
|
|
48
|
-
// }
|
|
49
|
-
|
|
50
|
-
// return columnVisibility.get(colId) === true;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getComputedPinned = (
|
|
54
|
-
colId: string,
|
|
55
|
-
columnPinning: InfiniteTablePropColumnPinning,
|
|
56
|
-
): InfiniteTableColumnPinnedValues => {
|
|
57
|
-
if (!columnPinning) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const pinned = columnPinning[colId];
|
|
61
|
-
const computedPinned: InfiniteTableColumnPinnedValues =
|
|
62
|
-
pinned === 'start' || pinned === true
|
|
63
|
-
? 'start'
|
|
64
|
-
: pinned === 'end'
|
|
65
|
-
? 'end'
|
|
66
|
-
: false;
|
|
67
|
-
|
|
68
|
-
return computedPinned;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type GetComputedVisibleColumnsResult<T> = {
|
|
72
|
-
renderSelectionCheckBox: boolean;
|
|
73
|
-
computedRemainingSpace: number;
|
|
74
|
-
computedPinnedStartColumnsWidth: number;
|
|
75
|
-
computedPinnedStartWidth: number;
|
|
76
|
-
computedPinnedEndColumnsWidth: number;
|
|
77
|
-
computedPinnedEndWidth: number;
|
|
78
|
-
computedUnpinnedColumnsWidth: number;
|
|
79
|
-
|
|
80
|
-
computedColumnsMap: Map<string, InfiniteTableComputedColumn<T>>;
|
|
81
|
-
computedColumnsMapInInitialOrder: Map<string, InfiniteTableComputedColumn<T>>;
|
|
82
|
-
|
|
83
|
-
columnMinWidth?: number;
|
|
84
|
-
columnMaxWidth?: number;
|
|
85
|
-
columnDefaultWidth?: number;
|
|
86
|
-
|
|
87
|
-
computedPinnedStartColumns: InfiniteTableComputedColumn<T>[];
|
|
88
|
-
computedPinnedEndColumns: InfiniteTableComputedColumn<T>[];
|
|
89
|
-
computedUnpinnedColumns: InfiniteTableComputedColumn<T>[];
|
|
90
|
-
|
|
91
|
-
computedColumnOrder: InfiniteTablePropColumnOrderNormalized;
|
|
92
|
-
|
|
93
|
-
computedUnpinnedOffset: number;
|
|
94
|
-
computedPinnedEndOffset: number;
|
|
95
|
-
|
|
96
|
-
computedVisibleColumns: InfiniteTableComputedColumn<T>[];
|
|
97
|
-
computedVisibleColumnsMap: Map<string, InfiniteTableComputedColumn<T>>;
|
|
98
|
-
fieldsToColumn: Map<keyof T, InfiniteTableComputedColumn<T>>;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
type GetComputedVisibleColumnsParam<T> = {
|
|
102
|
-
columns: Map<string, InfiniteTableColumn<T>>;
|
|
103
|
-
|
|
104
|
-
bodySize: Size;
|
|
105
|
-
columnMinWidth?: number;
|
|
106
|
-
columnMaxWidth?: number;
|
|
107
|
-
pinnedStartMaxWidth?: number;
|
|
108
|
-
pinnedEndMaxWidth?: number;
|
|
109
|
-
columnDefaultWidth?: number;
|
|
110
|
-
viewportReservedWidth?: number;
|
|
111
|
-
resizableColumns: boolean | undefined;
|
|
112
|
-
|
|
113
|
-
columnCssEllipsis: boolean;
|
|
114
|
-
columnHeaderCssEllipsis: boolean;
|
|
115
|
-
|
|
116
|
-
scrollbarWidth: number | undefined;
|
|
117
|
-
|
|
118
|
-
filterValue?: DataSourcePropFilterValue<T>;
|
|
119
|
-
|
|
120
|
-
sortable?: boolean;
|
|
121
|
-
multiSort: boolean;
|
|
122
|
-
sortInfo?: DataSourceSingleSortInfo<T>[];
|
|
123
|
-
setSortInfo: (sortInfo: DataSourceSingleSortInfo<T>[]) => void;
|
|
124
|
-
|
|
125
|
-
draggableColumns?: boolean;
|
|
126
|
-
columnOrder: InfiniteTablePropColumnOrder;
|
|
127
|
-
columnPinning: InfiniteTablePropColumnPinning;
|
|
128
|
-
columnSizing: InfiniteTablePropColumnSizing;
|
|
129
|
-
columnTypes: InfiniteTablePropColumnTypes<T>;
|
|
130
|
-
columnVisibility: InfiniteTablePropColumnVisibility;
|
|
131
|
-
columnVisibilityAssumeVisible: boolean;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
function isGroupColumnSortable<T>(
|
|
135
|
-
column: InfiniteTableComputedColumn<T>,
|
|
136
|
-
columns: Map<string, InfiniteTableComputedColumn<T>>,
|
|
137
|
-
) {
|
|
138
|
-
let sortableColumnOrType = column.sortable ?? column.colType.sortable;
|
|
139
|
-
|
|
140
|
-
if (sortableColumnOrType != null) {
|
|
141
|
-
return sortableColumnOrType;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (column.computedSortable === false) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let groupByField = column.groupByField || [];
|
|
149
|
-
if (groupByField != null && !Array.isArray(groupByField)) {
|
|
150
|
-
groupByField = [groupByField];
|
|
151
|
-
}
|
|
152
|
-
const fields = (groupByField || []).reduce((acc, field: string) => {
|
|
153
|
-
acc[field] = true;
|
|
154
|
-
return acc;
|
|
155
|
-
}, {} as Record<string, boolean>);
|
|
156
|
-
|
|
157
|
-
const groupColumns: InfiniteTableComputedColumn<T>[] = [];
|
|
158
|
-
columns.forEach((col) => {
|
|
159
|
-
if (col.field && fields[col.field as string]) {
|
|
160
|
-
groupColumns.push(col);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
return groupColumns.reduce((sortable, col) => {
|
|
165
|
-
return sortable && col.computedSortable === true;
|
|
166
|
-
}, true as boolean);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export const getComputedVisibleColumns = <T extends unknown>({
|
|
170
|
-
columns,
|
|
171
|
-
|
|
172
|
-
bodySize,
|
|
173
|
-
columnMinWidth,
|
|
174
|
-
columnMaxWidth,
|
|
175
|
-
columnDefaultWidth,
|
|
176
|
-
scrollbarWidth,
|
|
177
|
-
columnCssEllipsis,
|
|
178
|
-
columnHeaderCssEllipsis,
|
|
179
|
-
pinnedStartMaxWidth,
|
|
180
|
-
pinnedEndMaxWidth,
|
|
181
|
-
filterValue,
|
|
182
|
-
sortable,
|
|
183
|
-
sortInfo,
|
|
184
|
-
setSortInfo,
|
|
185
|
-
multiSort,
|
|
186
|
-
|
|
187
|
-
viewportReservedWidth,
|
|
188
|
-
resizableColumns,
|
|
189
|
-
|
|
190
|
-
draggableColumns,
|
|
191
|
-
columnOrder,
|
|
192
|
-
columnPinning,
|
|
193
|
-
columnSizing,
|
|
194
|
-
columnTypes,
|
|
195
|
-
columnVisibility,
|
|
196
|
-
columnVisibilityAssumeVisible,
|
|
197
|
-
}: GetComputedVisibleColumnsParam<T>): GetComputedVisibleColumnsResult<T> => {
|
|
198
|
-
let computedOffset = 0;
|
|
199
|
-
|
|
200
|
-
const filterValueRecord = (filterValue || []).reduce(
|
|
201
|
-
(acc, filterValueItem) => {
|
|
202
|
-
const { id, field } = filterValueItem;
|
|
203
|
-
|
|
204
|
-
if (field) {
|
|
205
|
-
acc[field as string] = filterValueItem;
|
|
206
|
-
}
|
|
207
|
-
if (id) {
|
|
208
|
-
acc[id] = filterValueItem;
|
|
209
|
-
}
|
|
210
|
-
return acc;
|
|
211
|
-
},
|
|
212
|
-
{} as Record<string, DataSourceFilterValueItem<T>>,
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const normalizedColumnOrder = adjustColumnOrderForPinning(
|
|
216
|
-
columnOrder === true ? [...columns.keys()] : columnOrder,
|
|
217
|
-
columnPinning,
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
const visibleColumnOrder = normalizedColumnOrder.filter((colId) => {
|
|
221
|
-
const col = columns.get(colId);
|
|
222
|
-
if (!col) {
|
|
223
|
-
logError(
|
|
224
|
-
`Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`,
|
|
225
|
-
);
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const result = isColumnVisible(
|
|
230
|
-
columnVisibility,
|
|
231
|
-
columnVisibilityAssumeVisible,
|
|
232
|
-
colId,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
return result;
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
const columnIdsToVisibleIndex: Map<string, number> = new Map();
|
|
239
|
-
|
|
240
|
-
const visibleColumnsArray: InfiniteTableColumn<T>[] = visibleColumnOrder.map(
|
|
241
|
-
(columnId, index) => {
|
|
242
|
-
const col = columns.get(columnId)!;
|
|
243
|
-
|
|
244
|
-
columnIdsToVisibleIndex.set(columnId, index);
|
|
245
|
-
|
|
246
|
-
return col;
|
|
247
|
-
},
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
const sortedMap = (sortInfo ?? []).reduce(
|
|
251
|
-
(acc: SortInfoMap<T>, info: DataSourceSingleSortInfo<T>, index) => {
|
|
252
|
-
if (info.id) {
|
|
253
|
-
acc[info.id] = { sortInfo: info, index };
|
|
254
|
-
} else if (info.field) {
|
|
255
|
-
acc[info.field as unknown as keyof SortInfoMap<T>] = {
|
|
256
|
-
sortInfo: info,
|
|
257
|
-
index,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
return acc;
|
|
261
|
-
},
|
|
262
|
-
{} as SortInfoMap<T>,
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
type ColSizeOptions = {
|
|
266
|
-
flex?: number;
|
|
267
|
-
size?: number;
|
|
268
|
-
minSize?: number;
|
|
269
|
-
maxSize?: number;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
function getColSize(
|
|
273
|
-
colId: string,
|
|
274
|
-
): RequireAtLeastOne<ColSizeOptions, 'flex' | 'size'> {
|
|
275
|
-
const column = columns.get(colId);
|
|
276
|
-
const colType = getColumnComputedType(column!, columnTypes);
|
|
277
|
-
const colTypeSizing: InfiniteTableColumnSizingOptions = {
|
|
278
|
-
minWidth: colType?.minWidth,
|
|
279
|
-
maxWidth: colType?.maxWidth,
|
|
280
|
-
width: colType?.defaultWidth,
|
|
281
|
-
flex: colType?.defaultFlex,
|
|
282
|
-
};
|
|
283
|
-
let colSizing = assignNonNull(
|
|
284
|
-
{
|
|
285
|
-
width: column?.defaultWidth,
|
|
286
|
-
flex: column?.defaultFlex,
|
|
287
|
-
minWidth: column?.minWidth,
|
|
288
|
-
maxWidth: column?.maxWidth,
|
|
289
|
-
},
|
|
290
|
-
columnSizing[colId],
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
// if colSizing has width
|
|
294
|
-
if (colSizing.width != null) {
|
|
295
|
-
// it should ignore coltype flex
|
|
296
|
-
delete colTypeSizing.flex;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// or if it has flex
|
|
300
|
-
if (colSizing.flex != null) {
|
|
301
|
-
// it should ignore coltype width
|
|
302
|
-
delete colTypeSizing.width;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
colSizing = assignNonNull(colTypeSizing, colSizing);
|
|
306
|
-
|
|
307
|
-
const colFlex: number | undefined = colSizing.flex ?? undefined;
|
|
308
|
-
const colMinWidth =
|
|
309
|
-
colSizing.minWidth ?? column?.minWidth ?? columnMinWidth;
|
|
310
|
-
const colMaxWidth =
|
|
311
|
-
colSizing.maxWidth ?? column?.maxWidth ?? columnMaxWidth;
|
|
312
|
-
|
|
313
|
-
let size =
|
|
314
|
-
colFlex != undefined ? undefined : colSizing.width ?? columnDefaultWidth;
|
|
315
|
-
|
|
316
|
-
if (!size && colFlex == undefined) {
|
|
317
|
-
size = colMinWidth;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return {
|
|
321
|
-
size,
|
|
322
|
-
flex: colFlex!,
|
|
323
|
-
minSize: colMinWidth,
|
|
324
|
-
maxSize: colMaxWidth,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const flexResult = computeFlex({
|
|
329
|
-
availableSize: Math.max(
|
|
330
|
-
bodySize.width -
|
|
331
|
-
(viewportReservedWidth ?? 0) -
|
|
332
|
-
// see #scrollbarverticaltag
|
|
333
|
-
(scrollbarWidth ?? getScrollbarWidth()),
|
|
334
|
-
0,
|
|
335
|
-
),
|
|
336
|
-
|
|
337
|
-
maxSize: columnMaxWidth,
|
|
338
|
-
minSize: columnMinWidth,
|
|
339
|
-
items: visibleColumnOrder.map(getColSize),
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
const { computedSizes, flexSizes, minSizes, maxSizes } = flexResult;
|
|
343
|
-
|
|
344
|
-
const computedPinnedStartColumns: InfiniteTableComputedColumn<T>[] = [];
|
|
345
|
-
const computedPinnedEndColumns: InfiniteTableComputedColumn<T>[] = [];
|
|
346
|
-
const computedUnpinnedColumns: InfiniteTableComputedColumn<T>[] = [];
|
|
347
|
-
|
|
348
|
-
const computedVisibleColumns: InfiniteTableComputedColumn<T>[] = [];
|
|
349
|
-
computedVisibleColumns.length = visibleColumnOrder.length;
|
|
350
|
-
|
|
351
|
-
const computedVisibleColumnsMap: Map<
|
|
352
|
-
string,
|
|
353
|
-
InfiniteTableComputedColumn<T>
|
|
354
|
-
> = new Map();
|
|
355
|
-
|
|
356
|
-
const computedColumnsMap: Map<
|
|
357
|
-
string,
|
|
358
|
-
InfiniteTableComputedColumn<T>
|
|
359
|
-
> = new Map();
|
|
360
|
-
|
|
361
|
-
let computedUnpinnedColumnsWidth = 0;
|
|
362
|
-
let computedPinnedStartColumnsWidth = 0;
|
|
363
|
-
let computedPinnedEndColumnsWidth = 0;
|
|
364
|
-
let prevPinned: InfiniteTableColumnPinnedValues | null = null;
|
|
365
|
-
|
|
366
|
-
const computedPinnedArray: InfiniteTableColumnPinnedValues[] = [];
|
|
367
|
-
|
|
368
|
-
let totalPinnedStartWidth = 0;
|
|
369
|
-
let totalUnpinnedWidth = 0;
|
|
370
|
-
let totalPinnedEndWidth = 0;
|
|
371
|
-
|
|
372
|
-
visibleColumnsArray.forEach((_c, i) => {
|
|
373
|
-
const id = visibleColumnOrder[i];
|
|
374
|
-
const computedWidth = computedSizes[i];
|
|
375
|
-
|
|
376
|
-
const pinned = (computedPinnedArray[i] = getComputedPinned(
|
|
377
|
-
id,
|
|
378
|
-
columnPinning,
|
|
379
|
-
));
|
|
380
|
-
if (pinned === 'start') {
|
|
381
|
-
totalPinnedStartWidth += computedWidth;
|
|
382
|
-
} else if (pinned === 'end') {
|
|
383
|
-
totalPinnedEndWidth += computedWidth;
|
|
384
|
-
} else {
|
|
385
|
-
totalUnpinnedWidth += computedWidth;
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const firstPinnedEndAbsoluteOffset = bodySize.width - totalPinnedEndWidth;
|
|
390
|
-
|
|
391
|
-
const groupColumns: InfiniteTableComputedColumn<T>[] = [];
|
|
392
|
-
|
|
393
|
-
const orderedColumns: Map<string, InfiniteTableColumn<T>> = new Map();
|
|
394
|
-
visibleColumnOrder.forEach((id, index) => {
|
|
395
|
-
const c = visibleColumnsArray[index];
|
|
396
|
-
orderedColumns.set(id, c);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
const columnIdsInitialColumnOrder: string[] = [];
|
|
400
|
-
|
|
401
|
-
columns.forEach((c, key) => {
|
|
402
|
-
columnIdsInitialColumnOrder.push(key);
|
|
403
|
-
if (!orderedColumns.has(key)) {
|
|
404
|
-
orderedColumns.set(key, c);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
const fieldsToColumn: Map<
|
|
409
|
-
keyof T,
|
|
410
|
-
InfiniteTableComputedColumn<T>
|
|
411
|
-
> = new Map();
|
|
412
|
-
|
|
413
|
-
// we need to loop over this in the visibility order
|
|
414
|
-
// as we calculate computedOffset based on previous item
|
|
415
|
-
// and also have a reference
|
|
416
|
-
orderedColumns.forEach((c, id) => {
|
|
417
|
-
let theComputedVisibleIndex = columnIdsToVisibleIndex.get(id);
|
|
418
|
-
|
|
419
|
-
if (theComputedVisibleIndex == undefined) {
|
|
420
|
-
theComputedVisibleIndex = -1;
|
|
421
|
-
}
|
|
422
|
-
const computedVisible = theComputedVisibleIndex != -1;
|
|
423
|
-
|
|
424
|
-
const nextColumnId = visibleColumnOrder[theComputedVisibleIndex + 1];
|
|
425
|
-
const colType = getColumnComputedType(c, columnTypes);
|
|
426
|
-
|
|
427
|
-
const computedVisibleIndex = theComputedVisibleIndex;
|
|
428
|
-
|
|
429
|
-
const sortingInfo = sortedMap[id as string]
|
|
430
|
-
? sortedMap[id as string]
|
|
431
|
-
: c.field
|
|
432
|
-
? sortedMap[c.field as string] ?? null
|
|
433
|
-
: null;
|
|
434
|
-
|
|
435
|
-
const computedSortInfo = sortingInfo?.sortInfo ?? null;
|
|
436
|
-
const computedSorted = !!computedSortInfo;
|
|
437
|
-
const computedSortedAsc = computedSorted && computedSortInfo!.dir === 1;
|
|
438
|
-
const computedSortedDesc = computedSorted && !computedSortedAsc;
|
|
439
|
-
const computedSortIndex = sortingInfo?.index ?? -1;
|
|
440
|
-
|
|
441
|
-
const colSizeForNonVisibleColumn: ColSizeOptions = computedVisible
|
|
442
|
-
? {}
|
|
443
|
-
: getColSize(id);
|
|
444
|
-
|
|
445
|
-
const computedWidth = computedVisible
|
|
446
|
-
? computedSizes[theComputedVisibleIndex]
|
|
447
|
-
: colSizeForNonVisibleColumn.size || 0;
|
|
448
|
-
const computedFlex = computedVisible
|
|
449
|
-
? flexSizes[theComputedVisibleIndex] || null
|
|
450
|
-
: null;
|
|
451
|
-
|
|
452
|
-
const computedMinWidth = computedVisible
|
|
453
|
-
? minSizes[theComputedVisibleIndex] || 0
|
|
454
|
-
: colSizeForNonVisibleColumn.minSize || 0;
|
|
455
|
-
|
|
456
|
-
const computedMaxWidth = computedVisible
|
|
457
|
-
? maxSizes[theComputedVisibleIndex] || 10_000
|
|
458
|
-
: colSizeForNonVisibleColumn.maxSize || 10_000;
|
|
459
|
-
|
|
460
|
-
// const computedComp;
|
|
461
|
-
|
|
462
|
-
// const pinned = columnPinning.get(id);
|
|
463
|
-
const computedPinned = computedVisible
|
|
464
|
-
? getComputedPinned(id, columnPinning)
|
|
465
|
-
: false;
|
|
466
|
-
|
|
467
|
-
const computedLast = computedVisible
|
|
468
|
-
? theComputedVisibleIndex === visibleColumnOrder.length - 1
|
|
469
|
-
: false;
|
|
470
|
-
let computedVisibleIndexInCategory = computedVisibleIndex;
|
|
471
|
-
const computedPinningOffset = computedVisible
|
|
472
|
-
? computedPinned === 'start'
|
|
473
|
-
? computedPinnedStartColumnsWidth
|
|
474
|
-
: computedPinned === 'end'
|
|
475
|
-
? computedPinnedEndColumnsWidth
|
|
476
|
-
: computedOffset - computedPinnedStartColumnsWidth
|
|
477
|
-
: 0;
|
|
478
|
-
|
|
479
|
-
if (computedPinned == 'start') {
|
|
480
|
-
computedVisibleIndexInCategory = computedVisible
|
|
481
|
-
? computedVisibleIndex
|
|
482
|
-
: -1;
|
|
483
|
-
} else if (computedPinned === 'end') {
|
|
484
|
-
computedVisibleIndexInCategory = computedVisible
|
|
485
|
-
? computedVisibleIndex -
|
|
486
|
-
(computedPinnedStartColumns.length + computedUnpinnedColumns.length)
|
|
487
|
-
: -1;
|
|
488
|
-
} else {
|
|
489
|
-
computedVisibleIndexInCategory = computedVisible
|
|
490
|
-
? computedVisibleIndex - computedPinnedStartColumns.length
|
|
491
|
-
: -1;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
const computedAbsoluteOffset = computedVisible
|
|
495
|
-
? computedPinned === 'start' || computedPinned === false
|
|
496
|
-
? computedOffset
|
|
497
|
-
: firstPinnedEndAbsoluteOffset + computedPinnedEndColumnsWidth
|
|
498
|
-
: -1;
|
|
499
|
-
|
|
500
|
-
const computedFirstInCategory = computedVisible
|
|
501
|
-
? computedPinned !== prevPinned
|
|
502
|
-
: false;
|
|
503
|
-
const computedLastInCategory = computedVisible
|
|
504
|
-
? computedLast ||
|
|
505
|
-
computedPinned !== getComputedPinned(nextColumnId, columnPinning)
|
|
506
|
-
: false;
|
|
507
|
-
|
|
508
|
-
const cssEllipsis =
|
|
509
|
-
c.cssEllipsis ?? colType.cssEllipsis ?? columnCssEllipsis;
|
|
510
|
-
|
|
511
|
-
const headerCssEllipsis =
|
|
512
|
-
c.headerCssEllipsis ??
|
|
513
|
-
colType.cssEllipsis ??
|
|
514
|
-
c.cssEllipsis ??
|
|
515
|
-
colType.headerCssEllipsis ??
|
|
516
|
-
columnHeaderCssEllipsis ??
|
|
517
|
-
cssEllipsis;
|
|
518
|
-
|
|
519
|
-
const computedFilterValue = computedVisible
|
|
520
|
-
? filterValueRecord[id] || c.field
|
|
521
|
-
? filterValueRecord[c.field as string] || null
|
|
522
|
-
: null
|
|
523
|
-
: null;
|
|
524
|
-
|
|
525
|
-
const computedFiltered = computedFilterValue != null;
|
|
526
|
-
const computedFilterable =
|
|
527
|
-
c.defaultFilterable ?? colType.defaultFilterable ?? true;
|
|
528
|
-
|
|
529
|
-
const computedDataType =
|
|
530
|
-
c.dataType ||
|
|
531
|
-
colType.dataType ||
|
|
532
|
-
(Array.isArray(c.type) ? c.type[0] : c.type) ||
|
|
533
|
-
'string';
|
|
534
|
-
const computedSortType = c.sortType || colType.sortType || computedDataType;
|
|
535
|
-
const computedFilterType =
|
|
536
|
-
c.filterType || colType.filterType || computedDataType;
|
|
537
|
-
|
|
538
|
-
const field = c.field ?? colType.field;
|
|
539
|
-
const valueGetter = c.valueGetter ?? colType.valueGetter;
|
|
540
|
-
|
|
541
|
-
let sortableColumnOrType = c.sortable ?? colType.sortable;
|
|
542
|
-
|
|
543
|
-
if (
|
|
544
|
-
sortableColumnOrType == null &&
|
|
545
|
-
!(c as InfiniteTableGeneratedGroupColumn<T>).groupByField
|
|
546
|
-
) {
|
|
547
|
-
//not explicitly set, so if no field or valueGetter defined, we'll make this unsortable
|
|
548
|
-
if (field == null && valueGetter == null) {
|
|
549
|
-
sortableColumnOrType = false;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
let computedSortable = sortableColumnOrType ?? sortable ?? true;
|
|
554
|
-
|
|
555
|
-
const result: InfiniteTableComputedColumn<T> = {
|
|
556
|
-
colType,
|
|
557
|
-
align: colType.align,
|
|
558
|
-
computedVisible,
|
|
559
|
-
verticalAlign: colType.verticalAlign,
|
|
560
|
-
defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
|
|
561
|
-
valueGetter,
|
|
562
|
-
valueFormatter: colType.valueFormatter,
|
|
563
|
-
renderValue: colType.renderValue,
|
|
564
|
-
render: colType.render,
|
|
565
|
-
style: colType.style,
|
|
566
|
-
renderMenuIcon: colType.renderMenuIcon,
|
|
567
|
-
renderSortIcon: colType.renderSortIcon,
|
|
568
|
-
renderSelectionCheckBox: colType.renderSelectionCheckBox,
|
|
569
|
-
renderHeaderSelectionCheckBox: colType.renderHeaderSelectionCheckBox,
|
|
570
|
-
headerStyle: colType.headerStyle,
|
|
571
|
-
headerClassName: colType.headerClassName,
|
|
572
|
-
|
|
573
|
-
columnGroup: colType.columnGroup,
|
|
574
|
-
field,
|
|
575
|
-
...c,
|
|
576
|
-
components: {
|
|
577
|
-
...colType.components,
|
|
578
|
-
...c.components,
|
|
579
|
-
},
|
|
580
|
-
computedResizable:
|
|
581
|
-
c.resizable ?? colType.resizable ?? resizableColumns ?? true,
|
|
582
|
-
computedMinWidth,
|
|
583
|
-
computedMaxWidth,
|
|
584
|
-
computedFlex,
|
|
585
|
-
computedDataType,
|
|
586
|
-
computedSortType,
|
|
587
|
-
computedFilterType,
|
|
588
|
-
cssEllipsis,
|
|
589
|
-
headerCssEllipsis,
|
|
590
|
-
computedFilterValue,
|
|
591
|
-
computedFiltered,
|
|
592
|
-
computedFilterable,
|
|
593
|
-
computedWidth,
|
|
594
|
-
computedAbsoluteOffset,
|
|
595
|
-
computedPinningOffset,
|
|
596
|
-
computedVisibleIndexInCategory,
|
|
597
|
-
computedOffset,
|
|
598
|
-
computedSortable,
|
|
599
|
-
computedSortInfo,
|
|
600
|
-
computedSortIndex,
|
|
601
|
-
computedMultiSort: multiSort,
|
|
602
|
-
computedSorted,
|
|
603
|
-
computedSortedAsc,
|
|
604
|
-
computedSortedDesc,
|
|
605
|
-
computedVisibleIndex,
|
|
606
|
-
computedPinned,
|
|
607
|
-
computedDraggable: c.draggable ?? draggableColumns ?? true,
|
|
608
|
-
computedFirstInCategory,
|
|
609
|
-
computedLastInCategory,
|
|
610
|
-
computedFirst: theComputedVisibleIndex === 0,
|
|
611
|
-
computedLast,
|
|
612
|
-
toggleSort: () => {
|
|
613
|
-
const currentSortInfo = computedSortInfo;
|
|
614
|
-
let newColumnSortInfo: DataSourceSingleSortInfo<T> | null;
|
|
615
|
-
|
|
616
|
-
const field = (result.groupByField ? result.groupByField : c.field) as
|
|
617
|
-
| keyof T
|
|
618
|
-
| (keyof T)[];
|
|
619
|
-
if (!currentSortInfo) {
|
|
620
|
-
newColumnSortInfo = {
|
|
621
|
-
dir: 1,
|
|
622
|
-
id,
|
|
623
|
-
field,
|
|
624
|
-
type: computedSortType,
|
|
625
|
-
} as DataSourceSingleSortInfo<T>;
|
|
626
|
-
} else {
|
|
627
|
-
if (computedSortedDesc) {
|
|
628
|
-
newColumnSortInfo = null;
|
|
629
|
-
} else {
|
|
630
|
-
newColumnSortInfo = {
|
|
631
|
-
...computedSortInfo,
|
|
632
|
-
dir: -1,
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
if (field && newColumnSortInfo && !newColumnSortInfo.field) {
|
|
638
|
-
newColumnSortInfo.field = field;
|
|
639
|
-
}
|
|
640
|
-
if (
|
|
641
|
-
c.valueGetter &&
|
|
642
|
-
newColumnSortInfo &&
|
|
643
|
-
!newColumnSortInfo.valueGetter
|
|
644
|
-
) {
|
|
645
|
-
newColumnSortInfo.valueGetter = (data) =>
|
|
646
|
-
c.valueGetter!({ data, field: c.field });
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
let finalSortInfo = sortInfo ? [...sortInfo] : [];
|
|
650
|
-
if (multiSort) {
|
|
651
|
-
if (computedSortIndex === -1) {
|
|
652
|
-
// it should be added to the end
|
|
653
|
-
if (newColumnSortInfo) {
|
|
654
|
-
finalSortInfo.push(newColumnSortInfo);
|
|
655
|
-
}
|
|
656
|
-
} else {
|
|
657
|
-
// it's an existing sort - so should be updated
|
|
658
|
-
finalSortInfo = finalSortInfo
|
|
659
|
-
.map((info, index) => {
|
|
660
|
-
if (index === computedSortIndex) {
|
|
661
|
-
return newColumnSortInfo;
|
|
662
|
-
}
|
|
663
|
-
return info;
|
|
664
|
-
})
|
|
665
|
-
.filter((x) => x != null) as DataSourceSingleSortInfo<T>[];
|
|
666
|
-
}
|
|
667
|
-
} else {
|
|
668
|
-
finalSortInfo = newColumnSortInfo ? [newColumnSortInfo] : [];
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
setSortInfo(finalSortInfo);
|
|
672
|
-
},
|
|
673
|
-
id: id as string,
|
|
674
|
-
header: c.header ?? colType.header ?? c.name ?? c.field,
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
if (computedVisible) {
|
|
678
|
-
computedOffset += computedWidth;
|
|
679
|
-
computedVisibleColumnsMap.set(result.id, result);
|
|
680
|
-
computedVisibleColumns[theComputedVisibleIndex] = result;
|
|
681
|
-
|
|
682
|
-
if (computedPinned === 'start') {
|
|
683
|
-
computedPinnedStartColumns.push(result);
|
|
684
|
-
computedPinnedStartColumnsWidth += result.computedWidth;
|
|
685
|
-
}
|
|
686
|
-
if (computedPinned === 'end') {
|
|
687
|
-
computedPinnedEndColumns.push(result);
|
|
688
|
-
computedPinnedEndColumnsWidth += result.computedWidth;
|
|
689
|
-
}
|
|
690
|
-
if (!computedPinned) {
|
|
691
|
-
computedUnpinnedColumns.push(result);
|
|
692
|
-
computedUnpinnedColumnsWidth += result.computedWidth;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
prevPinned = computedPinned;
|
|
696
|
-
}
|
|
697
|
-
if (result.groupByField) {
|
|
698
|
-
groupColumns.push(result);
|
|
699
|
-
}
|
|
700
|
-
computedColumnsMap.set(result.id, result);
|
|
701
|
-
|
|
702
|
-
if (
|
|
703
|
-
result.field &&
|
|
704
|
-
// for now, do not include group columns
|
|
705
|
-
!result.groupByField &&
|
|
706
|
-
!fieldsToColumn.has(result.field)
|
|
707
|
-
) {
|
|
708
|
-
fieldsToColumn.set(result.field, result);
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
groupColumns.forEach((col) => {
|
|
713
|
-
col.computedSortable = isGroupColumnSortable(col, computedColumnsMap);
|
|
714
|
-
});
|
|
715
|
-
|
|
716
|
-
const computedColumnsMapInInitialOrder = new Map<
|
|
717
|
-
string,
|
|
718
|
-
InfiniteTableComputedColumn<T>
|
|
719
|
-
>();
|
|
720
|
-
columnIdsInitialColumnOrder.forEach((id) => {
|
|
721
|
-
const col = computedColumnsMap.get(id);
|
|
722
|
-
if (col) {
|
|
723
|
-
computedColumnsMapInInitialOrder.set(id, col);
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
computedColumnsMap.forEach((col) => {
|
|
728
|
-
if (!computedColumnsMapInInitialOrder.has(col.id)) {
|
|
729
|
-
computedColumnsMapInInitialOrder.set(col.id, col);
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
const computedPinnedStartWidth =
|
|
734
|
-
pinnedStartMaxWidth != null
|
|
735
|
-
? Math.min(pinnedStartMaxWidth, computedPinnedStartColumnsWidth)
|
|
736
|
-
: computedPinnedStartColumnsWidth;
|
|
737
|
-
const computedPinnedEndWidth =
|
|
738
|
-
pinnedEndMaxWidth != null
|
|
739
|
-
? Math.min(pinnedEndMaxWidth, computedPinnedEndColumnsWidth)
|
|
740
|
-
: computedPinnedEndColumnsWidth;
|
|
741
|
-
|
|
742
|
-
const result: GetComputedVisibleColumnsResult<T> = {
|
|
743
|
-
computedRemainingSpace:
|
|
744
|
-
bodySize.width -
|
|
745
|
-
(totalPinnedStartWidth + totalPinnedEndWidth + totalUnpinnedWidth),
|
|
746
|
-
computedPinnedStartColumnsWidth,
|
|
747
|
-
computedPinnedEndColumnsWidth,
|
|
748
|
-
computedUnpinnedColumnsWidth,
|
|
749
|
-
computedColumnOrder: normalizedColumnOrder,
|
|
750
|
-
computedPinnedStartColumns,
|
|
751
|
-
computedPinnedEndColumns,
|
|
752
|
-
computedUnpinnedOffset: computedPinnedStartColumnsWidth,
|
|
753
|
-
computedPinnedEndOffset:
|
|
754
|
-
computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
|
|
755
|
-
computedUnpinnedColumns,
|
|
756
|
-
computedVisibleColumns,
|
|
757
|
-
|
|
758
|
-
computedColumnsMap,
|
|
759
|
-
computedColumnsMapInInitialOrder,
|
|
760
|
-
computedVisibleColumnsMap,
|
|
761
|
-
computedPinnedEndWidth,
|
|
762
|
-
computedPinnedStartWidth,
|
|
763
|
-
renderSelectionCheckBox: computedVisibleColumns.reduce(
|
|
764
|
-
(bool: boolean, c: InfiniteTableComputedColumn<T>) => {
|
|
765
|
-
return bool || !!c.renderSelectionCheckBox;
|
|
766
|
-
},
|
|
767
|
-
false,
|
|
768
|
-
),
|
|
769
|
-
fieldsToColumn,
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
return result;
|
|
773
|
-
};
|