@infinite-table/infinite-react 10.2.1 → 11.0.1

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;
@@ -2146,6 +2083,43 @@ declare class ScrollListener {
2146
2083
  destroy: () => void;
2147
2084
  }
2148
2085
 
2086
+ /**
2087
+ * The filter values typed in the header that wait `filterDelay` before they
2088
+ * are applied, one per column (the last one typed).
2089
+ *
2090
+ * A pending value is dropped when the column's filter is written by
2091
+ * something else in the meantime, so it doesn't overwrite that write when
2092
+ * it fires:
2093
+ * - the table API writes it (setColumnFilter, clearColumnFilter, ...): the
2094
+ * API calls `cancel`;
2095
+ * - the DataSource's filterValue changes in another way (a controlled
2096
+ * `filterValue`, a restored state): when it fires, the pending value
2097
+ * checks that the column's filter is the one it was typed over (by
2098
+ * value - a filterValue built again with the same filters doesn't drop
2099
+ * it), or the one this column applied last (a controlled filterValue
2100
+ * gets it back after the apply).
2101
+ *
2102
+ * The filter editors of a column listen with `onCancel`, to show the
2103
+ * column's filter again instead of the dropped value.
2104
+ */
2105
+ declare class PendingColumnFilters {
2106
+ private pending;
2107
+ /** the value applied last, until the DataSource has it */
2108
+ private applied;
2109
+ private cancelListeners;
2110
+ schedule(columnId: string, value: unknown, options: {
2111
+ delay: number;
2112
+ /** the column's filter value item in the DataSource, now */
2113
+ getFilterValueItem: () => DataSourceFilterValueItem<any> | null;
2114
+ apply: (value: unknown) => void;
2115
+ }): void;
2116
+ /** drops the value waiting for the column, if any */
2117
+ cancel(columnId: string): void;
2118
+ onCancel(columnId: string, fn: () => void): () => void;
2119
+ private isLastApplied;
2120
+ private notifyCancel;
2121
+ }
2122
+
2149
2123
  declare const DS_ERROR_CODES: Record<"DS001", DebugWarningPayload>;
2150
2124
  declare const INFINITE_ERROR_CODES: Record<"CSS001_CSS", DebugWarningPayload>;
2151
2125
  declare const ERROR_CODES: {
@@ -2299,6 +2273,8 @@ interface InfiniteTableSetupState<T> {
2299
2273
  target: HTMLElement | EventTarget;
2300
2274
  column: InfiniteTableComputedColumn<T>;
2301
2275
  }>;
2276
+ /** the filter values typed in the header, waiting for `filterDelay` */
2277
+ pendingColumnFilters: PendingColumnFilters;
2302
2278
  cellContextMenu: SubscriptionCallback<CellContextMenuLocationWithEvent>;
2303
2279
  contextMenu: SubscriptionCallback<ContextMenuLocationWithEvent>;
2304
2280
  cellContextMenuVisibleFor: CellContextMenuLocation | null;
@@ -7441,29 +7417,6 @@ type OverlayShowParams = {
7441
7417
  };
7442
7418
  declare function alignNode(node: HTMLDivElement, params: OverlayShowParams): Promise<void>;
7443
7419
 
7444
- type OverlayParams = {
7445
- portalContainer?: ElementContainerGetter | null | false;
7446
- constrainTo?: OverlayShowParams['constrainTo'];
7447
- };
7448
- /**
7449
- * If portal container is given, it will create a React portal from that element
7450
- * otherwise it will simply render another node as portal
7451
- *
7452
- * @param portalContainer
7453
- */
7454
- 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;
7455
- type UpdateOverlayContentFn = (content: ReactNode | (() => ReactNode), options?: {
7456
- skipRealign?: boolean;
7457
- }) => void;
7458
- type ShowOverlayFn = (content: ReactNode | (() => ReactNode), params: OverlayShowParams) => UpdateOverlayContentFn;
7459
- declare function useOverlay(params: OverlayParams): {
7460
- 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;
7461
- hideOverlay: (id: string) => void;
7462
- clearAll: () => void;
7463
- rerenderOverlays: () => void;
7464
- showOverlay: ShowOverlayFn;
7465
- };
7466
-
7467
7420
  /**
7468
7421
 
7469
7422
  We have this utility - it's used in Menu Renderable declaration
@@ -8324,6 +8277,13 @@ declare namespace Menu {
8324
8277
  var __is_infinite_menu_component: boolean;
8325
8278
  }
8326
8279
 
8280
+ /**
8281
+ * Framework-neutral types of the drag and drop between drag lists.
8282
+ *
8283
+ * The DragDropProvider of each framework (DragDropProvider.tsx,
8284
+ * DragDropProvider.vue.ts, ...) re-exports them, and shared modules import
8285
+ * them from here so they never reach a framework's provider component.
8286
+ */
8327
8287
  type DragDropSourceAndTarget = {
8328
8288
  dragSourceListId: string | null;
8329
8289
  dropTargetListId: string | null;
@@ -8334,6 +8294,7 @@ type DragDropProviderContextValue = DragDropSourceAndTarget & {
8334
8294
  updateDragOperationSourceAndTarget: (params: DragDropSourceAndTarget) => void;
8335
8295
  getCurrentDragSourceAndTarget: () => DragDropSourceAndTarget;
8336
8296
  };
8297
+
8337
8298
  declare const useDragDropProvider: () => DragDropProviderContextValue;
8338
8299
  declare const DragDropProvider: (props: {
8339
8300
  children: React.ReactNode | ((context: DragDropProviderContextValue) => React.ReactNode);
@@ -8621,6 +8582,29 @@ declare class AutoScroller {
8621
8582
  stop(): void;
8622
8583
  }
8623
8584
 
8585
+ type OverlayParams = {
8586
+ portalContainer?: ElementContainerGetter | null | false;
8587
+ constrainTo?: OverlayShowParams['constrainTo'];
8588
+ };
8589
+ /**
8590
+ * If portal container is given, it will create a React portal from that element
8591
+ * otherwise it will simply render another node as portal
8592
+ *
8593
+ * @param portalContainer
8594
+ */
8595
+ 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;
8596
+ type UpdateOverlayContentFn = (content: ReactNode | (() => ReactNode), options?: {
8597
+ skipRealign?: boolean;
8598
+ }) => void;
8599
+ type ShowOverlayFn = (content: ReactNode | (() => ReactNode), params: OverlayShowParams) => UpdateOverlayContentFn;
8600
+ declare function useOverlay(params: OverlayParams): {
8601
+ 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;
8602
+ hideOverlay: (id: string) => void;
8603
+ clearAll: () => void;
8604
+ rerenderOverlays: () => void;
8605
+ showOverlay: ShowOverlayFn;
8606
+ };
8607
+
8624
8608
  declare function useEffectWithChanges<T>(fn: (changes: Record<keyof T, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<keyof T, any>): void;
8625
8609
  declare function useLayoutEffectWithChanges<T>(fn: (changes: Record<keyof T, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<keyof T, any>): void;
8626
8610
  declare function useEffectWithObject(fn: EffectCallback, deps: Record<string, any>): void;
@@ -8634,6 +8618,69 @@ declare const keyboardShortcuts: {
8634
8618
  instantEdit: InfiniteTablePropKeyboardShorcut;
8635
8619
  };
8636
8620
 
8621
+ /**
8622
+ * React adapter for the managed component state system.
8623
+ *
8624
+ * All framework-free logic (controlled/uncontrolled resolution, reducer body,
8625
+ * generated action setters, prop-diff) lives in ./managedComponentState.ts.
8626
+ * This file owns React scheduling: useState/useReducer, effects, context.
8627
+ * Its behavior is pinned by buildManagedComponent.jestspec.tsx.
8628
+ */
8629
+
8630
+ type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE = {}, COMPONENT_DERIVED_STATE = {}, T_ACTIONS = {}, T_PARENT_STATE = {}> = {
8631
+ debugName?: string | ((props: T_PROPS) => string);
8632
+ initSetupState?: (props: T_PROPS) => COMPONENT_SETUP_STATE;
8633
+ Context?: React.Context<ManagedComponentStateContextValue<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE, ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>>>;
8634
+ layoutEffect?: boolean;
8635
+ forwardProps?: (setupState: COMPONENT_SETUP_STATE, props: T_PROPS) => ForwardPropsToStateFnResult<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE>;
8636
+ allowedControlledPropOverrides?: Record<keyof T_PROPS, true>;
8637
+ interceptActions?: ComponentInterceptedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
8638
+ mappedCallbacks?: ComponentMappedCallbacks<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
8639
+ onPropChange?: (params: {
8640
+ name: keyof T_PROPS;
8641
+ oldValue: any;
8642
+ newValue: any;
8643
+ }, 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;
8644
+ onPropsChange?: (newPropValues: {
8645
+ [k in keyof T_PROPS]?: {
8646
+ newValue: T_PROPS[k];
8647
+ oldValue: T_PROPS[k];
8648
+ };
8649
+ }, 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;
8650
+ mapPropsToState?: (params: {
8651
+ props: T_PROPS;
8652
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>;
8653
+ oldState: null | (COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & Partial<COMPONENT_DERIVED_STATE>);
8654
+ parentState: T_PARENT_STATE | null;
8655
+ }) => COMPONENT_DERIVED_STATE;
8656
+ concludeReducer?: (params: {
8657
+ previousState: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
8658
+ state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
8659
+ updatedProps: Partial<T_PROPS> | null;
8660
+ parentState: T_PARENT_STATE | null;
8661
+ }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
8662
+ getReducerActions?: (dispatch: React.Dispatch<any>) => T_ACTIONS;
8663
+ getParentState?: () => T_PARENT_STATE;
8664
+ cleanup?: (state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE) => void;
8665
+ onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
8666
+ };
8667
+ 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>): {
8668
+ ManagedComponentContextProvider: React.NamedExoticComponent<T_PROPS & {
8669
+ children?: React.ReactNode;
8670
+ }>;
8671
+ useManagedComponent: (props: T_PROPS) => {
8672
+ contextValue: {
8673
+ componentState: COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE;
8674
+ componentActions: ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>;
8675
+ getComponentState: () => COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE;
8676
+ replaceState: (newState: COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE) => void;
8677
+ assignState: (newState: Partial<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>) => void;
8678
+ };
8679
+ ContextComponent: React.Context<ManagedComponentStateContextValue<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE, ComponentStateGeneratedActions<COMPONENT_MAPPED_STATE & COMPONENT_DERIVED_STATE & COMPONENT_SETUP_STATE>>>;
8680
+ };
8681
+ };
8682
+ declare function useManagedComponentState<COMPONENT_STATE>(Context?: React.Context<ManagedComponentStateContextValue<COMPONENT_STATE, ComponentStateActions<COMPONENT_STATE>>>): ManagedComponentStateContextValue<COMPONENT_STATE, ComponentStateGeneratedActions<COMPONENT_STATE>>;
8683
+
8637
8684
  type InterceptedMapFns<K, V> = {
8638
8685
  set?: (k: K, v: V) => void;
8639
8686
  beforeClear?: (map: Map<K, V>) => void;