@infinite-table/infinite-react 10.2.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { CSSProperties, HTMLAttributes, MutableRefObject, ComponentType, HTMLProps, RefCallback, KeyboardEvent, MouseEvent, ReactNode, FocusEvent, EffectCallback, DependencyList } from 'react';
2
+ import React__default, { CSSProperties, HTMLAttributes, MutableRefObject, ComponentType, HTMLProps, RefCallback, KeyboardEvent, MouseEvent, FocusEvent, ReactNode, EffectCallback, DependencyList } from 'react';
3
3
 
4
4
  /**
5
5
  * The UI-framework types that the shared type declarations are written
@@ -939,69 +939,6 @@ type ForwardPropsToStateFnResult<TYPE_PROPS, TYPE_RESULT, COMPONENT_SETUP_STATE>
939
939
  [propName in keyof TYPE_PROPS & keyof TYPE_RESULT]: 1 | ((value: TYPE_PROPS[propName], setupState: COMPONENT_SETUP_STATE) => TYPE_RESULT[propName]);
940
940
  };
941
941
 
942
- /**
943
- * React adapter for the managed component state system.
944
- *
945
- * All framework-free logic (controlled/uncontrolled resolution, reducer body,
946
- * generated action setters, prop-diff) lives in ./managedComponentState.ts.
947
- * This file owns React scheduling: useState/useReducer, effects, context.
948
- * Its behavior is pinned by buildManagedComponent.jestspec.tsx.
949
- */
950
-
951
- type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE = {}, COMPONENT_DERIVED_STATE = {}, T_ACTIONS = {}, T_PARENT_STATE = {}> = {
952
- debugName?: string | ((props: T_PROPS) => string);
953
- initSetupState?: (props: T_PROPS) => COMPONENT_SETUP_STATE;
954
- Context?: React.Context<ManagedComponentStateContextValue<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE, ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>>>;
955
- layoutEffect?: boolean;
956
- forwardProps?: (setupState: COMPONENT_SETUP_STATE, props: T_PROPS) => ForwardPropsToStateFnResult<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE>;
957
- allowedControlledPropOverrides?: Record<keyof T_PROPS, true>;
958
- interceptActions?: ComponentInterceptedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
959
- mappedCallbacks?: ComponentMappedCallbacks<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
960
- onPropChange?: (params: {
961
- name: keyof T_PROPS;
962
- oldValue: any;
963
- newValue: any;
964
- }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>, state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>) => void;
965
- onPropsChange?: (newPropValues: {
966
- [k in keyof T_PROPS]?: {
967
- newValue: T_PROPS[k];
968
- oldValue: T_PROPS[k];
969
- };
970
- }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>, state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>) => void;
971
- mapPropsToState?: (params: {
972
- props: T_PROPS;
973
- state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>;
974
- oldState: null | (COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>);
975
- parentState: T_PARENT_STATE | null;
976
- }) => COMPONENT_DERIVED_STATE;
977
- concludeReducer?: (params: {
978
- previousState: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
979
- state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
980
- updatedProps: Partial<T_PROPS> | null;
981
- parentState: T_PARENT_STATE | null;
982
- }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
983
- getReducerActions?: (dispatch: React.Dispatch<any>) => T_ACTIONS;
984
- getParentState?: () => T_PARENT_STATE;
985
- cleanup?: (state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE) => void;
986
- onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
987
- };
988
- declare function buildManagedComponent<T_PROPS extends object, COMPONENT_MAPPED_STATE extends object, COMPONENT_SETUP_STATE extends object = {}, COMPONENT_DERIVED_STATE extends object = {}, T_ACTIONS = {}, T_PARENT_STATE = {}>(config: ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE, COMPONENT_DERIVED_STATE, T_ACTIONS, T_PARENT_STATE>): {
989
- ManagedComponentContextProvider: React.NamedExoticComponent<T_PROPS & {
990
- children?: React.ReactNode;
991
- }>;
992
- useManagedComponent: (props: T_PROPS) => {
993
- contextValue: {
994
- componentState: COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE;
995
- componentActions: ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
996
- getComponentState: () => COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE;
997
- replaceState: (newState: COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE) => void;
998
- assignState: (newState: Partial<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>) => void;
999
- };
1000
- ContextComponent: React.Context<ManagedComponentStateContextValue<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE, ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>>>;
1001
- };
1002
- };
1003
- declare function useManagedComponentState<COMPONENT_STATE>(Context?: React.Context<ManagedComponentStateContextValue<COMPONENT_STATE, ComponentStateActions<COMPONENT_STATE>>>): ManagedComponentStateContextValue<COMPONENT_STATE, ComponentStateGeneratedActions<COMPONENT_STATE>>;
1004
-
1005
942
  type PerfMarkerDetails = {
1006
943
  name: string;
1007
944
  value: string | number | boolean;
@@ -1989,6 +1926,16 @@ declare class GridRenderer extends Logger {
1989
1926
  private scrolling;
1990
1927
  cellHoverClassNames: string[];
1991
1928
  cellDetachedClassNames: string[];
1929
+ /**
1930
+ * Inside InfiniteTable, the table owns the CSS vars that position the
1931
+ * cells horizontally (one offset var per column, plus the scroll position
1932
+ * vars used by pinned cells) and sets them on its root node.
1933
+ *
1934
+ * A HeadlessTable used on its own has nobody to set them. With this on,
1935
+ * the renderer writes each cell's x from the brain, and sets the scroll
1936
+ * position vars itself, on the parent node of the cells.
1937
+ */
1938
+ ownsPositionVars: boolean;
1992
1939
  cellManager: GridCellManager<GridCellAdditionalInfo>;
1993
1940
  protected rowManager: ListRowManager;
1994
1941
  private lastEnteredRow;
@@ -2016,8 +1963,20 @@ declare class GridRenderer extends Logger {
2016
1963
  * as the scroll layer transform, which uses the new origin too.
2017
1964
  */
2018
1965
  private onScrollOriginChange;
1966
+ /**
1967
+ * While a render pass is in progress, the cells it detaches are collected
1968
+ * here and only get the detached class names when the pass ends - if they
1969
+ * are still detached by then.
1970
+ *
1971
+ * Most of the cells detached by a render pass (while scrolling, all of
1972
+ * them) are re-attached at another position by the same pass, so they
1973
+ * would get the class names added and then removed, with no visible effect
1974
+ * - only the cost of the DOM writes and of the style invalidations.
1975
+ */
1976
+ private cellsDetachedInRenderPass;
2019
1977
  private onCellAttached;
2020
1978
  private onCellDetached;
1979
+ private addDetachedClassNames;
2021
1980
  private onRowAttached;
2022
1981
  private onRowDetached;
2023
1982
  getFullyVisibleRowsRange: () => {
@@ -2054,7 +2013,8 @@ declare class GridRenderer extends Logger {
2054
2013
  rendered: boolean;
2055
2014
  mapped: boolean;
2056
2015
  };
2057
- renderRange(range: TableRenderRange, { renderCell, renderDetailRow, force, onRender }: RenderRangeOptions): Renderable[];
2016
+ renderRange(range: TableRenderRange, options: RenderRangeOptions): Renderable[];
2017
+ private renderRangeInternal;
2058
2018
  getFixedRanges: (currentRenderRange: TableRenderRange) => TableRenderRange[];
2059
2019
  protected isCellFixed: (rowIndex: number, colIndex: number) => {
2060
2020
  row: FixedPosition;
@@ -2088,6 +2048,13 @@ declare class GridRenderer extends Logger {
2088
2048
  private updateDetailElementPosition;
2089
2049
  private onScrollStart;
2090
2050
  private onScrollStop;
2051
+ /**
2052
+ * Where a fixed (pinned) cell goes: its x and/or y relative to the viewport
2053
+ * (`scrollLeft` / `scrollTop: true` - see setTransform), and its z-index:
2054
+ * the corners above the pinned rows and columns, those above the cells
2055
+ * scrolling under them. null for a cell that is not fixed.
2056
+ */
2057
+ private getFixedCellPlacement;
2091
2058
  adjustFixedElementsOnScroll: (scrollPosition?: ScrollPosition) => void;
2092
2059
  flushPendingAfterCommitWork: () => void;
2093
2060
  destroy: () => void;
@@ -7411,29 +7378,6 @@ type OverlayShowParams = {
7411
7378
  };
7412
7379
  declare function alignNode(node: HTMLDivElement, params: OverlayShowParams): Promise<void>;
7413
7380
 
7414
- type OverlayParams = {
7415
- portalContainer?: ElementContainerGetter | null | false;
7416
- constrainTo?: OverlayShowParams['constrainTo'];
7417
- };
7418
- /**
7419
- * If portal container is given, it will create a React portal from that element
7420
- * otherwise it will simply render another node as portal
7421
- *
7422
- * @param portalContainer
7423
- */
7424
- declare function useOverlayPortal(content: ReactNode, portalContainer?: ElementContainerGetter | null | false): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
7425
- type UpdateOverlayContentFn = (content: ReactNode | (() => ReactNode), options?: {
7426
- skipRealign?: boolean;
7427
- }) => void;
7428
- type ShowOverlayFn = (content: ReactNode | (() => ReactNode), params: OverlayShowParams) => UpdateOverlayContentFn;
7429
- declare function useOverlay(params: OverlayParams): {
7430
- portal: string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
7431
- hideOverlay: (id: string) => void;
7432
- clearAll: () => void;
7433
- rerenderOverlays: () => void;
7434
- showOverlay: ShowOverlayFn;
7435
- };
7436
-
7437
7381
  /**
7438
7382
 
7439
7383
  We have this utility - it's used in Menu Renderable declaration
@@ -8294,6 +8238,13 @@ declare namespace Menu {
8294
8238
  var __is_infinite_menu_component: boolean;
8295
8239
  }
8296
8240
 
8241
+ /**
8242
+ * Framework-neutral types of the drag and drop between drag lists.
8243
+ *
8244
+ * The DragDropProvider of each framework (DragDropProvider.tsx,
8245
+ * DragDropProvider.vue.ts, ...) re-exports them, and shared modules import
8246
+ * them from here so they never reach a framework's provider component.
8247
+ */
8297
8248
  type DragDropSourceAndTarget = {
8298
8249
  dragSourceListId: string | null;
8299
8250
  dropTargetListId: string | null;
@@ -8304,6 +8255,7 @@ type DragDropProviderContextValue = DragDropSourceAndTarget & {
8304
8255
  updateDragOperationSourceAndTarget: (params: DragDropSourceAndTarget) => void;
8305
8256
  getCurrentDragSourceAndTarget: () => DragDropSourceAndTarget;
8306
8257
  };
8258
+
8307
8259
  declare const useDragDropProvider: () => DragDropProviderContextValue;
8308
8260
  declare const DragDropProvider: (props: {
8309
8261
  children: React.ReactNode | ((context: DragDropProviderContextValue) => React.ReactNode);
@@ -8591,6 +8543,29 @@ declare class AutoScroller {
8591
8543
  stop(): void;
8592
8544
  }
8593
8545
 
8546
+ type OverlayParams = {
8547
+ portalContainer?: ElementContainerGetter | null | false;
8548
+ constrainTo?: OverlayShowParams['constrainTo'];
8549
+ };
8550
+ /**
8551
+ * If portal container is given, it will create a React portal from that element
8552
+ * otherwise it will simply render another node as portal
8553
+ *
8554
+ * @param portalContainer
8555
+ */
8556
+ declare function useOverlayPortal(content: ReactNode, portalContainer?: ElementContainerGetter | null | false): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
8557
+ type UpdateOverlayContentFn = (content: ReactNode | (() => ReactNode), options?: {
8558
+ skipRealign?: boolean;
8559
+ }) => void;
8560
+ type ShowOverlayFn = (content: ReactNode | (() => ReactNode), params: OverlayShowParams) => UpdateOverlayContentFn;
8561
+ declare function useOverlay(params: OverlayParams): {
8562
+ portal: string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
8563
+ hideOverlay: (id: string) => void;
8564
+ clearAll: () => void;
8565
+ rerenderOverlays: () => void;
8566
+ showOverlay: ShowOverlayFn;
8567
+ };
8568
+
8594
8569
  declare function useEffectWithChanges<T>(fn: (changes: Record<keyof T, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<keyof T, any>): void;
8595
8570
  declare function useLayoutEffectWithChanges<T>(fn: (changes: Record<keyof T, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<keyof T, any>): void;
8596
8571
  declare function useEffectWithObject(fn: EffectCallback, deps: Record<string, any>): void;
@@ -8604,6 +8579,69 @@ declare const keyboardShortcuts: {
8604
8579
  instantEdit: InfiniteTablePropKeyboardShorcut;
8605
8580
  };
8606
8581
 
8582
+ /**
8583
+ * React adapter for the managed component state system.
8584
+ *
8585
+ * All framework-free logic (controlled/uncontrolled resolution, reducer body,
8586
+ * generated action setters, prop-diff) lives in ./managedComponentState.ts.
8587
+ * This file owns React scheduling: useState/useReducer, effects, context.
8588
+ * Its behavior is pinned by buildManagedComponent.jestspec.tsx.
8589
+ */
8590
+
8591
+ type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE = {}, COMPONENT_DERIVED_STATE = {}, T_ACTIONS = {}, T_PARENT_STATE = {}> = {
8592
+ debugName?: string | ((props: T_PROPS) => string);
8593
+ initSetupState?: (props: T_PROPS) => COMPONENT_SETUP_STATE;
8594
+ Context?: React.Context<ManagedComponentStateContextValue<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE, ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>>>;
8595
+ layoutEffect?: boolean;
8596
+ forwardProps?: (setupState: COMPONENT_SETUP_STATE, props: T_PROPS) => ForwardPropsToStateFnResult<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE>;
8597
+ allowedControlledPropOverrides?: Record<keyof T_PROPS, true>;
8598
+ interceptActions?: ComponentInterceptedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
8599
+ mappedCallbacks?: ComponentMappedCallbacks<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
8600
+ onPropChange?: (params: {
8601
+ name: keyof T_PROPS;
8602
+ oldValue: any;
8603
+ newValue: any;
8604
+ }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>, state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>) => void;
8605
+ onPropsChange?: (newPropValues: {
8606
+ [k in keyof T_PROPS]?: {
8607
+ newValue: T_PROPS[k];
8608
+ oldValue: T_PROPS[k];
8609
+ };
8610
+ }, props: T_PROPS, actions: ComponentStateActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>, state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>) => void;
8611
+ mapPropsToState?: (params: {
8612
+ props: T_PROPS;
8613
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>;
8614
+ oldState: null | (COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>);
8615
+ parentState: T_PARENT_STATE | null;
8616
+ }) => COMPONENT_DERIVED_STATE;
8617
+ concludeReducer?: (params: {
8618
+ previousState: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
8619
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
8620
+ updatedProps: Partial<T_PROPS> | null;
8621
+ parentState: T_PARENT_STATE | null;
8622
+ }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
8623
+ getReducerActions?: (dispatch: React.Dispatch<any>) => T_ACTIONS;
8624
+ getParentState?: () => T_PARENT_STATE;
8625
+ cleanup?: (state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE) => void;
8626
+ onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
8627
+ };
8628
+ declare function buildManagedComponent<T_PROPS extends object, COMPONENT_MAPPED_STATE extends object, COMPONENT_SETUP_STATE extends object = {}, COMPONENT_DERIVED_STATE extends object = {}, T_ACTIONS = {}, T_PARENT_STATE = {}>(config: ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE, COMPONENT_DERIVED_STATE, T_ACTIONS, T_PARENT_STATE>): {
8629
+ ManagedComponentContextProvider: React.NamedExoticComponent<T_PROPS & {
8630
+ children?: React.ReactNode;
8631
+ }>;
8632
+ useManagedComponent: (props: T_PROPS) => {
8633
+ contextValue: {
8634
+ componentState: COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE;
8635
+ componentActions: ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
8636
+ getComponentState: () => COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE;
8637
+ replaceState: (newState: COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE) => void;
8638
+ assignState: (newState: Partial<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>) => void;
8639
+ };
8640
+ ContextComponent: React.Context<ManagedComponentStateContextValue<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE, ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>>>;
8641
+ };
8642
+ };
8643
+ declare function useManagedComponentState<COMPONENT_STATE>(Context?: React.Context<ManagedComponentStateContextValue<COMPONENT_STATE, ComponentStateActions<COMPONENT_STATE>>>): ManagedComponentStateContextValue<COMPONENT_STATE, ComponentStateGeneratedActions<COMPONENT_STATE>>;
8644
+
8607
8645
  type InterceptedMapFns<K, V> = {
8608
8646
  set?: (k: K, v: V) => void;
8609
8647
  beforeClear?: (map: Map<K, V>) => void;