@infinite-table/infinite-react 0.5.1 → 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 +2 -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,364 +0,0 @@
|
|
|
1
|
-
import { InfiniteTable_RowInfoBase } from '../../../utils/groupAndPivot';
|
|
2
|
-
import { getGroupKeysForDataItem } from '../../../utils/groupAndPivot/getGroupKeysForDataItem';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
DataSourceComponentActions,
|
|
6
|
-
DataSourceState,
|
|
7
|
-
RowSelectionState,
|
|
8
|
-
} from '../../DataSource';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
GetRowSelectionStateConfig,
|
|
12
|
-
RowSelectionStateObject,
|
|
13
|
-
} from '../../DataSource/RowSelectionState';
|
|
14
|
-
|
|
15
|
-
type ArrayOfIds = Pick<InfiniteTable_RowInfoBase<any>, 'id'>[];
|
|
16
|
-
|
|
17
|
-
export type InfiniteTableSelectionApi = {
|
|
18
|
-
get allRowsSelected(): boolean;
|
|
19
|
-
isRowSelected(pk: any, groupKeys?: any[]): boolean;
|
|
20
|
-
isRowDeselected(pk: any, groupKeys?: any[]): boolean;
|
|
21
|
-
|
|
22
|
-
selectRow(pk: any, groupKeys?: any[]): void;
|
|
23
|
-
deselectRow(pk: any, groupKeys?: any[]): void;
|
|
24
|
-
toggleRowSelection(pk: any, groupKeys?: any[]): void;
|
|
25
|
-
|
|
26
|
-
selectGroupRow(groupKeys: any[], children?: ArrayOfIds): void;
|
|
27
|
-
deselectGroupRow(groupKeys: any[], children?: ArrayOfIds): void;
|
|
28
|
-
toggleGroupRowSelection(groupKeys: any[], children?: ArrayOfIds): void;
|
|
29
|
-
|
|
30
|
-
getGroupRowSelectionState(groupKeys: any[]): boolean | null;
|
|
31
|
-
|
|
32
|
-
getSelectedPrimaryKeys(
|
|
33
|
-
rowSelection?: RowSelectionStateObject,
|
|
34
|
-
): (string | number)[];
|
|
35
|
-
selectAll(): void;
|
|
36
|
-
deselectAll(): void;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type GetSelectionApiParam<T> = {
|
|
40
|
-
getDataSourceState: () => DataSourceState<T>;
|
|
41
|
-
dataSourceActions: {
|
|
42
|
-
rowSelection: DataSourceComponentActions<T>['rowSelection'];
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export function cloneRowSelection<T>(
|
|
47
|
-
rowSelection: RowSelectionState<T> | RowSelectionStateObject,
|
|
48
|
-
stateOrGetDataSourceState: DataSourceState<T> | (() => DataSourceState<T>),
|
|
49
|
-
) {
|
|
50
|
-
return new RowSelectionState<T>(
|
|
51
|
-
rowSelection,
|
|
52
|
-
rowSelectionStateConfigGetter(stateOrGetDataSourceState),
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function rowSelectionStateConfigGetter<T>(
|
|
57
|
-
stateOrStateGetter: DataSourceState<T> | (() => DataSourceState<T>),
|
|
58
|
-
): GetRowSelectionStateConfig<T> {
|
|
59
|
-
return () => {
|
|
60
|
-
const state =
|
|
61
|
-
typeof stateOrStateGetter === 'function'
|
|
62
|
-
? stateOrStateGetter()
|
|
63
|
-
: stateOrStateGetter;
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
lazyLoad: !!state.lazyLoad,
|
|
67
|
-
toPrimaryKey: state.toPrimaryKey,
|
|
68
|
-
onlyUsePrimaryKeys: !state.useGroupKeysForMultiRowSelection,
|
|
69
|
-
groupBy: state.groupBy,
|
|
70
|
-
groupDeepMap: state.groupDeepMap,
|
|
71
|
-
indexer: state.indexer,
|
|
72
|
-
totalCount: state.unfilteredCount,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function getSelectionApi<T>(
|
|
78
|
-
param: GetSelectionApiParam<T>,
|
|
79
|
-
): InfiniteTableSelectionApi {
|
|
80
|
-
const {
|
|
81
|
-
// getComputed,
|
|
82
|
-
// getState,
|
|
83
|
-
getDataSourceState,
|
|
84
|
-
// componentActions,
|
|
85
|
-
dataSourceActions,
|
|
86
|
-
} = param;
|
|
87
|
-
|
|
88
|
-
const selectionApi = {
|
|
89
|
-
get allRowsSelected() {
|
|
90
|
-
return getDataSourceState().allRowsSelected;
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
selectAll() {
|
|
94
|
-
const { rowSelection, selectionMode } = getDataSourceState();
|
|
95
|
-
|
|
96
|
-
if (selectionMode !== 'multi-row') {
|
|
97
|
-
throw 'Selection mode is not multi-row';
|
|
98
|
-
}
|
|
99
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
100
|
-
throw 'Invalid row selection';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const rowSelectionState = new RowSelectionState(
|
|
104
|
-
rowSelection as RowSelectionState<string>,
|
|
105
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
rowSelectionState.selectAll();
|
|
109
|
-
|
|
110
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
deselectAll() {
|
|
114
|
-
const { rowSelection, selectionMode } = getDataSourceState();
|
|
115
|
-
|
|
116
|
-
if (selectionMode !== 'multi-row') {
|
|
117
|
-
throw 'Selection mode is not multi-row';
|
|
118
|
-
}
|
|
119
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
120
|
-
throw 'Invalid row selection';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const rowSelectionState = new RowSelectionState(
|
|
124
|
-
rowSelection as RowSelectionState<string>,
|
|
125
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
rowSelectionState.deselectAll();
|
|
129
|
-
|
|
130
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
131
|
-
},
|
|
132
|
-
isRowSelected(pk: any, groupKeys?: any[]) {
|
|
133
|
-
const { rowSelection, selectionMode, indexer, groupBy } =
|
|
134
|
-
getDataSourceState();
|
|
135
|
-
|
|
136
|
-
if (selectionMode === 'single-row') {
|
|
137
|
-
return rowSelection === pk;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (selectionMode !== 'multi-row') {
|
|
141
|
-
throw 'Selection mode is not multi-row or single-row';
|
|
142
|
-
}
|
|
143
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
144
|
-
throw 'Invalid row selection';
|
|
145
|
-
}
|
|
146
|
-
if (!groupKeys) {
|
|
147
|
-
const data = indexer.getDataForPrimaryKey(pk);
|
|
148
|
-
groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return rowSelection.isRowSelected(pk, groupKeys);
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
isRowDeselected(pk: any, groupKeys?: any[]) {
|
|
155
|
-
return !this.isRowSelected(pk, groupKeys);
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
selectRow(pk: any, groupKeys?: any[]) {
|
|
159
|
-
const { rowSelection, selectionMode, indexer, groupBy } =
|
|
160
|
-
getDataSourceState();
|
|
161
|
-
|
|
162
|
-
if (selectionMode === 'single-row') {
|
|
163
|
-
dataSourceActions.rowSelection = pk;
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (selectionMode !== 'multi-row') {
|
|
168
|
-
throw 'Selection mode is not multi-row or single-row';
|
|
169
|
-
}
|
|
170
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
171
|
-
throw 'Invalid row selection';
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (!groupKeys) {
|
|
175
|
-
const data = indexer.getDataForPrimaryKey(pk);
|
|
176
|
-
groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const rowSelectionState = new RowSelectionState(
|
|
180
|
-
rowSelection,
|
|
181
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
rowSelectionState.selectRow(pk, groupKeys);
|
|
185
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
deselectRow(pk: any, groupKeys?: any[]) {
|
|
189
|
-
const { selectionMode, rowSelection, indexer, groupBy } =
|
|
190
|
-
getDataSourceState();
|
|
191
|
-
|
|
192
|
-
if (selectionMode === 'single-row') {
|
|
193
|
-
dataSourceActions.rowSelection = null;
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (selectionMode !== 'multi-row') {
|
|
198
|
-
throw 'Selection mode is not multi-row or single-row';
|
|
199
|
-
}
|
|
200
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
201
|
-
throw 'Invalid row selection';
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (selectionMode === 'multi-row') {
|
|
205
|
-
if (!groupKeys) {
|
|
206
|
-
const data = indexer.getDataForPrimaryKey(pk);
|
|
207
|
-
groupKeys = data ? getGroupKeysForDataItem(data, groupBy) : [];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const rowSelectionState = new RowSelectionState(
|
|
211
|
-
rowSelection,
|
|
212
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
rowSelectionState.deselectRow(pk, groupKeys);
|
|
216
|
-
|
|
217
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
toggleRowSelection(pk: any, groupKeys?: any[]) {
|
|
221
|
-
if (this.isRowSelected(pk, groupKeys)) {
|
|
222
|
-
this.deselectRow(pk, groupKeys);
|
|
223
|
-
} else {
|
|
224
|
-
this.selectRow(pk, groupKeys);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
selectGroupRow(groupKeys: any[]) {
|
|
229
|
-
const { selectionMode, rowSelection, groupBy } = getDataSourceState();
|
|
230
|
-
|
|
231
|
-
if (selectionMode !== 'multi-row') {
|
|
232
|
-
throw 'Selection mode should be "multi-row"';
|
|
233
|
-
}
|
|
234
|
-
if (!groupBy) {
|
|
235
|
-
throw 'No grouping specified';
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
239
|
-
throw 'Invalid row selection';
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const rowSelectionState = new RowSelectionState(
|
|
243
|
-
rowSelection,
|
|
244
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
rowSelectionState.selectGroupRow(groupKeys);
|
|
248
|
-
|
|
249
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
deselectGroupRow(groupKeys: any[]) {
|
|
253
|
-
const { selectionMode, rowSelection, groupBy } = getDataSourceState();
|
|
254
|
-
|
|
255
|
-
if (selectionMode !== 'multi-row') {
|
|
256
|
-
throw 'Selection mode should be "multi-row"';
|
|
257
|
-
}
|
|
258
|
-
if (!groupBy) {
|
|
259
|
-
throw 'No grouping specified';
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
263
|
-
throw 'Invalid row selection';
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const rowSelectionState = new RowSelectionState(
|
|
267
|
-
rowSelection,
|
|
268
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
rowSelectionState.deselectGroupRow(groupKeys);
|
|
272
|
-
|
|
273
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
toggleGroupRowSelection(groupKeys: any[]) {
|
|
277
|
-
const { selectionMode, rowSelection, groupBy } = getDataSourceState();
|
|
278
|
-
|
|
279
|
-
if (selectionMode !== 'multi-row') {
|
|
280
|
-
throw 'Selection mode should be "multi-row"';
|
|
281
|
-
}
|
|
282
|
-
if (!groupBy) {
|
|
283
|
-
throw 'No grouping specified';
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (!(rowSelection instanceof RowSelectionState)) {
|
|
287
|
-
throw 'Invalid row selection';
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const rowSelectionState = new RowSelectionState(
|
|
291
|
-
rowSelection,
|
|
292
|
-
rowSelectionStateConfigGetter(getDataSourceState),
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
rowSelectionState.toggleGroupRowSelection(groupKeys);
|
|
296
|
-
|
|
297
|
-
dataSourceActions.rowSelection = rowSelectionState;
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
getGroupRowSelectionState(
|
|
301
|
-
groupKeys: any[],
|
|
302
|
-
rowSelection?: RowSelectionStateObject | RowSelectionState,
|
|
303
|
-
) {
|
|
304
|
-
const state = getDataSourceState();
|
|
305
|
-
const { selectionMode, groupBy } = state;
|
|
306
|
-
|
|
307
|
-
const rowSelectionState = rowSelection
|
|
308
|
-
? new RowSelectionState(
|
|
309
|
-
rowSelection,
|
|
310
|
-
rowSelectionStateConfigGetter(state),
|
|
311
|
-
)
|
|
312
|
-
: (state.rowSelection as RowSelectionState);
|
|
313
|
-
|
|
314
|
-
if (selectionMode !== 'multi-row') {
|
|
315
|
-
throw 'Selection mode should be "multi-row"';
|
|
316
|
-
}
|
|
317
|
-
if (!groupBy) {
|
|
318
|
-
throw 'No grouping specified';
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (!(rowSelectionState instanceof RowSelectionState)) {
|
|
322
|
-
throw 'Invalid row selection';
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return rowSelectionState.getGroupRowSelectionState(groupKeys);
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
getSelectedPrimaryKeys: (
|
|
329
|
-
rowSelection?: RowSelectionStateObject | RowSelectionState,
|
|
330
|
-
) => {
|
|
331
|
-
const state = getDataSourceState();
|
|
332
|
-
const rowSelectionState = rowSelection
|
|
333
|
-
? new RowSelectionState(
|
|
334
|
-
rowSelection,
|
|
335
|
-
rowSelectionStateConfigGetter(state),
|
|
336
|
-
)
|
|
337
|
-
: (state.rowSelection as RowSelectionState);
|
|
338
|
-
|
|
339
|
-
const selected: (string | number)[] = [];
|
|
340
|
-
|
|
341
|
-
if (state.lazyLoad) {
|
|
342
|
-
console.error(
|
|
343
|
-
`getSelectedPrimaryKeys should not be called for lazy-loaded datasources as it wont return reliable results`,
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// we can't iterate over state.dataArray as that has collapsed rows
|
|
348
|
-
// and wont reflect all the rows in the dataset
|
|
349
|
-
state.originalDataArray.forEach((data) => {
|
|
350
|
-
const id = state.toPrimaryKey(data);
|
|
351
|
-
if (rowSelectionState.isRowSelected(id)) {
|
|
352
|
-
selected.push(id);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
return selected;
|
|
357
|
-
},
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
if (__DEV__) {
|
|
361
|
-
(globalThis as any).selectionApi = selectionApi;
|
|
362
|
-
}
|
|
363
|
-
return selectionApi;
|
|
364
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DataSourceState, DataSourceComponentActions } from '../../DataSource';
|
|
2
|
-
import { InfiniteTableComputedValues, InfiniteTableState } from '../types';
|
|
3
|
-
import { InfiniteTableActions } from '../types/InfiniteTableState';
|
|
4
|
-
|
|
5
|
-
export type GetImperativeApiParam<T> = {
|
|
6
|
-
getComputed: () => InfiniteTableComputedValues<T>;
|
|
7
|
-
getState: () => InfiniteTableState<T>;
|
|
8
|
-
getDataSourceState: () => DataSourceState<T>;
|
|
9
|
-
componentActions: InfiniteTableActions<T>;
|
|
10
|
-
dataSourceActions: DataSourceComponentActions<T>;
|
|
11
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { fallbackVar, style, styleVariants } from '@vanilla-extract/css';
|
|
2
|
-
|
|
3
|
-
import { ThemeVars } from '../theme.css';
|
|
4
|
-
import {
|
|
5
|
-
left,
|
|
6
|
-
top,
|
|
7
|
-
pointerEvents,
|
|
8
|
-
position,
|
|
9
|
-
height,
|
|
10
|
-
zIndex,
|
|
11
|
-
} from '../utilities.css';
|
|
12
|
-
|
|
13
|
-
export const ActiveIndicatorWrapperCls = style([
|
|
14
|
-
pointerEvents.none,
|
|
15
|
-
position.sticky,
|
|
16
|
-
left['0'],
|
|
17
|
-
top['0'],
|
|
18
|
-
height['0'],
|
|
19
|
-
zIndex[1_000_000],
|
|
20
|
-
]);
|
|
21
|
-
export const ActiveCellIndicatorBaseCls = style(
|
|
22
|
-
[
|
|
23
|
-
pointerEvents.none,
|
|
24
|
-
position.sticky,
|
|
25
|
-
left['0'],
|
|
26
|
-
top['0'],
|
|
27
|
-
{
|
|
28
|
-
border: fallbackVar(
|
|
29
|
-
ThemeVars.components.Cell.activeBorder,
|
|
30
|
-
|
|
31
|
-
`${ThemeVars.components.Cell.activeBorderWidth} ${
|
|
32
|
-
ThemeVars.components.Cell.activeBorderStyle
|
|
33
|
-
} ${fallbackVar(
|
|
34
|
-
ThemeVars.components.Cell.activeBorderColor,
|
|
35
|
-
`rgb(${ThemeVars.components.Cell.activeBorderColor_R} ${ThemeVars.components.Cell.activeBorderColor_G} ${ThemeVars.components.Cell.activeBorderColor_B})`,
|
|
36
|
-
)}`,
|
|
37
|
-
),
|
|
38
|
-
|
|
39
|
-
background: fallbackVar(
|
|
40
|
-
ThemeVars.components.Cell.activeBackground,
|
|
41
|
-
`rgba(${ThemeVars.components.Cell.activeBorderColor_R}, ${ThemeVars.components.Cell.activeBorderColor_G}, ${ThemeVars.components.Cell.activeBorderColor_B}, ${ThemeVars.components.Cell.activeBackgroundAlpha})`,
|
|
42
|
-
),
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
'ActiveCellIndicator',
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
export const ActiveCellIndicatorCls = styleVariants({
|
|
49
|
-
visible: [ActiveCellIndicatorBaseCls, { display: 'block' }],
|
|
50
|
-
hidden: [ActiveCellIndicatorBaseCls, { display: 'none' }],
|
|
51
|
-
});
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useEffect, useLayoutEffect, useRef, CSSProperties } from 'react';
|
|
3
|
-
import { stripVar } from '../../../utils/stripVar';
|
|
4
|
-
import { useRerender } from '../../hooks/useRerender';
|
|
5
|
-
import { MatrixBrain } from '../../VirtualBrain/MatrixBrain';
|
|
6
|
-
|
|
7
|
-
import { internalProps } from '../internalProps';
|
|
8
|
-
import { InternalVars } from '../theme.css';
|
|
9
|
-
import { setInfiniteVarsOnNode } from '../utils/infiniteDOMUtils';
|
|
10
|
-
import {
|
|
11
|
-
ActiveCellIndicatorCls,
|
|
12
|
-
ActiveIndicatorWrapperCls,
|
|
13
|
-
} from './ActiveCellIndicator.css';
|
|
14
|
-
|
|
15
|
-
const { rootClassName } = internalProps;
|
|
16
|
-
|
|
17
|
-
const baseCls = `${rootClassName}-ActiveCellIndicator`;
|
|
18
|
-
|
|
19
|
-
const columnZIndexAtIndex = stripVar(InternalVars.columnZIndexAtIndex);
|
|
20
|
-
|
|
21
|
-
export type ActiveCellIndicatorInfo = {
|
|
22
|
-
index: [number, number];
|
|
23
|
-
colOffset: number;
|
|
24
|
-
colWidth: number;
|
|
25
|
-
};
|
|
26
|
-
type ActiveCellIndicatorProps = {
|
|
27
|
-
activeCellIndex?: [number, number] | null;
|
|
28
|
-
brain: MatrixBrain;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const ActiveStyle: CSSProperties = {
|
|
32
|
-
[stripVar(InternalVars.activeCellOffsetX)]: InternalVars.activeCellColOffset,
|
|
33
|
-
[stripVar(InternalVars.activeCellOffsetY)]: InternalVars.activeCellRowOffset,
|
|
34
|
-
|
|
35
|
-
transform: `translate3d(${InternalVars.activeCellOffsetX}, ${InternalVars.activeCellOffsetY}, 0px)`,
|
|
36
|
-
|
|
37
|
-
width: InternalVars.activeCellColWidth,
|
|
38
|
-
height: InternalVars.activeCellRowHeight,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const ActiveCellIndicatorFn = (props: ActiveCellIndicatorProps) => {
|
|
42
|
-
const { brain } = props;
|
|
43
|
-
const [_rerenderId, rerender] = useRerender();
|
|
44
|
-
|
|
45
|
-
const domRef = useRef<HTMLDivElement>(null);
|
|
46
|
-
|
|
47
|
-
const active =
|
|
48
|
-
props.activeCellIndex != null &&
|
|
49
|
-
brain.getRowCount() > props.activeCellIndex[0];
|
|
50
|
-
|
|
51
|
-
useLayoutEffect(() => {
|
|
52
|
-
if (props.activeCellIndex == null) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const rowIndex = props.activeCellIndex[0];
|
|
57
|
-
const activeCellRowHeight = brain.getRowHeight(rowIndex);
|
|
58
|
-
const activeCellRowOffset = brain.getItemOffsetFor(rowIndex, 'vertical');
|
|
59
|
-
|
|
60
|
-
const node = domRef.current!;
|
|
61
|
-
|
|
62
|
-
setInfiniteVarsOnNode(
|
|
63
|
-
{
|
|
64
|
-
activeCellRowHeight: `${activeCellRowHeight}px`,
|
|
65
|
-
activeCellRowOffset: `${activeCellRowOffset}px`,
|
|
66
|
-
},
|
|
67
|
-
node,
|
|
68
|
-
);
|
|
69
|
-
}, [props.activeCellIndex]);
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const removeOnRenderCountChange = brain.onRenderCountChange(() => {
|
|
73
|
-
rerender();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// const removeOnAvailableSizeChange = brain.onAvailableSizeChange(() => {
|
|
77
|
-
// rerender();
|
|
78
|
-
// });
|
|
79
|
-
|
|
80
|
-
return () => {
|
|
81
|
-
removeOnRenderCountChange();
|
|
82
|
-
};
|
|
83
|
-
}, [brain]);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
// #correct-scroll-size this wrapper is here in order to make the indicator not take up space in the scroll container - to reproduce: remove this and click on a row, you will see that if you scroll at the bottom, there is extra space
|
|
87
|
-
<div
|
|
88
|
-
className={ActiveIndicatorWrapperCls}
|
|
89
|
-
data-name="active-cell"
|
|
90
|
-
style={
|
|
91
|
-
active
|
|
92
|
-
? {
|
|
93
|
-
zIndex: `var(${columnZIndexAtIndex}-${
|
|
94
|
-
props.activeCellIndex![1]
|
|
95
|
-
})`,
|
|
96
|
-
}
|
|
97
|
-
: undefined
|
|
98
|
-
}
|
|
99
|
-
>
|
|
100
|
-
<div
|
|
101
|
-
ref={domRef}
|
|
102
|
-
data-name="active-cell-indicator"
|
|
103
|
-
className={`${baseCls} ${
|
|
104
|
-
active
|
|
105
|
-
? ActiveCellIndicatorCls.visible
|
|
106
|
-
: ActiveCellIndicatorCls.hidden
|
|
107
|
-
}`}
|
|
108
|
-
style={active ? ActiveStyle : undefined}
|
|
109
|
-
></div>
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const ActiveCellIndicator = React.memo(
|
|
115
|
-
ActiveCellIndicatorFn,
|
|
116
|
-
) as typeof ActiveCellIndicatorFn;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { fallbackVar, style, styleVariants } from '@vanilla-extract/css';
|
|
2
|
-
|
|
3
|
-
import { ThemeVars } from '../theme.css';
|
|
4
|
-
import { left, top, pointerEvents, position, width } from '../utilities.css';
|
|
5
|
-
|
|
6
|
-
export const ActiveRowIndicatorBaseCls = style(
|
|
7
|
-
[
|
|
8
|
-
pointerEvents.none,
|
|
9
|
-
position.sticky,
|
|
10
|
-
width['100%'],
|
|
11
|
-
top['0'],
|
|
12
|
-
left['0'],
|
|
13
|
-
{
|
|
14
|
-
border: fallbackVar(
|
|
15
|
-
ThemeVars.components.Row.activeBorder,
|
|
16
|
-
`${fallbackVar(
|
|
17
|
-
ThemeVars.components.Row.activeBorderWidth,
|
|
18
|
-
ThemeVars.components.Cell.activeBorderWidth,
|
|
19
|
-
)} ${fallbackVar(
|
|
20
|
-
ThemeVars.components.Row.activeBorderStyle,
|
|
21
|
-
ThemeVars.components.Cell.activeBorderStyle,
|
|
22
|
-
)} ${fallbackVar(
|
|
23
|
-
ThemeVars.components.Row.activeBorderColor,
|
|
24
|
-
`rgb(${ThemeVars.components.Cell.activeBorderColor_R} ${ThemeVars.components.Cell.activeBorderColor_G} ${ThemeVars.components.Cell.activeBorderColor_B})`,
|
|
25
|
-
)}`,
|
|
26
|
-
),
|
|
27
|
-
background: fallbackVar(
|
|
28
|
-
ThemeVars.components.Row.activeBackground,
|
|
29
|
-
ThemeVars.components.Cell.activeBackground,
|
|
30
|
-
`rgba(${ThemeVars.components.Cell.activeBorderColor_R}, ${
|
|
31
|
-
ThemeVars.components.Cell.activeBorderColor_G
|
|
32
|
-
}, ${ThemeVars.components.Cell.activeBorderColor_B}, ${fallbackVar(
|
|
33
|
-
ThemeVars.components.Row.activeBackgroundAlpha,
|
|
34
|
-
ThemeVars.components.Cell.activeBackgroundAlpha,
|
|
35
|
-
)})`,
|
|
36
|
-
),
|
|
37
|
-
vars: {
|
|
38
|
-
[ThemeVars.components.Row.activeBorderStyle]: fallbackVar(
|
|
39
|
-
ThemeVars.components.Row.activeBorderStyle,
|
|
40
|
-
ThemeVars.components.Cell.activeBorderStyle,
|
|
41
|
-
),
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
'ActiveRowIndicator',
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
export const ActiveRowIndicatorCls = styleVariants({
|
|
49
|
-
visible: [
|
|
50
|
-
ActiveRowIndicatorBaseCls,
|
|
51
|
-
{
|
|
52
|
-
display: 'block',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
hidden: [ActiveRowIndicatorBaseCls, { display: 'none' }],
|
|
56
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { CSSProperties, useEffect, useLayoutEffect, useRef } from 'react';
|
|
3
|
-
import { stripVar } from '../../../utils/stripVar';
|
|
4
|
-
import { useRerender } from '../../hooks/useRerender';
|
|
5
|
-
import { MatrixBrain } from '../../VirtualBrain/MatrixBrain';
|
|
6
|
-
|
|
7
|
-
import { internalProps } from '../internalProps';
|
|
8
|
-
import { InternalVars } from '../theme.css';
|
|
9
|
-
import { setInfiniteVarsOnNode } from '../utils/infiniteDOMUtils';
|
|
10
|
-
import { ActiveIndicatorWrapperCls } from './ActiveCellIndicator.css';
|
|
11
|
-
import { ActiveRowIndicatorCls } from './ActiveRowIndicator.css';
|
|
12
|
-
|
|
13
|
-
const { rootClassName } = internalProps;
|
|
14
|
-
const baseCls = `${rootClassName}-ActiveRowIndicator`;
|
|
15
|
-
|
|
16
|
-
type ActiveRowIndicatorProps = {
|
|
17
|
-
activeRowIndex?: number | null;
|
|
18
|
-
brain: MatrixBrain;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const ActiveStyle: CSSProperties = {
|
|
22
|
-
[stripVar(InternalVars.activeCellOffsetY)]: InternalVars.activeCellRowOffset,
|
|
23
|
-
|
|
24
|
-
transform: `translate3d(0px, calc( ${
|
|
25
|
-
InternalVars.activeCellOffsetY
|
|
26
|
-
} + var(${stripVar(InternalVars.scrollTopForActiveRow)}, 0px)), 0px)`,
|
|
27
|
-
height: InternalVars.activeCellRowHeight,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const ActiveRowIndicatorFn = (props: ActiveRowIndicatorProps) => {
|
|
31
|
-
const { brain } = props;
|
|
32
|
-
|
|
33
|
-
const domRef = useRef<HTMLDivElement>(null);
|
|
34
|
-
|
|
35
|
-
const active =
|
|
36
|
-
props.activeRowIndex != null && brain.getRowCount() > props.activeRowIndex;
|
|
37
|
-
|
|
38
|
-
const [_rerenderId, rerender] = useRerender();
|
|
39
|
-
|
|
40
|
-
useLayoutEffect(() => {
|
|
41
|
-
if (props.activeRowIndex == null) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const rowIndex = props.activeRowIndex;
|
|
46
|
-
const activeCellRowHeight = brain.getRowHeight(rowIndex);
|
|
47
|
-
const activeCellRowOffset = brain.getItemOffsetFor(rowIndex, 'vertical');
|
|
48
|
-
|
|
49
|
-
const node = domRef.current!;
|
|
50
|
-
|
|
51
|
-
const vars = {
|
|
52
|
-
activeCellRowHeight: `${activeCellRowHeight}px`,
|
|
53
|
-
activeCellRowOffset: `${activeCellRowOffset}px`,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
setInfiniteVarsOnNode(vars, node);
|
|
57
|
-
}, [props.activeRowIndex]);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const removeOnScroll = brain.onScroll((scrollPosition) => {
|
|
61
|
-
setInfiniteVarsOnNode(
|
|
62
|
-
{
|
|
63
|
-
scrollTopForActiveRow: `${-scrollPosition.scrollTop}px`,
|
|
64
|
-
},
|
|
65
|
-
domRef.current!,
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const removeOnRenderCountChange = brain.onRenderCountChange(rerender);
|
|
70
|
-
|
|
71
|
-
return () => {
|
|
72
|
-
removeOnRenderCountChange();
|
|
73
|
-
removeOnScroll();
|
|
74
|
-
};
|
|
75
|
-
}, [brain]);
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
// #correct-scroll-size this wrapper is here in order to make the indicator not take up space in the scroll container - to reproduce: remove this and click on a row, you will see that if you scroll at the bottom, there is extra space
|
|
79
|
-
<div className={ActiveIndicatorWrapperCls} data-name="active-row">
|
|
80
|
-
<div
|
|
81
|
-
ref={domRef}
|
|
82
|
-
data-name="active-row-indicator"
|
|
83
|
-
className={`${baseCls} ${
|
|
84
|
-
active ? ActiveRowIndicatorCls.visible : ActiveRowIndicatorCls.hidden
|
|
85
|
-
}`}
|
|
86
|
-
style={active ? ActiveStyle : undefined}
|
|
87
|
-
></div>
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const ActiveRowIndicator = React.memo(
|
|
93
|
-
ActiveRowIndicatorFn,
|
|
94
|
-
) as typeof ActiveRowIndicatorFn;
|