dinocollab-core 2.2.8 → 2.2.10
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/data-surface/index.js +2 -0
- package/dist/src/data-surface/button-switch.js +2 -0
- package/dist/src/data-surface/button-switch.js.map +1 -0
- package/dist/src/data-surface/helpers.js +2 -0
- package/dist/src/data-surface/helpers.js.map +1 -0
- package/dist/src/data-surface/index.create.js +2 -0
- package/dist/src/data-surface/index.create.js.map +1 -0
- package/dist/src/data-surface/index.dino.js +2 -0
- package/dist/src/data-surface/index.dino.js.map +1 -0
- package/dist/src/data-surface/types.js.map +1 -0
- package/dist/src/data-surface/ui.units.js +2 -0
- package/dist/src/data-surface/ui.units.js.map +1 -0
- package/dist/src/data-surface/view-grid/helpers.js +2 -0
- package/dist/src/data-surface/view-grid/helpers.js.map +1 -0
- package/dist/src/data-surface/view-grid/hooks.js +2 -0
- package/dist/src/data-surface/view-grid/hooks.js.map +1 -0
- package/dist/src/data-surface/view-grid/index.js +2 -0
- package/dist/src/data-surface/view-grid/index.js.map +1 -0
- package/dist/src/data-surface/view-grid/styleds.js +2 -0
- package/dist/src/data-surface/view-grid/styleds.js.map +1 -0
- package/dist/src/data-surface/view-grid/ui.units.js +2 -0
- package/dist/src/data-surface/view-grid/ui.units.js.map +1 -0
- package/dist/src/data-surface/view-list/helpers.js +2 -0
- package/dist/src/data-surface/view-list/helpers.js.map +1 -0
- package/dist/src/data-surface/view-list/hooks.js +2 -0
- package/dist/src/data-surface/view-list/hooks.js.map +1 -0
- package/dist/src/data-surface/view-list/index.js +2 -0
- package/dist/src/data-surface/view-list/index.js.map +1 -0
- package/dist/src/data-surface/view-list/styled.js +2 -0
- package/dist/src/data-surface/view-list/styled.js.map +1 -0
- package/dist/src/{lab/data-surface/view-list.types.js → data-surface/view-list/types.js} +1 -1
- package/dist/src/data-surface/view-list/types.js.map +1 -0
- package/dist/src/data-surface/view-switch-transition.js +2 -0
- package/dist/src/data-surface/view-switch-transition.js.map +1 -0
- package/dist/src/data-surface/view-switch-transition.units.js +2 -0
- package/dist/src/data-surface/view-switch-transition.units.js.map +1 -0
- package/dist/src/filter-bar/components/filter-input.js +1 -1
- package/dist/src/filter-bar/components/filter-input.js.map +1 -1
- 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/components/filter-summary.js +1 -1
- package/dist/src/filter-bar/components/filter-summary.js.map +1 -1
- package/dist/src/filter-bar/components/hint-icon.js +1 -1
- package/dist/src/filter-bar/components/hint-icon.js.map +1 -1
- package/dist/src/filter-bar/components/units.js +2 -0
- package/dist/src/filter-bar/components/units.js.map +1 -0
- package/dist/src/filter-bar/convert-to-graphql.js +1 -1
- package/dist/src/filter-bar/convert-to-graphql.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/hooks.js +2 -0
- package/dist/src/filter-bar/hooks.js.map +1 -0
- package/dist/src/filter-bar/index.context.js +1 -1
- package/dist/src/filter-bar/index.context.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/types.js +1 -1
- package/dist/src/filter-bar/types.js.map +1 -1
- package/dist/src/table/create.table.js +1 -1
- package/dist/src/utils/helpers.js +1 -1
- package/dist/types/{lab/data-surface → data-surface}/index.create.d.ts +1 -1
- package/dist/types/{lab/data-surface → data-surface}/index.d.ts +2 -2
- package/dist/types/{lab/data-surface → data-surface}/index.dino.d.ts +2 -0
- package/dist/types/{lab/data-surface → data-surface}/types.d.ts +0 -11
- package/dist/types/data-surface/view-grid/helpers.d.ts +19 -0
- package/dist/types/data-surface/view-grid/hooks.d.ts +9 -0
- package/dist/types/data-surface/view-grid/index.d.ts +19 -0
- package/dist/types/data-surface/view-grid/styleds.d.ts +12 -0
- package/dist/types/data-surface/view-grid/types.d.ts +39 -0
- package/dist/types/data-surface/view-grid/ui.units.d.ts +3 -0
- package/dist/types/data-surface/view-list/helpers.d.ts +15 -0
- package/dist/types/{lab/data-surface/view-list.units.d.ts → data-surface/view-list/hooks.d.ts} +11 -5
- package/dist/types/data-surface/view-list/index.d.ts +13 -0
- package/dist/types/data-surface/view-list/styled.d.ts +17 -0
- package/dist/types/{lab/data-surface/view-list.types.d.ts → data-surface/view-list/types.d.ts} +38 -0
- package/dist/types/data-view/dino.d.ts +1 -1
- package/dist/types/data-view/query-param-url.d.ts +1 -1
- package/dist/types/filter-bar/components/filter-menu.types.d.ts +2 -0
- package/dist/types/filter-bar/components/filter-sort.types.d.ts +25 -8
- package/dist/types/filter-bar/components/hint-icon.d.ts +4 -0
- package/dist/types/filter-bar/components/units.d.ts +3 -0
- package/dist/types/filter-bar/helpers.d.ts +8 -5
- package/dist/types/filter-bar/{components/hooks.d.ts → hooks.d.ts} +2 -2
- package/dist/types/filter-bar/index.context.d.ts +1 -0
- package/dist/types/filter-bar/index.create.d.ts +4 -1
- package/dist/types/filter-bar/types.d.ts +1 -1
- package/package.json +20 -20
- package/dist/lab/data-surface/index.js +0 -2
- package/dist/src/filter-bar/components/hooks.js +0 -2
- package/dist/src/filter-bar/components/hooks.js.map +0 -1
- package/dist/src/lab/data-surface/button-switch.js +0 -2
- package/dist/src/lab/data-surface/button-switch.js.map +0 -1
- package/dist/src/lab/data-surface/helpers.js +0 -2
- package/dist/src/lab/data-surface/helpers.js.map +0 -1
- package/dist/src/lab/data-surface/index.create.js +0 -2
- package/dist/src/lab/data-surface/index.create.js.map +0 -1
- package/dist/src/lab/data-surface/index.dino.js +0 -2
- package/dist/src/lab/data-surface/index.dino.js.map +0 -1
- package/dist/src/lab/data-surface/types.js.map +0 -1
- package/dist/src/lab/data-surface/ui.units.js +0 -2
- package/dist/src/lab/data-surface/ui.units.js.map +0 -1
- package/dist/src/lab/data-surface/view-grid.js +0 -2
- package/dist/src/lab/data-surface/view-grid.js.map +0 -1
- package/dist/src/lab/data-surface/view-grid.units.js +0 -2
- package/dist/src/lab/data-surface/view-grid.units.js.map +0 -1
- package/dist/src/lab/data-surface/view-list.js +0 -2
- package/dist/src/lab/data-surface/view-list.js.map +0 -1
- package/dist/src/lab/data-surface/view-list.types.js.map +0 -1
- package/dist/src/lab/data-surface/view-list.units.js +0 -2
- package/dist/src/lab/data-surface/view-list.units.js.map +0 -1
- package/dist/src/lab/data-surface/view-switch-transition.js +0 -2
- package/dist/src/lab/data-surface/view-switch-transition.js.map +0 -1
- package/dist/src/lab/data-surface/view-switch-transition.units.js +0 -2
- package/dist/src/lab/data-surface/view-switch-transition.units.js.map +0 -1
- package/dist/types/lab/data-surface/view-grid.d.ts +0 -42
- package/dist/types/lab/data-surface/view-grid.types.d.ts +0 -12
- package/dist/types/lab/data-surface/view-grid.units.d.ts +0 -11
- package/dist/types/lab/data-surface/view-list.d.ts +0 -52
- /package/dist/{lab/data-surface → data-surface}/index.js.map +0 -0
- /package/dist/src/{lab/data-surface → data-surface}/types.js +0 -0
- /package/dist/types/{lab/data-surface → data-surface}/button-switch.d.ts +0 -0
- /package/dist/types/{lab/data-surface → data-surface}/helpers.d.ts +0 -0
- /package/dist/types/{lab/data-surface → data-surface}/ui.units.d.ts +0 -0
- /package/dist/types/{lab/data-surface → data-surface}/view-switch-transition.d.ts +0 -0
- /package/dist/types/{lab/data-surface → data-surface}/view-switch-transition.units.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './helpers';
|
|
3
3
|
export * from './index.create';
|
|
4
|
-
export * from './view-list
|
|
5
|
-
export * from './view-grid
|
|
4
|
+
export * from './view-list';
|
|
5
|
+
export * from './view-grid';
|
|
6
6
|
export * from './index.dino';
|
|
7
7
|
export * from './button-switch';
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import { setViewModeToURL, getViewModeFromURL, setPaginationToURL, getPaginationFromURL } from './helpers';
|
|
3
3
|
import createViewGrid from './view-grid';
|
|
4
4
|
import createDataSurface from './index.create';
|
|
5
|
+
import createViewList from './view-list';
|
|
5
6
|
export declare class DinoDataSurFace {
|
|
6
7
|
createDataSurface: typeof createDataSurface;
|
|
7
8
|
createViewGrid: typeof createViewGrid;
|
|
9
|
+
createViewList: typeof createViewList;
|
|
8
10
|
ButtonSwitch: import("react").FC<import("./button-switch").IButtonSwitchProps>;
|
|
9
11
|
createButtonSwitch: () => import("react").FC<import("./button-switch").IButtonSwitchProps>;
|
|
10
12
|
setViewModeToURL: typeof setViewModeToURL;
|
|
@@ -8,17 +8,6 @@ export type TPagination = {
|
|
|
8
8
|
hasPrev?: boolean;
|
|
9
9
|
total?: number;
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Virtualized rendering configuration.
|
|
13
|
-
* Used by both grid and list views for windowing optimization.
|
|
14
|
-
*/
|
|
15
|
-
export type TVirtualizedConfig = {
|
|
16
|
-
scrollTop: number;
|
|
17
|
-
viewportHeight: number;
|
|
18
|
-
/** Number of extra rows/columns rendered outside the viewport as a buffer. Defaults to `4` (grid) / `6` (table). */
|
|
19
|
-
overscan?: number;
|
|
20
|
-
gap?: number;
|
|
21
|
-
};
|
|
22
11
|
/**
|
|
23
12
|
* Controls how the list is rendered into the DOM.
|
|
24
13
|
* - `normal` — all rows are mounted (suitable for small datasets)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TGridSizes } from './types';
|
|
2
|
+
/** Default spacing between grid items in pixels. */
|
|
3
|
+
export declare const DEFAULT_GRID_SPACING_PX = 8;
|
|
4
|
+
/** Resolves the final grid spacing from multiple optional values. */
|
|
5
|
+
export declare const resolveGridSpacing: (...spacing: (number | undefined)[]) => number;
|
|
6
|
+
/** Default scrolling threshold in pixels for triggering near-end events. */
|
|
7
|
+
export declare const DEFAULT_GRID_SCROLLING_THRESHOLD_PX = 80;
|
|
8
|
+
/** Resolves the final scrolling threshold from multiple optional values. */
|
|
9
|
+
export declare const resolveGridScrollingThreshold: (...threshold: (number | undefined)[]) => number;
|
|
10
|
+
/** Default grid item height estimate in pixels, used for virtualization calculations. */
|
|
11
|
+
export declare const DEFAULT_GRID_ITEM_HEIGHT_ESTIMATE = 120;
|
|
12
|
+
/** Default grid item sizes for each breakpoint. */
|
|
13
|
+
export declare const DEFAULT_GRID_ITEM_SIZES: TGridSizes;
|
|
14
|
+
/** Returns the grid item sizes, falling back to defaults if not provided. */
|
|
15
|
+
export declare const getGridItemSizes: (sizes?: TGridSizes) => TGridSizes;
|
|
16
|
+
/** Normalizes grid item sizes, ensuring all breakpoints have a value. */
|
|
17
|
+
export declare const normalizeGridSizes: (sizes?: TGridSizes) => Required<TGridSizes>;
|
|
18
|
+
/** Resolves the number of grid columns based on the container width and item sizes. */
|
|
19
|
+
export declare const resolveGridColumnsFromWidth: (width: number, sizes?: TGridSizes) => number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IViewGridConfig, IViewGridProps } from './types';
|
|
3
|
+
/** Merges the provided props and config into a single configuration object. */
|
|
4
|
+
export declare const useMergedConfig: <T>(props: IViewGridProps<T>, config: IViewGridConfig<T>) => {
|
|
5
|
+
spacing: number;
|
|
6
|
+
scrollingThreshold: number;
|
|
7
|
+
sizes: Partial<Record<import("./types").TGridSize, number>>;
|
|
8
|
+
Component: import("react").FC<import("./types").IViewGridItemProps<any>> | import("react").ComponentType<import("./types").IViewGridItemProps<T>>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentType, FC } from 'react';
|
|
2
|
+
import type { LoadingModeRule, TPagination } from '../types';
|
|
3
|
+
import type { IViewGridConfig, IViewGridProps } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Factory function to create a Grid view component that can switch between normal and virtualized rendering strategies based on props and configuration.
|
|
7
|
+
* @param config - The configuration object for the grid view, containing default settings and required properties.
|
|
8
|
+
* @returns A React functional component that renders a grid view based on the provided configuration and props, supporting both normal and virtualized rendering strategies.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createViewGrid<T>(config: IViewGridConfig<T>): FC<IViewGridProps<T>>;
|
|
11
|
+
export interface IViewGridLoadingProps<T> extends IViewGridProps<T> {
|
|
12
|
+
value: T[];
|
|
13
|
+
loadMode: LoadingModeRule;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
pagination?: TPagination;
|
|
16
|
+
onPageChange?: (page: number, pageSize: number) => void | Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createViewGridLoading<T>(GridComponent: ComponentType<IViewGridProps<T>>): FC<IViewGridLoadingProps<T>>;
|
|
19
|
+
export default createViewGrid;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const viewGridClasses: {
|
|
3
|
+
root: string;
|
|
4
|
+
virtualized: string;
|
|
5
|
+
scrollContainer: string;
|
|
6
|
+
grid: string;
|
|
7
|
+
gridItem: string;
|
|
8
|
+
scrolling: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const ViewGridStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
11
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
12
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { RenderStrategyRule, TGetterId } from '../types';
|
|
3
|
+
export type TGridSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
export type TGridSizes = Partial<Record<TGridSize, number>>;
|
|
5
|
+
/**
|
|
6
|
+
* Props received by the custom render function for each card in Grid view.
|
|
7
|
+
* @template T - The shape of a single data row object.
|
|
8
|
+
*/
|
|
9
|
+
export interface IViewGridItemProps<T> {
|
|
10
|
+
/** The data object for this grid card. */
|
|
11
|
+
value: T;
|
|
12
|
+
/** Zero-based position of this item in the data array. */
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
export interface IViewGridBase<T> {
|
|
16
|
+
/** Spacing between grid items in pixels. @default 8 */
|
|
17
|
+
spacing?: number;
|
|
18
|
+
/** Scroll offset threshold in pixels before the `scrolling` class is applied. @default 80 */
|
|
19
|
+
scrollingThreshold?: number;
|
|
20
|
+
sizes?: TGridSizes;
|
|
21
|
+
/**
|
|
22
|
+
* Controls how the list is rendered into the DOM.
|
|
23
|
+
* - `normal` — all rows are mounted (suitable for small datasets)
|
|
24
|
+
* - `virtualized` — only visible rows are mounted (optimized for large datasets)
|
|
25
|
+
* @default 'normal'
|
|
26
|
+
*/
|
|
27
|
+
renderStrategy?: RenderStrategyRule;
|
|
28
|
+
Component?: ComponentType<IViewGridItemProps<T>>;
|
|
29
|
+
/** Number of extra rows rendered outside the viewport as a buffer when using virtualized rendering. @default 4 */
|
|
30
|
+
overscan?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface IViewGridConfig<T> extends IViewGridBase<T> {
|
|
33
|
+
getterId: TGetterId<T>;
|
|
34
|
+
}
|
|
35
|
+
export interface IViewGridProps<T> extends IViewGridBase<T> {
|
|
36
|
+
value: T[];
|
|
37
|
+
/** Called when user scrolls near the bottom of the list. Use this to trigger pagination or infinity load. */
|
|
38
|
+
onNearEnd?: () => void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TableCellProps } from '@mui/material';
|
|
2
|
+
import { ListDensity, TListColumn, TListColumns } from './types';
|
|
3
|
+
export declare const LIST_HEADER_HEIGHT = 48;
|
|
4
|
+
export declare const LIST_DEFAULT_ROW_SPACING = 4;
|
|
5
|
+
export declare const LIST_ROW_HEIGHT_BY_DENSITY: Record<ListDensity, number>;
|
|
6
|
+
export declare const LIST_CELL_PADDING_BY_DENSITY: Record<ListDensity, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Converts TListColumns<T> Record type to TListColumn<T>[] array for internal use.
|
|
9
|
+
*/
|
|
10
|
+
export declare const columnsRecordToArray: <T>(value: T[], columnsRecord?: Partial<Record<keyof T, Omit<TListColumn<T>, "field">>> | undefined) => TListColumn<T>[];
|
|
11
|
+
export declare function resolveListRowHeight(density?: number | ListDensity): number;
|
|
12
|
+
export declare function resolveListCellPadding(density?: number | ListDensity): string;
|
|
13
|
+
export declare function resolveListRowSpacing(spacing?: number): number;
|
|
14
|
+
export declare function resolveListSpacerHeight(count: number, rowHeight: number, rowSpacing: number): number;
|
|
15
|
+
export declare const mapSxTableCell: <T>(col: TListColumn<T>, totalFlex: number, sx?: TableCellProps['sx']) => TableCellProps['sx'];
|
package/dist/types/{lab/data-surface/view-list.units.d.ts → data-surface/view-list/hooks.d.ts}
RENAMED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { TGetterId } from '
|
|
3
|
-
|
|
4
|
-
export declare
|
|
5
|
-
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import type { TGetterId } from '../types';
|
|
3
|
+
import type { IViewListConfig, IViewListProps } from './types';
|
|
4
|
+
export declare function useMergedConfig<T>(config: IViewListConfig<T>, props: IViewListProps<T>): {
|
|
5
|
+
columns: import("./types").TListColumn<T>[];
|
|
6
|
+
selectable: boolean;
|
|
7
|
+
rowHeight: number;
|
|
8
|
+
cellPadding: string;
|
|
9
|
+
rowSpacing: number;
|
|
10
|
+
rootStyle: CSSProperties;
|
|
11
|
+
};
|
|
6
12
|
/**
|
|
7
13
|
* Custom hook to manage list row selection logic.
|
|
8
14
|
* Handles select all, individual row selection, and indeterminate state.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType, FC } from 'react';
|
|
2
|
+
import type { LoadingModeRule, TPagination } from '../types';
|
|
3
|
+
import type { IViewListConfig, IViewListProps } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export declare function createViewList<T>(config: IViewListConfig<T>): FC<IViewListProps<T>>;
|
|
6
|
+
export interface IViewListLoadingProps<T> extends IViewListProps<T> {
|
|
7
|
+
loadMode: LoadingModeRule;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
pagination?: TPagination;
|
|
10
|
+
onPageChange?: (page: number, pageSize: number) => void | Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createViewListLoading<T>(ListComponent: ComponentType<IViewListProps<T>>): FC<IViewListLoadingProps<T>>;
|
|
13
|
+
export default createViewList;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const VIEW_LIST_ROW_SPACING_VAR = "--DinoViewList-rowSpacing";
|
|
3
|
+
export declare const viewListClasses: {
|
|
4
|
+
root: string;
|
|
5
|
+
virtualized: string;
|
|
6
|
+
scrollContainer: string;
|
|
7
|
+
table: string;
|
|
8
|
+
tableHeader: string;
|
|
9
|
+
tableHeaderCell: string;
|
|
10
|
+
tableBodyCell: string;
|
|
11
|
+
tableSpacerRow: string;
|
|
12
|
+
tableSpacerCell: string;
|
|
13
|
+
tableCellContent: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const ViewListStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
16
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
17
|
+
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
package/dist/types/{lab/data-surface/view-list.types.d.ts → data-surface/view-list/types.d.ts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import { RenderStrategyRule, TGetterId } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Props received by the custom render function for each row in List view.
|
|
4
5
|
* @template T - The shape of a single data row object.
|
|
@@ -51,6 +52,7 @@ export interface TListColumn<T> {
|
|
|
51
52
|
/** Derives a value from the row before it is passed to the render step. */
|
|
52
53
|
valueGetter?: (value: string, row: T, index: number) => any;
|
|
53
54
|
}
|
|
55
|
+
/** Columns configuration for List view. */
|
|
54
56
|
export type TListColumns<T> = Partial<Record<keyof T, Omit<TListColumn<T>, 'field'>>>;
|
|
55
57
|
/**
|
|
56
58
|
* Row density preset for List view.
|
|
@@ -62,3 +64,39 @@ export declare const ListDensity: {
|
|
|
62
64
|
readonly comfortable: "comfortable";
|
|
63
65
|
};
|
|
64
66
|
export type ListDensity = keyof typeof ListDensity;
|
|
67
|
+
/** Base configuration for List view. */
|
|
68
|
+
export interface IViewListBase<T> {
|
|
69
|
+
/** Custom render function for list rows. If not provided, a default row layout will be used. */
|
|
70
|
+
columns?: TListColumns<T>;
|
|
71
|
+
/** Row height preset or an explicit row height in pixels. @default 'standard' */
|
|
72
|
+
density?: number | ListDensity;
|
|
73
|
+
/** Spacing between rows in pixels. @default 4 */
|
|
74
|
+
spacing?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Controls how the list is rendered into the DOM.
|
|
77
|
+
* - `normal` — all rows are mounted (suitable for small datasets)
|
|
78
|
+
* - `virtualized` — only visible rows are mounted (optimized for large datasets)
|
|
79
|
+
* @default 'normal'
|
|
80
|
+
*/
|
|
81
|
+
renderStrategy?: RenderStrategyRule;
|
|
82
|
+
/** Enable row selection with checkboxes. */
|
|
83
|
+
selectable?: boolean;
|
|
84
|
+
/** Number of extra rows rendered outside the viewport as a buffer when using virtualized rendering. @default 6 */
|
|
85
|
+
overscan?: number;
|
|
86
|
+
}
|
|
87
|
+
/** Configuration for List view. */
|
|
88
|
+
export interface IViewListConfig<T> extends IViewListBase<T> {
|
|
89
|
+
/** Function to extract unique row ID from a data item. Required for selection and virtualization. */
|
|
90
|
+
getterId: TGetterId<T>;
|
|
91
|
+
}
|
|
92
|
+
/** Props for List view component. */
|
|
93
|
+
export interface IViewListProps<T> extends IViewListBase<T> {
|
|
94
|
+
/** The array of data items to display in the list. */
|
|
95
|
+
value: T[];
|
|
96
|
+
/** Called when user scrolls near the bottom of the list. Use this to trigger pagination or infinity load. */
|
|
97
|
+
onNearEnd?: () => void;
|
|
98
|
+
/** Array of selected row IDs (controlled). */
|
|
99
|
+
selectedIds?: (string | number)[];
|
|
100
|
+
/** Callback when selection changes. */
|
|
101
|
+
onSelectionChange?: (selectedIds: (string | number)[]) => void;
|
|
102
|
+
}
|
|
@@ -22,7 +22,7 @@ declare class DinoDataViewBase {
|
|
|
22
22
|
seedKey: string;
|
|
23
23
|
} | null;
|
|
24
24
|
getSeedKeyFromURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "defaultSeedKey">) => string;
|
|
25
|
-
syncViewModeToURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "
|
|
25
|
+
syncViewModeToURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "defaultViewMode" | "viewMode">) => void;
|
|
26
26
|
getViewModeFromURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "defaultViewMode">) => import("./view-mode.types").EViewMode | undefined;
|
|
27
27
|
convertFilterToQueryParam: <T>(filterState?: import("./types").IFilterState<T> | undefined) => string;
|
|
28
28
|
formatterDate: (value: any, options?: IFormatterDateOptions) => string;
|
|
@@ -21,6 +21,6 @@ export declare const getQueryFromURL: <T>(params: IViewDataHandlerParams<T, "def
|
|
|
21
21
|
seedKey: string;
|
|
22
22
|
} | null;
|
|
23
23
|
export declare const getSeedKeyFromURL: <T>(params: IViewDataHandlerParams<T, "defaultSeedKey">) => string;
|
|
24
|
-
export declare const syncViewModeToURL: <T>(params: IViewDataHandlerParams<T, "
|
|
24
|
+
export declare const syncViewModeToURL: <T>(params: IViewDataHandlerParams<T, "defaultViewMode" | "viewMode">) => void;
|
|
25
25
|
export declare const getViewModeFromURL: <T>(params: IViewDataHandlerParams<T, "defaultViewMode">) => EViewMode | undefined;
|
|
26
26
|
export declare const convertFilterToQueryParam: <T>(filterState?: IFilterState<T> | undefined) => string;
|
|
@@ -28,6 +28,8 @@ export interface IFilterMenuConfig<T> extends IFilterMenuSlots {
|
|
|
28
28
|
fields: TFieldMenuConfigs<T>;
|
|
29
29
|
validation?: IFormValidatorConfig<Partial<TFieldModelValid<T>>>;
|
|
30
30
|
element?: ComponentType<IFilterMenuProps<T>>;
|
|
31
|
+
quickSearchHint?: string | ((currentHint: string) => string);
|
|
32
|
+
/** Option to enable or disable quick search @default true */
|
|
31
33
|
enableQuickSearch?: boolean;
|
|
32
34
|
}
|
|
33
35
|
export interface IFilterMenuProps<T> {
|
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
import type { BoxProps, PopperProps } from '@mui/material';
|
|
2
|
+
import type { BoxProps, IconButtonProps, PopperProps } from '@mui/material';
|
|
3
3
|
import type { TFieldType } from '../types';
|
|
4
4
|
export declare const FieldSortDirection: {
|
|
5
5
|
readonly asc: "asc";
|
|
6
6
|
readonly desc: "desc";
|
|
7
7
|
};
|
|
8
8
|
export type FieldSortDirection = keyof typeof FieldSortDirection;
|
|
9
|
-
export interface
|
|
9
|
+
export interface TFieldSort<T> {
|
|
10
10
|
field: TFieldType<T>;
|
|
11
11
|
label?: string;
|
|
12
|
-
/** Default is true, set to false to disable direction selection for this field (e.g. random sort doesn't have direction) */
|
|
13
|
-
enableDirection?: boolean;
|
|
14
|
-
/** Default is true, set to false to hide this field from the sort options */
|
|
15
|
-
visible?: boolean;
|
|
16
12
|
}
|
|
17
|
-
export type TFieldSorts<T> = Partial<Record<TFieldType<T>, Omit<
|
|
13
|
+
export type TFieldSorts<T> = Partial<Record<TFieldType<T>, Omit<TFieldSort<T>, 'field'>>>;
|
|
18
14
|
export interface IFilterSortSlots {
|
|
19
15
|
popperProps?: Partial<PopperProps>;
|
|
20
16
|
rootProps?: BoxProps;
|
|
17
|
+
buttonSortProps?: IconButtonProps;
|
|
18
|
+
buttonShuffleProps?: IconButtonProps;
|
|
21
19
|
}
|
|
22
20
|
export interface IFilterSortProps<T> {
|
|
23
21
|
sx?: BoxProps['sx'];
|
|
24
22
|
slots?: IFilterSortSlots;
|
|
25
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Configuration interface for filter and sort functionality.
|
|
26
|
+
* Extends slot definitions to provide sorting and shuffling capabilities.
|
|
27
|
+
*
|
|
28
|
+
* @template T - The type of data being filtered and sorted.
|
|
29
|
+
*
|
|
30
|
+
* @property {TFieldSorts<T>} fields - Available fields for sorting with optional labels.
|
|
31
|
+
* Note: Special keys 'quickSearch' and 'sortShuffle' are excluded.
|
|
32
|
+
* @property {boolean} [enableShuffle] - Optional flag to enable shuffle functionality.
|
|
33
|
+
* @property {'left' | 'right'} [shufflePosition='right'] - The horizontal position of the shuffle icon.
|
|
34
|
+
* Defaults to 'right' if not specified.
|
|
35
|
+
* @property {ComponentType<IFilterSortProps<T>>} [element] - Optional custom component for rendering
|
|
36
|
+
* the filter sort interface.
|
|
37
|
+
*/
|
|
26
38
|
export interface IFilterSortConfig<T> extends IFilterSortSlots {
|
|
39
|
+
/** Available fields for sorting with optional labels. Note: Special keys 'quickSearch' and 'sortShuffle' are excluded. */
|
|
27
40
|
fields: TFieldSorts<T>;
|
|
28
|
-
|
|
41
|
+
/** Optional flag to enable shuffle functionality. */
|
|
42
|
+
enableShuffle?: boolean;
|
|
43
|
+
/** The position of the shuffle icon. @default 'right' */
|
|
44
|
+
shufflePosition?: 'left' | 'right';
|
|
45
|
+
/** Optional custom component for rendering the filter sort interface. */
|
|
29
46
|
element?: ComponentType<IFilterSortProps<T>>;
|
|
30
47
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { IRichTooltipProps } from '../../components/rich-tooltip';
|
|
1
2
|
import type { FC, ReactNode } from 'react';
|
|
2
3
|
interface IHintIconProps {
|
|
3
4
|
title: ReactNode;
|
|
4
5
|
content: ReactNode;
|
|
6
|
+
slots?: {
|
|
7
|
+
richTooltipProps?: IRichTooltipProps;
|
|
8
|
+
};
|
|
5
9
|
}
|
|
6
10
|
export declare const HintIcon: FC<IHintIconProps>;
|
|
7
11
|
export declare function createHintIcon(param: IHintIconProps): FC<Partial<IHintIconProps>>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { KeySpecial, TFilterState } from './types';
|
|
2
|
+
export declare const mapSpecialTexts: {
|
|
3
|
+
qsTooltip: string;
|
|
4
|
+
};
|
|
2
5
|
export declare const mapSpecialLabel: Record<KeySpecial, string>;
|
|
3
6
|
export interface IFilterStateQueryParams {
|
|
4
7
|
filter?: string;
|
|
@@ -35,14 +38,14 @@ export declare function setFilterToURL<T>(state?: TFilterState<T>, defaultState?
|
|
|
35
38
|
*/
|
|
36
39
|
export declare function getFilterFromURL<T>(defaultState?: TFilterState<T>): TFilterState<T> | undefined;
|
|
37
40
|
/**
|
|
38
|
-
* @en Set seed value to URL for
|
|
39
|
-
* @vi Dat gia tri seed vao URL de sap xep
|
|
40
|
-
* @param seed - Seed value for
|
|
41
|
+
* @en Set seed value to URL for shuffle sorting. If seed is undefined, remove from URL.
|
|
42
|
+
* @vi Dat gia tri seed vao URL de sap xep shuffle. Neu seed khong xac dinh, xoa khoi URL.
|
|
43
|
+
* @param seed - Seed value for shuffle sorting
|
|
41
44
|
*/
|
|
42
45
|
export declare const setSeedToURL: (seed?: string) => void;
|
|
43
46
|
/**
|
|
44
|
-
* @en Get seed value from URL for
|
|
45
|
-
* @vi Lay gia tri seed tu URL de sap xep
|
|
47
|
+
* @en Get seed value from URL for shuffle sorting. Returns undefined if not set or on error.
|
|
48
|
+
* @vi Lay gia tri seed tu URL de sap xep shuffle. Tra ve undefined neu khong duoc dat hoac co loi.
|
|
46
49
|
* @returns Seed value from URL or undefined
|
|
47
50
|
*/
|
|
48
51
|
export declare const getSeedFromURL: () => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IFilterBarContext } from '
|
|
2
|
-
import type { TFieldSort, TFieldStore, TFieldType, TFieldValid, TFieldValue, TLogic } from '
|
|
1
|
+
import type { IFilterBarContext } from './index.context';
|
|
2
|
+
import type { TFieldSort, TFieldStore, TFieldType, TFieldValid, TFieldValue, TLogic } from './types';
|
|
3
3
|
type TOptions = {
|
|
4
4
|
logic?: TLogic;
|
|
5
5
|
};
|
|
@@ -6,6 +6,7 @@ export interface IFilterBarContextActions<T> {
|
|
|
6
6
|
export interface IFilterBarContextState<T> {
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
filterState: TFilterState<T>;
|
|
9
|
+
defaultFilterState?: TFilterState<T>;
|
|
9
10
|
}
|
|
10
11
|
export interface IFilterBarContext<T> extends IFilterBarContextState<T>, IFilterBarContextActions<T> {
|
|
11
12
|
}
|
|
@@ -6,7 +6,9 @@ import type { IFilterSortConfig, IFilterSortProps } from './components/filter-so
|
|
|
6
6
|
import type { IFilterInputConfig, IFilterInputProps } from './components/filter-input.types';
|
|
7
7
|
import type { IFilterSummaryConfig, IFilterSummaryProps } from './components/filter-summary.types';
|
|
8
8
|
export interface IFilterBarConfigs<T> {
|
|
9
|
-
|
|
9
|
+
/** Debounce delay for filter input changes in milliseconds @default 300 */
|
|
10
|
+
debounceDelay?: number;
|
|
11
|
+
defaultFilterState?: TFilterState<T>;
|
|
10
12
|
/** Default filter logic, can be overridden by individual filters @default "and" */
|
|
11
13
|
defaultFilterLogic?: 'and' | 'or';
|
|
12
14
|
InputComponent?: ComponentType<IFilterInputProps<T>>;
|
|
@@ -30,6 +32,7 @@ export interface IFilterBarSlots {
|
|
|
30
32
|
export interface IFilterBarProps<T> {
|
|
31
33
|
sx?: BoxProps['sx'];
|
|
32
34
|
value?: TFilterState<T>;
|
|
35
|
+
defaultValue?: TFilterState<T>;
|
|
33
36
|
onChange?: (state: TFilterState<T>) => Promise<void> | void;
|
|
34
37
|
slots?: IFilterBarSlots;
|
|
35
38
|
}
|
|
@@ -19,7 +19,7 @@ export type TFieldValid = string | number | boolean;
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const KeySpecial: {
|
|
21
21
|
readonly quickSearch: "quickSearch";
|
|
22
|
-
readonly
|
|
22
|
+
readonly sortShuffle: "sortShuffle";
|
|
23
23
|
};
|
|
24
24
|
export type KeySpecial = keyof typeof KeySpecial;
|
|
25
25
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dinocollab-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.10",
|
|
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,12 +32,18 @@
|
|
|
32
32
|
"filter-bar": [
|
|
33
33
|
"./dist/types/filter-bar/index.d.ts"
|
|
34
34
|
],
|
|
35
|
-
"
|
|
36
|
-
"./dist/types/
|
|
35
|
+
"table": [
|
|
36
|
+
"./dist/types/table/index.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"table-grid": [
|
|
39
|
+
"./dist/types/table-grid/index.d.ts"
|
|
37
40
|
],
|
|
38
41
|
"data-view": [
|
|
39
42
|
"./dist/types/data-view/index.d.ts"
|
|
40
43
|
],
|
|
44
|
+
"data-surface": [
|
|
45
|
+
"./dist/types/data-surface/index.d.ts"
|
|
46
|
+
],
|
|
41
47
|
"form": [
|
|
42
48
|
"./dist/types/form/index.d.ts"
|
|
43
49
|
],
|
|
@@ -56,12 +62,6 @@
|
|
|
56
62
|
"redux": [
|
|
57
63
|
"./dist/types/redux/index.d.ts"
|
|
58
64
|
],
|
|
59
|
-
"table": [
|
|
60
|
-
"./dist/types/table/index.d.ts"
|
|
61
|
-
],
|
|
62
|
-
"table-grid": [
|
|
63
|
-
"./dist/types/table-grid/index.d.ts"
|
|
64
|
-
],
|
|
65
65
|
"utils": [
|
|
66
66
|
"./dist/types/utils/index.d.ts"
|
|
67
67
|
]
|
|
@@ -84,14 +84,22 @@
|
|
|
84
84
|
"import": "./dist/filter-bar/index.js",
|
|
85
85
|
"types": "./dist/types/filter-bar/index.d.ts"
|
|
86
86
|
},
|
|
87
|
-
"./
|
|
88
|
-
"import": "./dist/
|
|
89
|
-
"types": "./dist/types/
|
|
87
|
+
"./table": {
|
|
88
|
+
"import": "./dist/table/index.js",
|
|
89
|
+
"types": "./dist/types/table/index.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./table-grid": {
|
|
92
|
+
"import": "./dist/table-grid/index.js",
|
|
93
|
+
"types": "./dist/types/table-grid/index.d.ts"
|
|
90
94
|
},
|
|
91
95
|
"./data-view": {
|
|
92
96
|
"import": "./dist/data-view/index.js",
|
|
93
97
|
"types": "./dist/types/data-view/index.d.ts"
|
|
94
98
|
},
|
|
99
|
+
"./data-surface": {
|
|
100
|
+
"import": "./dist/data-surface/index.js",
|
|
101
|
+
"types": "./dist/types/data-surface/index.d.ts"
|
|
102
|
+
},
|
|
95
103
|
"./form": {
|
|
96
104
|
"import": "./dist/form/index.js",
|
|
97
105
|
"types": "./dist/types/form/index.d.ts"
|
|
@@ -116,14 +124,6 @@
|
|
|
116
124
|
"import": "./dist/redux/index.js",
|
|
117
125
|
"types": "./dist/types/redux/index.d.ts"
|
|
118
126
|
},
|
|
119
|
-
"./table": {
|
|
120
|
-
"import": "./dist/table/index.js",
|
|
121
|
-
"types": "./dist/types/table/index.d.ts"
|
|
122
|
-
},
|
|
123
|
-
"./table-grid": {
|
|
124
|
-
"import": "./dist/table-grid/index.js",
|
|
125
|
-
"types": "./dist/types/table-grid/index.d.ts"
|
|
126
|
-
},
|
|
127
127
|
"./utils": {
|
|
128
128
|
"import": "./dist/utils/index.js",
|
|
129
129
|
"types": "./dist/types/utils/index.d.ts"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export{DataSurfaceViewMode,LoadingModeRule,RenderStrategyRule}from"../../src/lab/data-surface/types.js";export{getPaginationFromURL,getViewModeFromURL,setPaginationToURL,setViewModeToURL}from"../../src/lab/data-surface/helpers.js";export{createDataSurface}from"../../src/lab/data-surface/index.create.js";export{ListDensity}from"../../src/lab/data-surface/view-list.types.js";export{DinoDataSurFace,dinoDataSurface}from"../../src/lab/data-surface/index.dino.js";export{ButtonSwitch}from"../../src/lab/data-surface/button-switch.js";
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{objectSpread2 as t,defineProperty as e,toConsumableArray as r}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{KeySpecial as i}from"../types.js";var l=function(t,e,r){if(!t)return!1;var i=t[e];if(!i)return!1;var l=r.logic!==i.logic,o=new Set(i.values.map(function(t){return JSON.stringify(t)}).filter(Boolean));return r.values.some(function(t){return o.has(JSON.stringify(t))})&&!l},o=function(t,i,l){var o=null==t?void 0:t[i],n={values:Array.from(new Set([].concat(r((null==o?void 0:o.values)||[]),r(l.values)).filter(Boolean))),logic:l.logic||(null==o?void 0:o.logic)};return Object.assign({},t,e({},i,n))},n=function(r){return{addFilter:function(e,i,n){var a=r.filterState.storeFilter,s=t(t({},i),{},{logic:(null==n?void 0:n.logic)||i.logic});if(!l(a,e,s)){var u=o(a,e,s),f=Object.assign({},a,u);r.setFilterState(t(t({},r.filterState),{},{storeFilter:f}))}},replaceFilter:function(i,l,o){var n=t(t({},l),{},{logic:(null==o?void 0:o.logic)||l.logic}),a=Object.assign({},r.filterState.storeFilter,e({},i,n));r.setFilterState(t(t({},r.filterState),{},{storeFilter:a}))},upsertManyFilter:function(e,i,n){if(0!==i.values.length){var a=Object.assign({},r.filterState.storeFilter);i.values.forEach(function(t){var r={values:[t],logic:(null==n?void 0:n.logic)||i.logic};l(a,e,r)||(a=o(a,e,r))}),r.setFilterState(t(t({},r.filterState),{},{storeFilter:a}))}},removeFilter:function(e){var i=Object.assign({},r.filterState.storeFilter);delete i[e],r.setFilterState(t(t({},r.filterState),{},{storeFilter:i}))},removeFilterByFieldValue:function(e,i){var l=Object.assign({},r.filterState.storeFilter),o=l[e];o&&(l[e]=t(t({},o),{},{values:o.values.filter(function(t){return t.toString()!==i.toString()})}),l[e]&&0===l[e].values.length&&delete l[e],r.setFilterState(t(t({},r.filterState),{},{storeFilter:l})))},clearAllFilters:function(){r.setFilterState(t(t({},r.filterState),{},{storeFilter:{}}))},getFieldInfo:function(t){var e;return null===(e=r.filterState.storeFilter)||void 0===e?void 0:e[t]},getTotalCount:function(){var t=r.filterState.storeFilter;return t?Object.keys(t).reduce(function(e,r){var i=t[r];return e+(i?i.values.length:0)},0):0},hasSortByField:function(t){var e=r.filterState.storeSort;return(null==e?void 0:e.field)===t},getSort:function(){return r.filterState.storeSort},changeSort:function(e){var l=r.filterState.storeSort,o=e===i.sortRandom,n=(null==l?void 0:l.field)===e;if(o){var a=void 0;return n||(a={field:e}),void r.setFilterState(t(t({},r.filterState),{},{storeSort:a}))}var s="desc";n&&(s="desc"===l.direction?"asc":"desc"),r.setFilterState(t(t({},r.filterState),{},{storeSort:{field:e,direction:s}}))},removeSort:function(){r.setFilterState(t(t({},r.filterState),{},{storeSort:void 0}))}}};export{n as useFilterActions};
|
|
2
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../../src/filter-bar/components/hooks.ts"],"sourcesContent":["// Copyright (c) 2024-present, Dinocollab Technologies, Inc. and its affiliates. All rights reserved.\r\n\r\n// types\r\nimport { KeySpecial } from '../types'\r\nimport type { IFilterBarContext } from '../index.context'\r\nimport type { TFieldSort, TFieldStore, TFieldType, TFieldValid, TFieldValue, TLogic } from '../types'\r\n\r\ntype TOptions = {\r\n logic?: TLogic\r\n}\r\n\r\n/**\r\n * Check if a given filter value already exists in the store for a specific field.\r\n * @param storeFilter - The current filter store.\r\n * @param field - The field to check for duplicate values.\r\n * @param value - The filter value to check for duplicates.\r\n * @returns True if a duplicate value exists, false otherwise.\r\n */\r\nconst checkDuplicateValue = <T>(storeFilter: TFieldStore<T> | undefined, field: keyof TFieldStore<T>, value: TFieldValue): boolean => {\r\n // If there is no filter store or no filter values for the field, there can be no duplicates\r\n if (!storeFilter) return false\r\n const fieldValue = storeFilter[field]\r\n // If there are no filter values for the field, there can be no duplicates\r\n if (!fieldValue) return false\r\n const isLogicChange = value.logic !== fieldValue.logic\r\n // Create a set of existing values for the field to efficiently check for duplicates\r\n const fieldSet = new Set(fieldValue.values.map((v) => JSON.stringify(v)).filter(Boolean))\r\n return value.values.some((v) => fieldSet.has(JSON.stringify(v))) && !isLogicChange\r\n}\r\n/**\r\n * Merge a filter value into the store for a specific field.\r\n * @param storeFilter - The current filter store.\r\n * @param field - The field to merge the value into.\r\n * @param value - The filter value to merge.\r\n * @returns The updated filter store.\r\n */\r\nconst mergeValueToStoreFilter = <T>(storeFilter: TFieldStore<T> | undefined, field: keyof TFieldStore<T>, value: TFieldValue): TFieldStore<T> => {\r\n const fieldValue: TFieldValue | undefined = storeFilter?.[field]\r\n const values = Array.from(new Set([...(fieldValue?.values || []), ...value.values].filter(Boolean)))\r\n const newData: TFieldValue = { values, logic: value.logic || fieldValue?.logic }\r\n return Object.assign({}, storeFilter, { [field]: newData }) as TFieldStore<T>\r\n}\r\n\r\nexport const useFilterActions = <T>(context: IFilterBarContext<T>) => {\r\n /**\r\n * Add a filter value to the store for a specific field.\r\n * @param field - The field to add the filter value to.\r\n * @param value - The filter value to add.\r\n * @returns void\r\n */\r\n const addFilter = (field: keyof TFieldStore<T>, value: TFieldValue, options?: TOptions) => {\r\n // Check for duplicate value before adding\r\n const { storeFilter } = context.filterState\r\n const valueObj: TFieldValue = { ...value, logic: options?.logic || value.logic }\r\n // If the value already exists in the store for the field, do not add it again\r\n if (checkDuplicateValue(storeFilter, field, valueObj)) return\r\n // Merge the new value into the store filter for the field\r\n const newData = mergeValueToStoreFilter(storeFilter, field, valueObj)\r\n const newStoreFilter = Object.assign({}, storeFilter, newData)\r\n context.setFilterState({ ...context.filterState, storeFilter: newStoreFilter })\r\n }\r\n /**\r\n * Replace all filter values for a specific field in the store with a new value.\r\n * Value will be replaced instead of merged, which is useful for single-value filters or when you want to reset the filter values for a field.\r\n * @param field - The field to update the filter value for.\r\n * @param value - The new filter value to set.\r\n */\r\n const replaceFilter = (field: keyof TFieldStore<T>, value: TFieldValue, options?: TOptions) => {\r\n const valueObj: TFieldValue = { ...value, logic: options?.logic || value.logic }\r\n const newStoreFilter = Object.assign({}, context.filterState.storeFilter, { [field]: valueObj })\r\n context.setFilterState({ ...context.filterState, storeFilter: newStoreFilter as TFieldStore<T> })\r\n }\r\n /**\r\n * Add multiple filter values to the store for a specific field, ensuring no duplicates are added.\r\n * @param field - The field to add the filter values to.\r\n * @param values - The filter values to add.\r\n * @returns void\r\n */\r\n const upsertManyFilter = (field: keyof TFieldStore<T>, value: TFieldValue, options?: TOptions) => {\r\n // If there are no values to add, return early\r\n if (value.values.length === 0) return\r\n let newStoreFilter = Object.assign({}, context.filterState.storeFilter)\r\n // Iterate through each value and add it to the store filter for the field, checking for duplicates\r\n value.values.forEach((val) => {\r\n const valueObj: TFieldValue = { values: [val], logic: options?.logic || value.logic }\r\n if (checkDuplicateValue(newStoreFilter, field, valueObj)) return\r\n newStoreFilter = mergeValueToStoreFilter(newStoreFilter, field, valueObj)\r\n })\r\n // Update the filter state with the new store filter after adding all values\r\n context.setFilterState({ ...context.filterState, storeFilter: newStoreFilter })\r\n }\r\n /**\r\n * Remove all filter values for a specific field from the store.\r\n * @param field - The field to remove filters from.\r\n * @returns void\r\n */\r\n const removeFilter = (field: TFieldType<T>) => {\r\n const newStoreFilter = Object.assign({}, context.filterState.storeFilter)\r\n delete newStoreFilter[field]\r\n context.setFilterState({ ...context.filterState, storeFilter: newStoreFilter })\r\n }\r\n\r\n const removeFilterByFieldValue = (field: TFieldType<T>, value: TFieldValid) => {\r\n const newStoreFilter = Object.assign({}, context.filterState.storeFilter)\r\n const fieldVal: TFieldValue | undefined = newStoreFilter[field]\r\n if (!fieldVal) return\r\n newStoreFilter[field] = { ...fieldVal, values: fieldVal.values.filter((v) => v.toString() !== value.toString()) }\r\n if (newStoreFilter[field] && newStoreFilter[field]!.values.length === 0) {\r\n delete newStoreFilter[field]\r\n }\r\n context.setFilterState({ ...context.filterState, storeFilter: newStoreFilter })\r\n }\r\n\r\n const clearAllFilters = () => {\r\n context.setFilterState({ ...context.filterState, storeFilter: {} as TFieldStore<T> })\r\n }\r\n\r\n const getFieldInfo = (field: TFieldType<T>): TFieldValue | undefined => {\r\n const fieldVal = context.filterState.storeFilter?.[field]\r\n return fieldVal\r\n }\r\n\r\n const getTotalCount = (): number => {\r\n const storeFilter = context.filterState.storeFilter\r\n if (!storeFilter) return 0\r\n const keys = Object.keys(storeFilter) as (keyof TFieldStore<T>)[]\r\n return keys.reduce((acc, key) => {\r\n const fieldVal = storeFilter[key]\r\n return acc + (fieldVal ? fieldVal.values.length : 0)\r\n }, 0)\r\n }\r\n\r\n const hasSortByField = (field: TFieldType<T>): boolean => {\r\n const sort = context.filterState.storeSort\r\n return sort?.field === field\r\n }\r\n\r\n const getSort = (): TFieldSort<T> | undefined => {\r\n return context.filterState.storeSort\r\n }\r\n\r\n const changeSort = (field: TFieldType<T>) => {\r\n const currentSort = context.filterState.storeSort\r\n const isRandom = field === KeySpecial.sortRandom\r\n const isEqualField = currentSort?.field === field\r\n if (isRandom) {\r\n // if current sort is random and user click random again, we remove the sort\r\n let newValue: TFieldSort<T> | undefined = undefined\r\n if (!isEqualField) newValue = { field }\r\n context.setFilterState({ ...context.filterState, storeSort: newValue })\r\n return\r\n }\r\n let newDirection: 'asc' | 'desc' = 'desc'\r\n if (isEqualField) newDirection = currentSort.direction === 'desc' ? 'asc' : 'desc'\r\n context.setFilterState({ ...context.filterState, storeSort: { field, direction: newDirection } })\r\n }\r\n\r\n const removeSort = () => {\r\n context.setFilterState({ ...context.filterState, storeSort: undefined })\r\n }\r\n\r\n return {\r\n addFilter,\r\n replaceFilter,\r\n upsertManyFilter,\r\n removeFilter,\r\n removeFilterByFieldValue,\r\n clearAllFilters,\r\n getFieldInfo,\r\n getTotalCount,\r\n hasSortByField,\r\n getSort,\r\n changeSort,\r\n removeSort\r\n }\r\n}\r\n"],"names":["checkDuplicateValue","storeFilter","field","value","fieldValue","isLogicChange","logic","fieldSet","Set","values","map","v","JSON","stringify","filter","Boolean","some","has","mergeValueToStoreFilter","newData","Array","from","concat","_toConsumableArray","Object","assign","_defineProperty","useFilterActions","context","addFilter","options","filterState","valueObj","_objectSpread","newStoreFilter","setFilterState","replaceFilter","upsertManyFilter","length","forEach","val","removeFilter","removeFilterByFieldValue","fieldVal","toString","clearAllFilters","getFieldInfo","_context$filterState$","getTotalCount","keys","reduce","acc","key","hasSortByField","sort","storeSort","getSort","changeSort","currentSort","isRandom","KeySpecial","sortRandom","isEqualField","newValue","undefined","newDirection","direction","removeSort"],"mappings":"mKAkBA,IAAMA,EAAsB,SAAIC,EAAyCC,EAA6BC,GAEpG,IAAKF,EAAa,OAAO,EACzB,IAAMG,EAAaH,EAAYC,GAE/B,IAAKE,EAAY,OAAO,EACxB,IAAMC,EAAgBF,EAAMG,QAAUF,EAAWE,MAE3CC,EAAW,IAAIC,IAAIJ,EAAWK,OAAOC,IAAI,SAACC,GAAC,OAAKC,KAAKC,UAAUF,EAAE,GAAEG,OAAOC,UAChF,OAAOZ,EAAMM,OAAOO,KAAK,SAACL,GAAC,OAAKJ,EAASU,IAAIL,KAAKC,UAAUF,GAAI,KAAKN,CACvE,EAQMa,EAA0B,SAAIjB,EAAyCC,EAA6BC,GACxG,IAAMC,EAAsCH,aAAAA,EAAAA,EAAcC,GAEpDiB,EAAuB,CAAEV,OADhBW,MAAMC,KAAK,IAAIb,IAAI,GAAAc,OAAAC,GAAKnB,aAAAA,EAAAA,EAAYK,SAAU,IAAEc,EAAMpB,EAAMM,SAAQK,OAAOC,WACnDT,MAAOH,EAAMG,QAASF,aAAU,EAAVA,EAAYE,QACzE,OAAOkB,OAAOC,OAAO,GAAIxB,EAAWyB,EAAKxB,CAAAA,EAAAA,EAAQiB,GACnD,EAEaQ,EAAmB,SAAIC,GAsHlC,MAAO,CACLC,UAhHgB,SAAC3B,EAA6BC,EAAoB2B,GAElE,IAAQ7B,EAAgB2B,EAAQG,YAAxB9B,YACF+B,EAAQC,EAAAA,KAAqB9B,GAAK,GAAA,CAAEG,OAAOwB,aAAAA,EAAAA,EAASxB,QAASH,EAAMG,QAEzE,IAAIN,EAAoBC,EAAaC,EAAO8B,GAA5C,CAEA,IAAMb,EAAUD,EAAwBjB,EAAaC,EAAO8B,GACtDE,EAAiBV,OAAOC,OAAO,CAAA,EAAIxB,EAAakB,GACtDS,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAE9B,YAAaiC,IAJP,CAKxD,EAuGCE,cAhGoB,SAAClC,EAA6BC,EAAoB2B,GACtE,IAAME,EAAQC,EAAAA,KAAqB9B,GAAK,GAAA,CAAEG,OAAOwB,aAAAA,EAAAA,EAASxB,QAASH,EAAMG,QACnE4B,EAAiBV,OAAOC,OAAO,CAAE,EAAEG,EAAQG,YAAY9B,YAAWyB,KAAKxB,EAAQ8B,IACrFJ,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAE9B,YAAaiC,IAC/D,EA6FCG,iBAtFuB,SAACnC,EAA6BC,EAAoB2B,GAEzE,GAA4B,IAAxB3B,EAAMM,OAAO6B,OAAjB,CACA,IAAIJ,EAAiBV,OAAOC,OAAO,CAAE,EAAEG,EAAQG,YAAY9B,aAE3DE,EAAMM,OAAO8B,QAAQ,SAACC,GACpB,IAAMR,EAAwB,CAAEvB,OAAQ,CAAC+B,GAAMlC,OAAOwB,aAAAA,EAAAA,EAASxB,QAASH,EAAMG,OAC1EN,EAAoBkC,EAAgBhC,EAAO8B,KAC/CE,EAAiBhB,EAAwBgB,EAAgBhC,EAAO8B,GAClE,GAEAJ,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAE9B,YAAaiC,IAT/B,CAUhC,EA2ECO,aArEmB,SAACvC,GACpB,IAAMgC,EAAiBV,OAAOC,OAAO,CAAE,EAAEG,EAAQG,YAAY9B,oBACtDiC,EAAehC,GACtB0B,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAE9B,YAAaiC,IAC/D,EAkECQ,yBAhE+B,SAACxC,EAAsBC,GACtD,IAAM+B,EAAiBV,OAAOC,OAAO,CAAE,EAAEG,EAAQG,YAAY9B,aACvD0C,EAAoCT,EAAehC,GACpDyC,IACLT,EAAehC,GAAM+B,EAAAA,KAAQU,GAAQ,GAAA,CAAElC,OAAQkC,EAASlC,OAAOK,OAAO,SAACH,GAAC,OAAKA,EAAEiC,aAAezC,EAAMyC,UAAU,KAC1GV,EAAehC,IAAmD,IAAzCgC,EAAehC,GAAQO,OAAO6B,eAClDJ,EAAehC,GAExB0B,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAE9B,YAAaiC,KAC/D,EAwDCW,gBAtDsB,WACtBjB,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAE9B,YAAa,CAAA,IAC/D,EAqDC6C,aAnDmB,SAAC5C,GAAiD,IAAA6C,EAErE,eADcA,EAAGnB,EAAQG,YAAY9B,mBAAW,IAAA8C,OAAA,EAA/BA,EAAkC7C,EAEpD,EAiDC8C,cA/CoB,WACpB,IAAM/C,EAAc2B,EAAQG,YAAY9B,YACxC,OAAKA,EACQuB,OAAOyB,KAAKhD,GACbiD,OAAO,SAACC,EAAKC,GACvB,IAAMT,EAAW1C,EAAYmD,GAC7B,OAAOD,GAAOR,EAAWA,EAASlC,OAAO6B,OAAS,EACnD,EAAE,GALsB,CAM1B,EAwCCe,eAtCqB,SAACnD,GACtB,IAAMoD,EAAO1B,EAAQG,YAAYwB,UACjC,OAAOD,eAAAA,EAAMpD,SAAUA,CACxB,EAoCCsD,QAlCc,WACd,OAAO5B,EAAQG,YAAYwB,SAC5B,EAiCCE,WA/BiB,SAACvD,GAClB,IAAMwD,EAAc9B,EAAQG,YAAYwB,UAClCI,EAAWzD,IAAU0D,EAAWC,WAChCC,GAAeJ,aAAW,EAAXA,EAAaxD,SAAUA,EAC5C,GAAIyD,EAAU,CAEZ,IAAII,OAAsCC,EAG1C,OAFKF,IAAcC,EAAW,CAAE7D,MAAAA,SAChC0B,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAEwB,UAAWQ,IAE7D,CACD,IAAIE,EAA+B,OAC/BH,IAAcG,EAAyC,SAA1BP,EAAYQ,UAAuB,MAAQ,QAC5EtC,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAEwB,UAAW,CAAErD,MAAAA,EAAOgE,UAAWD,KACjF,EAkBCE,WAhBiB,WACjBvC,EAAQO,eAAcF,EAAAA,EAAA,CAAA,EAAML,EAAQG,aAAW,GAAA,CAAEwB,eAAWS,IAC7D,EAgBH"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as o}from"react/jsx-runtime";import{useRef as e,useCallback as r}from"react";import{styled as l,ToggleButtonGroup as a,colors as i,Tooltip as n,ToggleButton as t}from"@mui/material";import u from"@mui/icons-material/ViewList";import c from"@mui/icons-material/GridView";import{DataSurfaceViewMode as m}from"./types.js";var s={sm:"small",md:"medium"},d=[{value:m.list,icon:o(u,{fontSize:"small"}),label:"List View"},{value:m.grid,icon:o(c,{fontSize:"small"}),label:"Grid View"}],v=function(l){var a=l.value,i=l.onChange,u=l.size,c=void 0===u?"md":u,m=l.className,v=l.onlyIcon,f=void 0!==v&&v,g=l.reverse,p=void 0!==g&&g,h=s[c]||"small",w=e(null),x=r(function(o){w.current&&clearTimeout(w.current),w.current=setTimeout(function(){null!==o&&o!==a&&(null==i||i(o))},250)},[a,i]),C=p?[].concat(d).reverse():d;return o(b,{className:m,size:h,value:a,exclusive:!0,onChange:function(o,e){return x(e)},"aria-label":"view mode",children:C.map(function(e){return o(n,{title:e.label,arrow:!0,children:o(t,{value:e.value,"aria-label":e.label,size:h,sx:{p:f?"5px":void 0,minWidth:f?"small"===h?36:44:void 0},children:f?e.icon:e.label})},e.value)})})},b=l(a)({flex:"0 0 auto",".MuiToggleButtonGroup-grouped":{"&.Mui-selected":{color:i.common.white,backgroundColor:"var(--color-orange, ".concat(i.blue[600],")"),borderColor:"var(--color-orange, ".concat(i.blue[600],")"),"&.MuiToggleButtonGroup-lastButton":{borderColor:"var(--color-orange, ".concat(i.blue[600],")")},"&:hover":{backgroundColor:"var(--color-orange, ".concat(i.blue[600],")")}}}});export{v as ButtonSwitch,v as default};
|
|
2
|
-
//# sourceMappingURL=button-switch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button-switch.js","sources":["../../../../src/lab/data-surface/button-switch.tsx"],"sourcesContent":["import { FC, useCallback, useRef } from 'react'\r\nimport { colors, styled, ToggleButton, ToggleButtonGroup, Tooltip } from '@mui/material'\r\nimport ViewListIcon from '@mui/icons-material/ViewList'\r\nimport GridViewIcon from '@mui/icons-material/GridView'\r\nimport { DataSurfaceViewMode } from './types'\r\n\r\nexport interface IButtonSwitchProps {\r\n value?: DataSurfaceViewMode\r\n onChange?: (value: DataSurfaceViewMode) => void\r\n size?: 'sm' | 'md'\r\n className?: string\r\n onlyIcon?: boolean\r\n reverse?: boolean\r\n}\r\n\r\nconst sizeMap = { sm: 'small', md: 'medium' } as const\r\n\r\nconst viewModes = [\r\n { value: DataSurfaceViewMode.list, icon: <ViewListIcon fontSize='small' />, label: 'List View' },\r\n { value: DataSurfaceViewMode.grid, icon: <GridViewIcon fontSize='small' />, label: 'Grid View' }\r\n]\r\n\r\nexport const ButtonSwitch: FC<IButtonSwitchProps> = (props) => {\r\n const { value, onChange, size = 'md', className, onlyIcon = false, reverse = false } = props\r\n const muiSize = sizeMap[size] || 'small'\r\n\r\n const changeTimeoutRef = useRef<NodeJS.Timeout | null>(null)\r\n const handleChange = useCallback(\r\n (newValue: DataSurfaceViewMode | null) => {\r\n if (changeTimeoutRef.current) {\r\n clearTimeout(changeTimeoutRef.current)\r\n }\r\n changeTimeoutRef.current = setTimeout(() => {\r\n if (newValue !== null && newValue !== value) {\r\n onChange?.(newValue)\r\n }\r\n }, 250)\r\n },\r\n [value, onChange]\r\n )\r\n\r\n const displayModes = reverse ? [...viewModes].reverse() : viewModes\r\n\r\n return (\r\n <StyledToggleButtonGroup className={className} size={muiSize} value={value} exclusive onChange={(_, v) => handleChange(v)} aria-label='view mode'>\r\n {displayModes.map((mode) => (\r\n <Tooltip key={mode.value} title={mode.label} arrow>\r\n <ToggleButton\r\n value={mode.value}\r\n aria-label={mode.label}\r\n size={muiSize}\r\n sx={{\r\n p: onlyIcon ? '5px' : undefined,\r\n minWidth: onlyIcon ? (muiSize === 'small' ? 36 : 44) : undefined\r\n }}\r\n >\r\n {onlyIcon ? mode.icon : mode.label}\r\n </ToggleButton>\r\n </Tooltip>\r\n ))}\r\n </StyledToggleButtonGroup>\r\n )\r\n}\r\n\r\nexport default ButtonSwitch\r\n\r\nconst StyledToggleButtonGroup = styled(ToggleButtonGroup)({\r\n flex: '0 0 auto',\r\n '.MuiToggleButtonGroup-grouped': {\r\n '&.Mui-selected': {\r\n color: colors.common.white,\r\n backgroundColor: `var(--color-orange, ${colors.blue[600]})`,\r\n borderColor: `var(--color-orange, ${colors.blue[600]})`,\r\n '&.MuiToggleButtonGroup-lastButton': {\r\n borderColor: `var(--color-orange, ${colors.blue[600]})`\r\n },\r\n '&:hover': {\r\n backgroundColor: `var(--color-orange, ${colors.blue[600]})`\r\n }\r\n }\r\n }\r\n})\r\n"],"names":["sizeMap","sm","md","viewModes","value","DataSurfaceViewMode","list","icon","_jsx","ViewListIcon","fontSize","label","grid","GridViewIcon","ButtonSwitch","props","onChange","_props$size","size","className","_props$onlyIcon","onlyIcon","_props$reverse","reverse","muiSize","changeTimeoutRef","useRef","handleChange","useCallback","newValue","current","clearTimeout","setTimeout","displayModes","concat","StyledToggleButtonGroup","exclusive","_","v","map","mode","Tooltip","title","arrow","children","ToggleButton","sx","p","undefined","minWidth","styled","ToggleButtonGroup","flex","color","colors","common","white","backgroundColor","blue","borderColor"],"mappings":"0UAeA,IAAMA,EAAU,CAAEC,GAAI,QAASC,GAAI,UAE7BC,EAAY,CAChB,CAAEC,MAAOC,EAAoBC,KAAMC,KAAMC,EAACC,EAAa,CAAAC,SAAS,UAAYC,MAAO,aACnF,CAAEP,MAAOC,EAAoBO,KAAML,KAAMC,EAACK,EAAa,CAAAH,SAAS,UAAYC,MAAO,cAGxEG,EAAuC,SAACC,GACnD,IAAQX,EAA+EW,EAA/EX,MAAOY,EAAwED,EAAxEC,SAAQC,EAAgEF,EAA9DG,KAAAA,OAAO,IAAHD,EAAG,KAAIA,EAAEE,EAAiDJ,EAAjDI,UAASC,EAAwCL,EAAtCM,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAsBP,EAApBQ,QAAAA,OAAU,IAAHD,GAAQA,EAC5EE,EAAUxB,EAAQkB,IAAS,QAE3BO,EAAmBC,EAA8B,MACjDC,EAAeC,EACnB,SAACC,GACKJ,EAAiBK,SACnBC,aAAaN,EAAiBK,SAEhCL,EAAiBK,QAAUE,WAAW,WACnB,OAAbH,GAAqBA,IAAazB,IACpCY,SAAAA,EAAWa,GAEd,EAAE,IACL,EACA,CAACzB,EAAOY,IAGJiB,EAAeV,EAAU,GAAAW,OAAI/B,GAAWoB,UAAYpB,EAE1D,OACEK,EAAC2B,EAAuB,CAAChB,UAAWA,EAAWD,KAAMM,EAASpB,MAAOA,EAAOgC,WAAU,EAAApB,SAAU,SAACqB,EAAGC,GAAC,OAAKX,EAAaW,EAAE,EAAa,aAAA,qBACnIL,EAAaM,IAAI,SAACC,GAAI,OACrBhC,EAACiC,EAAO,CAAkBC,MAAOF,EAAK7B,MAAOgC,OAAK,EAAAC,SAChDpC,EAACqC,GACCzC,MAAOoC,EAAKpC,MACA,aAAAoC,EAAK7B,MACjBO,KAAMM,EACNsB,GAAI,CACFC,EAAG1B,EAAW,WAAQ2B,EACtBC,SAAU5B,EAAwB,UAAZG,EAAsB,GAAK,QAAMwB,GAGxDJ,SAAAvB,EAAWmB,EAAKjC,KAAOiC,EAAK7B,SAVnB6B,EAAKpC,MAapB,IAGP,EAIM+B,EAA0Be,EAAOC,EAAPD,CAA0B,CACxDE,KAAM,WACN,gCAAiC,CAC/B,iBAAkB,CAChBC,MAAOC,EAAOC,OAAOC,MACrBC,gBAAe,uBAAAvB,OAAyBoB,EAAOI,KAAK,KAAO,KAC3DC,YAAW,uBAAAzB,OAAyBoB,EAAOI,KAAK,KAAO,KACvD,oCAAqC,CACnCC,YAAW,uBAAAzB,OAAyBoB,EAAOI,KAAK,KAAI,MAEtD,UAAW,CACTD,gBAAe,uBAAAvB,OAAyBoB,EAAOI,KAAK,KAAI"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{objectSpread2 as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{QueryParam as r}from"../../utils/query-param.js";function i(e,i){if("undefined"!=typeof window)try{var o={mode:e===i?void 0:e};o.mode?r.replacePatch(o):r.replaceDeletes("mode")}catch(e){console.error("Error syncing view mode to URL:",e)}}function o(e){if("undefined"==typeof window)return e;try{var i=r.gets("mode");return i.mode?i.mode:e}catch(r){return console.error("Error getting view mode from URL:",r),e}}function a(e,i){var o,a;if("undefined"!=typeof window)try{if((o=e)===(a=i)||!o&&!a||o&&a&&o.page===a.page&&o.pageSize===a.pageSize)return void r.replaceDeletes("page","pageSize");if(!e)return void r.replaceDeletes("page","pageSize");var n={};void 0!==e.page&&e.page!==(null==i?void 0:i.page)&&(n.page=String(e.page)),void 0!==e.pageSize&&e.pageSize!==(null==i?void 0:i.pageSize)&&(n.pageSize=String(e.pageSize)),0===Object.keys(n).length?r.replaceDeletes("page","pageSize"):r.replacePatch(n)}catch(e){console.error("Error syncing pagination to URL:",e)}}function n(i){if("undefined"==typeof window)return i;try{var o=r.gets("page","pageSize"),a=o.page?parseInt(o.page,10):void 0,n=o.pageSize?parseInt(o.pageSize,10):void 0;return void 0===a&&void 0===n?i:e(e({},i),{},{page:void 0===a||isNaN(a)?null==i?void 0:i.page:a,pageSize:void 0===n||isNaN(n)?null==i?void 0:i.pageSize:n})}catch(e){return console.error("Error getting pagination from URL:",e),i}}export{n as getPaginationFromURL,o as getViewModeFromURL,a as setPaginationToURL,i as setViewModeToURL};
|
|
2
|
-
//# sourceMappingURL=helpers.js.map
|