dinocollab-core 2.2.1 → 2.2.3
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/dist/lab/data-surface/index.js +2 -0
- package/dist/lab/data-surface/index.js.map +1 -0
- package/dist/src/filter-bar/components/filter-input.units.js +1 -1
- package/dist/src/filter-bar/components/filter-input.units.js.map +1 -1
- package/dist/src/filter-bar/components/filter-menu.js +1 -1
- package/dist/src/filter-bar/components/filter-menu.js.map +1 -1
- package/dist/src/filter-bar/components/filter-sort.js +1 -1
- package/dist/src/filter-bar/components/filter-sort.js.map +1 -1
- package/dist/src/filter-bar/helpers.js +1 -1
- package/dist/src/filter-bar/helpers.js.map +1 -1
- package/dist/src/filter-bar/index.create.js +1 -1
- package/dist/src/filter-bar/index.create.js.map +1 -1
- package/dist/src/filter-bar/index.dino.js +1 -1
- package/dist/src/filter-bar/index.dino.js.map +1 -1
- package/dist/src/lab/data-surface/button-switch.js +2 -0
- package/dist/src/lab/data-surface/button-switch.js.map +1 -0
- package/dist/src/lab/data-surface/helpers.js +2 -0
- package/dist/src/lab/data-surface/helpers.js.map +1 -0
- package/dist/src/lab/data-surface/index.create.js +2 -0
- package/dist/src/lab/data-surface/index.create.js.map +1 -0
- package/dist/src/lab/data-surface/index.dino.js +2 -0
- package/dist/src/lab/data-surface/index.dino.js.map +1 -0
- package/dist/src/lab/data-surface/types.js +2 -0
- package/dist/src/lab/data-surface/types.js.map +1 -0
- package/dist/src/lab/data-surface/ui.units.js +2 -0
- package/dist/src/lab/data-surface/ui.units.js.map +1 -0
- package/dist/src/lab/data-surface/view-grid.js +2 -0
- package/dist/src/lab/data-surface/view-grid.js.map +1 -0
- package/dist/src/lab/data-surface/view-grid.units.js +2 -0
- package/dist/src/lab/data-surface/view-grid.units.js.map +1 -0
- package/dist/src/lab/data-surface/view-list.js +2 -0
- package/dist/src/lab/data-surface/view-list.js.map +1 -0
- package/dist/src/lab/data-surface/view-list.types.js +2 -0
- package/dist/src/lab/data-surface/view-list.types.js.map +1 -0
- package/dist/src/lab/data-surface/view-list.units.js +2 -0
- package/dist/src/lab/data-surface/view-list.units.js.map +1 -0
- package/dist/src/lab/data-surface/view-switch-transition.js +2 -0
- package/dist/src/lab/data-surface/view-switch-transition.js.map +1 -0
- package/dist/src/lab/data-surface/view-switch-transition.units.js +2 -0
- package/dist/src/lab/data-surface/view-switch-transition.units.js.map +1 -0
- package/dist/types/filter-bar/components/filter-sort.types.d.ts +1 -0
- package/dist/types/filter-bar/helpers.d.ts +30 -1
- package/dist/types/filter-bar/index.create.d.ts +8 -0
- package/dist/types/filter-bar/index.dino.d.ts +5 -0
- package/dist/types/lab/data-surface/button-switch.d.ts +12 -0
- package/dist/types/lab/data-surface/helpers.d.ts +26 -0
- package/dist/types/lab/data-surface/index.create.d.ts +49 -6
- package/dist/types/lab/data-surface/index.d.ts +5 -0
- package/dist/types/lab/data-surface/index.dino.d.ts +23 -1
- package/dist/types/lab/data-surface/types.d.ts +31 -4
- package/dist/types/lab/data-surface/ui.units.d.ts +34 -0
- package/dist/types/lab/data-surface/view-grid.d.ts +12 -10
- package/dist/types/lab/data-surface/view-grid.types.d.ts +0 -10
- package/dist/types/lab/data-surface/view-grid.units.d.ts +3 -3
- package/dist/types/lab/data-surface/view-list.d.ts +52 -0
- package/dist/types/lab/data-surface/view-list.types.d.ts +64 -0
- package/dist/types/lab/data-surface/view-list.units.d.ts +23 -0
- package/dist/types/lab/data-surface/view-switch-transition.units.d.ts +1 -1
- package/package.json +8 -1
- package/dist/types/lab/data-viewer/index.d.ts +0 -1
|
@@ -1,16 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DataSurfaceViewMode, LoadingModeRule } from './types';
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
3
|
+
import type { ComponentType, FC, ReactNode } from 'react';
|
|
4
|
+
import type { TPagination, TDataSurfaceState } from './types';
|
|
5
|
+
import type { IViewGridConfig, IViewGridProps } from './view-grid';
|
|
6
|
+
import type { IViewListConfig, IViewListProps } from './view-list';
|
|
7
|
+
export interface IDataSurfaceSlots {
|
|
8
|
+
footer?: {
|
|
9
|
+
status?: string | ((currentStatus: string) => ReactNode);
|
|
10
|
+
range?: string | ((currentRange: string) => ReactNode);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
4
13
|
export interface IDataSurfaceProps<T> {
|
|
5
14
|
value?: T[];
|
|
6
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated No longer used. Use `viewMode` and `loadMode` props directly instead.
|
|
17
|
+
* Controlled state. When provided, DataSurface becomes fully controlled.
|
|
18
|
+
*/
|
|
19
|
+
state?: TDataSurfaceState;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated No longer used. Component now uses uncontrolled mode with props.
|
|
22
|
+
* Called on any state change (viewMode, loadMode, page, pageSize).
|
|
23
|
+
*/
|
|
24
|
+
onStateChange?: (state: TDataSurfaceState) => void;
|
|
7
25
|
viewMode?: DataSurfaceViewMode;
|
|
26
|
+
/** Pagination metadata shared by both modes. */
|
|
27
|
+
pagination?: TPagination;
|
|
28
|
+
/** True while a page fetch is in flight (shows loading indicator). */
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Called when the component needs a new page of data.
|
|
32
|
+
* - pagination mode: triggered by user clicking page control
|
|
33
|
+
* - infiniteScroll mode: triggered automatically when scrolling near the bottom
|
|
34
|
+
* Supports async operations - return a Promise to indicate loading state.
|
|
35
|
+
*/
|
|
36
|
+
onPageChange?: (page: number, pageSize: number) => void | Promise<void>;
|
|
37
|
+
/** Load orchestration mode. @default 'pagination' */
|
|
38
|
+
loadMode?: LoadingModeRule;
|
|
39
|
+
sx?: BoxProps['sx'];
|
|
40
|
+
slots?: IDataSurfaceSlots;
|
|
41
|
+
/** Enable row selection with checkboxes (List view only). */
|
|
42
|
+
selectable?: boolean;
|
|
43
|
+
/** Array of selected row IDs (controlled). */
|
|
44
|
+
selectedIds?: (string | number)[];
|
|
45
|
+
/** Callback when selection changes. */
|
|
46
|
+
onSelectionChange?: (selectedIds: (string | number)[]) => void;
|
|
8
47
|
}
|
|
9
48
|
export interface IDataSurfaceConfig<T> {
|
|
10
49
|
defaultViewMode?: DataSurfaceViewMode;
|
|
50
|
+
/** Default load mode when not provided via props. @default 'pagination' */
|
|
51
|
+
defaultLoadMode?: LoadingModeRule;
|
|
52
|
+
/** Default page size. @default 20 */
|
|
53
|
+
defaultPageSize?: number;
|
|
11
54
|
enableSingleViewTransition?: boolean;
|
|
12
|
-
listConfig?:
|
|
13
|
-
ListComponent?: ComponentType<
|
|
55
|
+
listConfig?: IViewListConfig<T>;
|
|
56
|
+
ListComponent?: ComponentType<IViewListProps<T>>;
|
|
14
57
|
gridConfig?: IViewGridConfig<T>;
|
|
15
58
|
GridComponent?: ComponentType<IViewGridProps<T>>;
|
|
16
59
|
}
|
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { setViewModeToURL, getViewModeFromURL, setPaginationToURL, getPaginationFromURL } from './helpers';
|
|
2
3
|
import createViewGrid from './view-grid';
|
|
4
|
+
import createDataSurface from './index.create';
|
|
3
5
|
export declare class DinoDataSurFace {
|
|
4
6
|
createDataSurface: typeof createDataSurface;
|
|
5
7
|
createViewGrid: typeof createViewGrid;
|
|
8
|
+
ButtonSwitch: import("react").FC<{
|
|
9
|
+
value?: "grid" | "list" | undefined;
|
|
10
|
+
onChange?: ((value: "grid" | "list") => void) | undefined;
|
|
11
|
+
size?: "sm" | "md" | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
onlyIcon?: boolean | undefined;
|
|
14
|
+
reverse?: boolean | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
createButtonSwitch: () => import("react").FC<{
|
|
17
|
+
value?: "grid" | "list" | undefined;
|
|
18
|
+
onChange?: ((value: "grid" | "list") => void) | undefined;
|
|
19
|
+
size?: "sm" | "md" | undefined;
|
|
20
|
+
className?: string | undefined;
|
|
21
|
+
onlyIcon?: boolean | undefined;
|
|
22
|
+
reverse?: boolean | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
setViewModeToURL: typeof setViewModeToURL;
|
|
25
|
+
getViewModeFromURL: typeof getViewModeFromURL;
|
|
26
|
+
setPaginationToURL: typeof setPaginationToURL;
|
|
27
|
+
getPaginationFromURL: typeof getPaginationFromURL;
|
|
6
28
|
}
|
|
7
29
|
export declare const dinoDataSurface: DinoDataSurFace;
|
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import { RenderStrategyRule } from "./view-grid.types";
|
|
2
1
|
export type TGetterId<T> = (item: T, index: number) => string | number;
|
|
2
|
+
export type TPagination = {
|
|
3
|
+
page?: number;
|
|
4
|
+
pageSize?: number;
|
|
5
|
+
hasNext?: boolean;
|
|
6
|
+
hasPrev?: boolean;
|
|
7
|
+
total?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Virtualized rendering configuration.
|
|
11
|
+
* Used by both grid and list views for windowing optimization.
|
|
12
|
+
*/
|
|
13
|
+
export type TVirtualizedConfig = {
|
|
14
|
+
scrollTop: number;
|
|
15
|
+
viewportHeight: number;
|
|
16
|
+
/** Number of extra rows/columns rendered outside the viewport as a buffer. Defaults to `4` (grid) / `6` (table). */
|
|
17
|
+
overscan?: number;
|
|
18
|
+
gap?: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Controls how the list is rendered into the DOM.
|
|
22
|
+
* - `normal` — all rows are mounted (suitable for small datasets)
|
|
23
|
+
* - `virtualized` — only visible rows are mounted (optimized for large datasets)
|
|
24
|
+
*/
|
|
25
|
+
export declare const RenderStrategyRule: {
|
|
26
|
+
readonly normal: "normal";
|
|
27
|
+
readonly virtualized: "virtualized";
|
|
28
|
+
};
|
|
29
|
+
export type RenderStrategyRule = keyof typeof RenderStrategyRule;
|
|
3
30
|
/**
|
|
4
31
|
* Controls how the list is displayed.
|
|
5
32
|
* - `list` — items are displayed in a single column
|
|
@@ -15,13 +42,13 @@ export type DataSurfaceViewMode = keyof typeof DataSurfaceViewMode;
|
|
|
15
42
|
* - `pagination` — loading indicator is shown when the user clicks on the pagination controls
|
|
16
43
|
* - `infiniteScroll` — loading indicator is shown when the user scrolls to the end of the list
|
|
17
44
|
*/
|
|
18
|
-
export declare const
|
|
45
|
+
export declare const LoadingModeRule: {
|
|
19
46
|
readonly pagination: "pagination";
|
|
20
47
|
readonly infiniteScroll: "infiniteScroll";
|
|
21
48
|
};
|
|
22
|
-
export type
|
|
49
|
+
export type LoadingModeRule = keyof typeof LoadingModeRule;
|
|
23
50
|
export type TDataSurfaceState = {
|
|
24
51
|
viewMode?: DataSurfaceViewMode;
|
|
25
|
-
|
|
52
|
+
loadMode?: LoadingModeRule;
|
|
26
53
|
renderStrategy?: RenderStrategyRule;
|
|
27
54
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
3
|
+
export declare const PanelLoading: FC<BoxProps>;
|
|
4
|
+
export declare const PanelError: FC<{
|
|
5
|
+
error: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const PanelNoData: FC;
|
|
8
|
+
export declare const PanelWaiting: FC;
|
|
9
|
+
export declare const PanelMissingConfig: FC;
|
|
10
|
+
export declare const PanelLoadMore: FC;
|
|
11
|
+
export interface IPanelInfiniteScrollFooterSlots {
|
|
12
|
+
statusText?: string | ((currentStatus: string) => ReactNode);
|
|
13
|
+
rangeText?: string | ((currentRange: string) => ReactNode);
|
|
14
|
+
}
|
|
15
|
+
export interface IPanelInfiniteScrollFooterProps {
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
hasNext?: boolean;
|
|
18
|
+
currentCount: number;
|
|
19
|
+
total?: number;
|
|
20
|
+
slots?: IPanelInfiniteScrollFooterSlots;
|
|
21
|
+
}
|
|
22
|
+
export declare const PanelInfiniteScrollFooter: FC<IPanelInfiniteScrollFooterProps>;
|
|
23
|
+
export interface IPanelPaginationFooterProps {
|
|
24
|
+
page: number;
|
|
25
|
+
pageSize: number;
|
|
26
|
+
total?: number;
|
|
27
|
+
hasNext?: boolean;
|
|
28
|
+
hasPrev?: boolean;
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
onPrevPage?: () => void;
|
|
31
|
+
onNextPage?: () => void;
|
|
32
|
+
onPageJump?: (page: number) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare const PanelPaginationFooter: FC<IPanelPaginationFooterProps>;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { ComponentType, FC } from 'react';
|
|
2
|
-
import { TGetterId } from './types';
|
|
3
|
-
import { RenderStrategyRule } from './view-grid.types';
|
|
1
|
+
import type { ComponentType, FC } from 'react';
|
|
2
|
+
import type { TGetterId, LoadingModeRule, TPagination, TVirtualizedConfig, RenderStrategyRule } from './types';
|
|
4
3
|
import type { IViewGridItemProps, TGridSizes } from './view-grid.types';
|
|
5
|
-
export type TVirtualizedConfig = {
|
|
6
|
-
scrollTop: number;
|
|
7
|
-
viewportHeight: number;
|
|
8
|
-
/** Number of extra rows/columns rendered outside the viewport as a buffer. Defaults to `4` (grid) / `6` (table). */
|
|
9
|
-
overscan?: number;
|
|
10
|
-
gap?: number;
|
|
11
|
-
};
|
|
12
4
|
export interface IViewGridBase<T> {
|
|
13
5
|
gap?: number;
|
|
14
6
|
sizes?: TGridSizes;
|
|
@@ -22,6 +14,8 @@ export interface IViewGridBase<T> {
|
|
|
22
14
|
renderStrategy?: RenderStrategyRule;
|
|
23
15
|
Component?: ComponentType<IViewGridItemProps<T>>;
|
|
24
16
|
virtualizedConfig?: TVirtualizedConfig;
|
|
17
|
+
/** Called when user scrolls near the bottom of the list. Use this to trigger pagination or infinity load. */
|
|
18
|
+
onNearEnd?: () => void;
|
|
25
19
|
}
|
|
26
20
|
export interface IViewGridConfig<T> extends IViewGridBase<T> {
|
|
27
21
|
getterId: TGetterId<T>;
|
|
@@ -29,7 +23,15 @@ export interface IViewGridConfig<T> extends IViewGridBase<T> {
|
|
|
29
23
|
export interface IViewGridProps<T> extends IViewGridBase<T> {
|
|
30
24
|
value: T[];
|
|
31
25
|
}
|
|
26
|
+
export interface IViewGridLoadingProps<T> extends IViewGridBase<T> {
|
|
27
|
+
value: T[];
|
|
28
|
+
loadMode: LoadingModeRule;
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
pagination?: TPagination;
|
|
31
|
+
onPageChange?: (page: number, pageSize: number) => void | Promise<void>;
|
|
32
|
+
}
|
|
32
33
|
export declare function createViewGrid<T>(config: IViewGridConfig<T>): FC<IViewGridProps<T>>;
|
|
34
|
+
export declare function createViewGridLoading<T>(GridComponent: ComponentType<IViewGridProps<T>>): FC<IViewGridLoadingProps<T>>;
|
|
33
35
|
export default createViewGrid;
|
|
34
36
|
export declare const viewGridClasses: {
|
|
35
37
|
root: string;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
export type TGridSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
2
2
|
export type TGridSizes = Partial<Record<TGridSize, number>>;
|
|
3
|
-
/**
|
|
4
|
-
* Controls how the list is rendered into the DOM.
|
|
5
|
-
* - `normal` — all rows are mounted (suitable for small datasets)
|
|
6
|
-
* - `virtualized` — only visible rows are mounted (optimized for large datasets)
|
|
7
|
-
*/
|
|
8
|
-
export declare const RenderStrategyRule: {
|
|
9
|
-
readonly normal: "normal";
|
|
10
|
-
readonly virtualized: "virtualized";
|
|
11
|
-
};
|
|
12
|
-
export type RenderStrategyRule = keyof typeof RenderStrategyRule;
|
|
13
3
|
/**
|
|
14
4
|
* Props received by the custom render function for each card in Grid view.
|
|
15
5
|
* @template T - The shape of a single data row object.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { IViewGridItemProps, TGridSizes } from './view-grid.types';
|
|
3
3
|
export declare const DEFAULT_GRID_GAP_PX = 8;
|
|
4
4
|
export declare const getMaxGridGap: (...gap: (number | undefined)[]) => number;
|
|
5
|
-
export declare const DEFAULT_GRID_ITEM_MAX_HEIGHT =
|
|
5
|
+
export declare const DEFAULT_GRID_ITEM_MAX_HEIGHT = 120;
|
|
6
6
|
export declare const getMaxGridItemHeight: (...height: (number | undefined)[]) => number;
|
|
7
7
|
export declare const DEFAULT_GRID_ITEM_SIZES: TGridSizes;
|
|
8
8
|
export declare const getGridItemSizes: (sizes?: TGridSizes) => TGridSizes;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ListDensity } from './view-list.types';
|
|
2
|
+
import type { ComponentType, FC } from 'react';
|
|
3
|
+
import type { TListColumns } from './view-list.types';
|
|
4
|
+
import type { TGetterId, LoadingModeRule, TPagination, TVirtualizedConfig, RenderStrategyRule } from './types';
|
|
5
|
+
export interface IViewListBase<T> {
|
|
6
|
+
columns?: TListColumns<T>;
|
|
7
|
+
density?: ListDensity;
|
|
8
|
+
/**
|
|
9
|
+
* Controls how the list is rendered into the DOM.
|
|
10
|
+
* - `normal` — all rows are mounted (suitable for small datasets)
|
|
11
|
+
* - `virtualized` — only visible rows are mounted (optimized for large datasets)
|
|
12
|
+
* @default 'normal'
|
|
13
|
+
*/
|
|
14
|
+
renderStrategy?: RenderStrategyRule;
|
|
15
|
+
virtualizedConfig?: TVirtualizedConfig;
|
|
16
|
+
/** Called when user scrolls near the bottom of the list. Use this to trigger pagination or infinity load. */
|
|
17
|
+
onNearEnd?: () => void;
|
|
18
|
+
/** Enable row selection with checkboxes. */
|
|
19
|
+
selectable?: boolean;
|
|
20
|
+
/** Array of selected row IDs (controlled). */
|
|
21
|
+
selectedIds?: (string | number)[];
|
|
22
|
+
/** Callback when selection changes. */
|
|
23
|
+
onSelectionChange?: (selectedIds: (string | number)[]) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface IViewListConfig<T> extends IViewListBase<T> {
|
|
26
|
+
getterId: TGetterId<T>;
|
|
27
|
+
}
|
|
28
|
+
export interface IViewListProps<T> extends IViewListBase<T> {
|
|
29
|
+
value: T[];
|
|
30
|
+
}
|
|
31
|
+
export interface IViewListLoadingProps<T> extends IViewListBase<T> {
|
|
32
|
+
value: T[];
|
|
33
|
+
loadMode: LoadingModeRule;
|
|
34
|
+
loading?: boolean;
|
|
35
|
+
pagination?: TPagination;
|
|
36
|
+
onPageChange?: (page: number, pageSize: number) => void | Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare function createViewList<T>(config: IViewListConfig<T>): FC<IViewListProps<T>>;
|
|
39
|
+
export declare function createViewListLoading<T>(ListComponent: ComponentType<IViewListProps<T>>): FC<IViewListLoadingProps<T>>;
|
|
40
|
+
export default createViewList;
|
|
41
|
+
export declare const viewListClasses: {
|
|
42
|
+
root: string;
|
|
43
|
+
virtualized: string;
|
|
44
|
+
scrollContainer: string;
|
|
45
|
+
table: string;
|
|
46
|
+
tableHeader: string;
|
|
47
|
+
tableHeaderCell: string;
|
|
48
|
+
tableBodyCell: string;
|
|
49
|
+
tableSpacerRow: string;
|
|
50
|
+
tableSpacerCell: string;
|
|
51
|
+
tableCellContent: string;
|
|
52
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props received by the custom render function for each row in List view.
|
|
4
|
+
* @template T - The shape of a single data row object.
|
|
5
|
+
*/
|
|
6
|
+
export interface IViewListItemProps<T> {
|
|
7
|
+
/** The data object for this list row. */
|
|
8
|
+
value: T;
|
|
9
|
+
/** Zero-based position of this item in the data array. */
|
|
10
|
+
index: number;
|
|
11
|
+
/** Whether this row is currently selected. */
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Horizontal alignment for list cell content. */
|
|
15
|
+
export type TListAlign = 'left' | 'right' | 'center';
|
|
16
|
+
/**
|
|
17
|
+
* Context passed to a column's render callback.
|
|
18
|
+
* @template T - The shape of a single data row object.
|
|
19
|
+
*/
|
|
20
|
+
export interface IListCellParams<T> {
|
|
21
|
+
/** Resolved cell value (after valueGetter if provided). */
|
|
22
|
+
value: any;
|
|
23
|
+
/** The full row object. */
|
|
24
|
+
row: T;
|
|
25
|
+
/** Zero-based row index. */
|
|
26
|
+
index: number;
|
|
27
|
+
/** The column field key this cell belongs to. */
|
|
28
|
+
field: keyof T;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Definition of a single column in List view.
|
|
32
|
+
* @template T - The shape of a single data row object.
|
|
33
|
+
*/
|
|
34
|
+
export interface TListColumn<T> {
|
|
35
|
+
/** Key of the row object this column maps to. */
|
|
36
|
+
field: keyof T;
|
|
37
|
+
/** Column header label shown in the header. */
|
|
38
|
+
label?: string;
|
|
39
|
+
/** Explicit column width. Accepts px number or CSS string (e.g. '120px', '20%'). */
|
|
40
|
+
width?: number | string;
|
|
41
|
+
/** Minimum column width in pixels. */
|
|
42
|
+
minWidth?: number;
|
|
43
|
+
/** Maximum column width in pixels. */
|
|
44
|
+
maxWidth?: number;
|
|
45
|
+
/** Flex grow ratio used when no explicit width is set. */
|
|
46
|
+
flex?: number;
|
|
47
|
+
/** Horizontal alignment of the cell content. */
|
|
48
|
+
align?: TListAlign;
|
|
49
|
+
/** Custom cell render function - receives CellParams, returns ReactNode. */
|
|
50
|
+
renderCell?: (params: IListCellParams<T>) => ReactNode;
|
|
51
|
+
/** Derives a value from the row before it is passed to the render step. */
|
|
52
|
+
valueGetter?: (row: T, index: number) => any;
|
|
53
|
+
}
|
|
54
|
+
export type TListColumns<T> = Partial<Record<keyof T, Omit<TListColumn<T>, 'field'>>>;
|
|
55
|
+
/**
|
|
56
|
+
* Row density preset for List view.
|
|
57
|
+
* Controls the row height and cell padding.
|
|
58
|
+
*/
|
|
59
|
+
export declare const ListDensity: {
|
|
60
|
+
readonly compact: "compact";
|
|
61
|
+
readonly standard: "standard";
|
|
62
|
+
readonly comfortable: "comfortable";
|
|
63
|
+
};
|
|
64
|
+
export type ListDensity = keyof typeof ListDensity;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ListDensity } from './view-list.types';
|
|
2
|
+
import type { TGetterId } from './types';
|
|
3
|
+
export declare const LIST_HEADER_HEIGHT = 48;
|
|
4
|
+
export declare const LIST_ROW_HEIGHT_BY_DENSITY: Record<ListDensity, number>;
|
|
5
|
+
export declare const LIST_CELL_PADDING_BY_DENSITY: Record<ListDensity, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook to manage list row selection logic.
|
|
8
|
+
* Handles select all, individual row selection, and indeterminate state.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The array of data items
|
|
11
|
+
* @param getterId - Function to extract unique ID from each row
|
|
12
|
+
* @param selectable - Whether selection is enabled
|
|
13
|
+
* @param selectedIds - Controlled array of selected row IDs
|
|
14
|
+
* @param onSelectionChange - Callback when selection changes
|
|
15
|
+
* @returns Selection state and handlers
|
|
16
|
+
*/
|
|
17
|
+
export declare function useListSelection<T>(value: T[], getterId: TGetterId<T>, selectable: boolean, selectedIds?: (string | number)[], onSelectionChange?: (selectedIds: (string | number)[]) => void): {
|
|
18
|
+
selectedIds: (string | number)[];
|
|
19
|
+
isAllSelected: boolean;
|
|
20
|
+
isSomeSelected: boolean;
|
|
21
|
+
handleToggleAll: () => void;
|
|
22
|
+
handleToggleRow: (rowId: string | number) => void;
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dinocollab-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Dinocollab core - libraries for building collaborative applications with React 18",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"filter-bar": [
|
|
33
33
|
"./dist/types/filter-bar/index.d.ts"
|
|
34
34
|
],
|
|
35
|
+
"lab/data-surface": [
|
|
36
|
+
"./dist/types/lab/data-surface/index.d.ts"
|
|
37
|
+
],
|
|
35
38
|
"data-view": [
|
|
36
39
|
"./dist/types/data-view/index.d.ts"
|
|
37
40
|
],
|
|
@@ -81,6 +84,10 @@
|
|
|
81
84
|
"import": "./dist/filter-bar/index.js",
|
|
82
85
|
"types": "./dist/types/filter-bar/index.d.ts"
|
|
83
86
|
},
|
|
87
|
+
"./lab/data-surface": {
|
|
88
|
+
"import": "./dist/lab/data-surface/index.js",
|
|
89
|
+
"types": "./dist/types/lab/data-surface/index.d.ts"
|
|
90
|
+
},
|
|
84
91
|
"./data-view": {
|
|
85
92
|
"import": "./dist/data-view/index.js",
|
|
86
93
|
"types": "./dist/types/data-view/index.d.ts"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|