@cerberus-design/data-grid 1.4.0 → 1.5.0-next-e13bf01
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/components/cerby-data-grid.client.d.cts +1 -1
- package/dist/components/cerby-data-grid.client.d.ts +1 -1
- package/dist/components/count-menu.client.d.cts +1 -1
- package/dist/components/count-menu.client.d.ts +1 -1
- package/dist/components/data-grid.client.d.cts +1 -1
- package/dist/components/data-grid.client.d.ts +1 -1
- package/dist/components/features.client.d.cts +1 -1
- package/dist/components/features.client.d.ts +1 -1
- package/dist/components/filter-item.client.d.cts +1 -1
- package/dist/components/filter-item.client.d.ts +1 -1
- package/dist/components/grid.client.d.cts +4 -4
- package/dist/components/grid.client.d.ts +4 -4
- package/dist/components/no-content.client.d.cts +1 -1
- package/dist/components/no-content.client.d.ts +1 -1
- package/dist/components/overlays.d.cts +2 -2
- package/dist/components/overlays.d.ts +2 -2
- package/dist/components/pagination.client.d.cts +1 -1
- package/dist/components/pagination.client.d.ts +1 -1
- package/dist/components/pinned-items.client.d.cts +1 -1
- package/dist/components/pinned-items.client.d.ts +1 -1
- package/dist/components/popover.client.d.cts +3 -3
- package/dist/components/popover.client.d.ts +3 -3
- package/dist/components/sort-items.client.d.cts +1 -1
- package/dist/components/sort-items.client.d.ts +1 -1
- package/dist/components/viewport.client.cjs +2 -1
- package/dist/components/viewport.client.d.cts +1 -1
- package/dist/components/viewport.client.d.ts +1 -1
- package/dist/components/viewport.client.js +2 -1
- package/dist/context.client.d.cts +1 -1
- package/dist/context.client.d.ts +1 -1
- package/dist/panda.buildinfo.json +1 -1
- package/dist/stores/layout.cjs +74 -60
- package/dist/stores/layout.d.cts +5 -2
- package/dist/stores/layout.d.ts +5 -2
- package/dist/stores/layout.js +74 -60
- package/dist/types.d.cts +13 -4
- package/dist/types.d.ts +13 -4
- package/package.json +9 -9
|
@@ -3,4 +3,4 @@ import { GridOptions } from '../types';
|
|
|
3
3
|
* A Data Grid wrapped in the CerberusProvider in order to provide the necessary
|
|
4
4
|
* context for the grid to function properly.
|
|
5
5
|
*/
|
|
6
|
-
export declare function CerberusDataGrid<TData>(props: GridOptions<TData>): import("react
|
|
6
|
+
export declare function CerberusDataGrid<TData>(props: GridOptions<TData>): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import { GridOptions } from '../types';
|
|
|
3
3
|
* A Data Grid wrapped in the CerberusProvider in order to provide the necessary
|
|
4
4
|
* context for the grid to function properly.
|
|
5
5
|
*/
|
|
6
|
-
export declare function CerberusDataGrid<TData>(props: GridOptions<TData>): import("react
|
|
6
|
+
export declare function CerberusDataGrid<TData>(props: GridOptions<TData>): import("react").JSX.Element;
|
|
@@ -2,5 +2,5 @@ import { SelectRootProps } from '@cerberus-design/react';
|
|
|
2
2
|
interface CountMenuProps {
|
|
3
3
|
onValueChange?: SelectRootProps['onValueChange'];
|
|
4
4
|
}
|
|
5
|
-
export declare function CountMenu(props: CountMenuProps): import("react
|
|
5
|
+
export declare function CountMenu(props: CountMenuProps): import("react").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -2,5 +2,5 @@ import { SelectRootProps } from '@cerberus-design/react';
|
|
|
2
2
|
interface CountMenuProps {
|
|
3
3
|
onValueChange?: SelectRootProps['onValueChange'];
|
|
4
4
|
}
|
|
5
|
-
export declare function CountMenu(props: CountMenuProps): import("react
|
|
5
|
+
export declare function CountMenu(props: CountMenuProps): import("react").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GridOptions } from '../types';
|
|
2
|
-
declare function DataGridEl<TData>(props: GridOptions<TData>): import("react
|
|
2
|
+
declare function DataGridEl<TData>(props: GridOptions<TData>): import("react").JSX.Element;
|
|
3
3
|
export declare const DataGrid: typeof DataGridEl;
|
|
4
4
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GridOptions } from '../types';
|
|
2
|
-
declare function DataGridEl<TData>(props: GridOptions<TData>): import("react
|
|
2
|
+
declare function DataGridEl<TData>(props: GridOptions<TData>): import("react").JSX.Element;
|
|
3
3
|
export declare const DataGrid: typeof DataGridEl;
|
|
4
4
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { InternalColumn } from '../types';
|
|
2
|
-
export declare function HeaderCellOptions<TData>(props: InternalColumn<TData>): import("react
|
|
2
|
+
export declare function HeaderCellOptions<TData>(props: InternalColumn<TData>): import("react").JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { InternalColumn } from '../types';
|
|
2
|
-
export declare function HeaderCellOptions<TData>(props: InternalColumn<TData>): import("react
|
|
2
|
+
export declare function HeaderCellOptions<TData>(props: InternalColumn<TData>): import("react").JSX.Element | null;
|
|
@@ -2,5 +2,5 @@ import { InternalColumn } from '../types';
|
|
|
2
2
|
interface FilterMenuItemProps<TData> {
|
|
3
3
|
colId: InternalColumn<TData>['id'];
|
|
4
4
|
}
|
|
5
|
-
export declare function FilterMenuItem<TData>(props: FilterMenuItemProps<TData>): import("react
|
|
5
|
+
export declare function FilterMenuItem<TData>(props: FilterMenuItemProps<TData>): import("react").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -2,5 +2,5 @@ import { InternalColumn } from '../types';
|
|
|
2
2
|
interface FilterMenuItemProps<TData> {
|
|
3
3
|
colId: InternalColumn<TData>['id'];
|
|
4
4
|
}
|
|
5
|
-
export declare function FilterMenuItem<TData>(props: FilterMenuItemProps<TData>): import("react
|
|
5
|
+
export declare function FilterMenuItem<TData>(props: FilterMenuItemProps<TData>): import("react").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -3,22 +3,22 @@ import { InternalColumn } from '../types';
|
|
|
3
3
|
interface GridHeaderCellProps<TData> {
|
|
4
4
|
column: InternalColumn<TData>;
|
|
5
5
|
}
|
|
6
|
-
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react
|
|
6
|
+
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react").JSX.Element)>;
|
|
7
7
|
interface GridCellProps<TData> {
|
|
8
8
|
row: any;
|
|
9
9
|
column: InternalColumn<TData>;
|
|
10
10
|
pending: boolean;
|
|
11
11
|
hasSkeleton: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react
|
|
13
|
+
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react").JSX.Element)>;
|
|
14
14
|
interface GridRowProps {
|
|
15
15
|
row: unknown;
|
|
16
16
|
index: number;
|
|
17
17
|
offsetY?: number;
|
|
18
18
|
}
|
|
19
|
-
export declare const GridRow: MemoExoticComponent<(props: GridRowProps) => import("react
|
|
19
|
+
export declare const GridRow: MemoExoticComponent<(props: GridRowProps) => import("react").JSX.Element>;
|
|
20
20
|
interface GridRowContainerProps {
|
|
21
21
|
offsetY?: number;
|
|
22
22
|
}
|
|
23
|
-
export declare function GridRowContainer(props: PropsWithChildren<GridRowContainerProps>): import("react
|
|
23
|
+
export declare function GridRowContainer(props: PropsWithChildren<GridRowContainerProps>): import("react").JSX.Element;
|
|
24
24
|
export {};
|
|
@@ -3,22 +3,22 @@ import { InternalColumn } from '../types';
|
|
|
3
3
|
interface GridHeaderCellProps<TData> {
|
|
4
4
|
column: InternalColumn<TData>;
|
|
5
5
|
}
|
|
6
|
-
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react
|
|
6
|
+
export declare const GridHeaderCell: MemoExoticComponent<(<TData>(props: GridHeaderCellProps<TData>) => import("react").JSX.Element)>;
|
|
7
7
|
interface GridCellProps<TData> {
|
|
8
8
|
row: any;
|
|
9
9
|
column: InternalColumn<TData>;
|
|
10
10
|
pending: boolean;
|
|
11
11
|
hasSkeleton: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react
|
|
13
|
+
export declare const GridCell: MemoExoticComponent<(<TData>(props: GridCellProps<TData>) => import("react").JSX.Element)>;
|
|
14
14
|
interface GridRowProps {
|
|
15
15
|
row: unknown;
|
|
16
16
|
index: number;
|
|
17
17
|
offsetY?: number;
|
|
18
18
|
}
|
|
19
|
-
export declare const GridRow: MemoExoticComponent<(props: GridRowProps) => import("react
|
|
19
|
+
export declare const GridRow: MemoExoticComponent<(props: GridRowProps) => import("react").JSX.Element>;
|
|
20
20
|
interface GridRowContainerProps {
|
|
21
21
|
offsetY?: number;
|
|
22
22
|
}
|
|
23
|
-
export declare function GridRowContainer(props: PropsWithChildren<GridRowContainerProps>): import("react
|
|
23
|
+
export declare function GridRowContainer(props: PropsWithChildren<GridRowContainerProps>): import("react").JSX.Element;
|
|
24
24
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function NoContent(): import("react
|
|
1
|
+
export declare function NoContent(): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function NoContent(): import("react
|
|
1
|
+
export declare function NoContent(): import("react").JSX.Element;
|
|
@@ -6,9 +6,9 @@ export declare const overlayStyle: {
|
|
|
6
6
|
interface NoContentOverlayProps {
|
|
7
7
|
custom?: OverlaySlots['noContent'];
|
|
8
8
|
}
|
|
9
|
-
export declare function NoContentOverlay(props: NoContentOverlayProps): import("react
|
|
9
|
+
export declare function NoContentOverlay(props: NoContentOverlayProps): import("react").JSX.Element;
|
|
10
10
|
interface PendingOverlayProps {
|
|
11
11
|
variant?: OverlaySlots['pending'];
|
|
12
12
|
}
|
|
13
|
-
export declare function PendingOverlay(props: PendingOverlayProps): import("react
|
|
13
|
+
export declare function PendingOverlay(props: PendingOverlayProps): import("react").JSX.Element | null;
|
|
14
14
|
export {};
|
|
@@ -6,9 +6,9 @@ export declare const overlayStyle: {
|
|
|
6
6
|
interface NoContentOverlayProps {
|
|
7
7
|
custom?: OverlaySlots['noContent'];
|
|
8
8
|
}
|
|
9
|
-
export declare function NoContentOverlay(props: NoContentOverlayProps): import("react
|
|
9
|
+
export declare function NoContentOverlay(props: NoContentOverlayProps): import("react").JSX.Element;
|
|
10
10
|
interface PendingOverlayProps {
|
|
11
11
|
variant?: OverlaySlots['pending'];
|
|
12
12
|
}
|
|
13
|
-
export declare function PendingOverlay(props: PendingOverlayProps): import("react
|
|
13
|
+
export declare function PendingOverlay(props: PendingOverlayProps): import("react").JSX.Element | null;
|
|
14
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function GridPagination(): import("react
|
|
1
|
+
export declare function GridPagination(): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function GridPagination(): import("react
|
|
1
|
+
export declare function GridPagination(): import("react").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PopoverRootProps } from '@cerberus-design/react';
|
|
2
2
|
import { HTMLAttributes, PropsWithChildren, RefObject } from 'react';
|
|
3
|
-
export declare function DGPopover(props: PropsWithChildren<PopoverRootProps>): import("react
|
|
4
|
-
export declare function DGPopoverAnchor(props: PropsWithChildren<HTMLAttributes<HTMLDivElement>>): import("react
|
|
3
|
+
export declare function DGPopover(props: PropsWithChildren<PopoverRootProps>): import("react").JSX.Element;
|
|
4
|
+
export declare function DGPopoverAnchor(props: PropsWithChildren<HTMLAttributes<HTMLDivElement>>): import("react").JSX.Element;
|
|
5
5
|
interface DGPopoverContentProps {
|
|
6
6
|
ref: RefObject<HTMLDivElement | null>;
|
|
7
7
|
}
|
|
8
|
-
export declare function DGPopoverContent(props: DGPopoverContentProps): import("react
|
|
8
|
+
export declare function DGPopoverContent(props: DGPopoverContentProps): import("react").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PopoverRootProps } from '@cerberus-design/react';
|
|
2
2
|
import { HTMLAttributes, PropsWithChildren, RefObject } from 'react';
|
|
3
|
-
export declare function DGPopover(props: PropsWithChildren<PopoverRootProps>): import("react
|
|
4
|
-
export declare function DGPopoverAnchor(props: PropsWithChildren<HTMLAttributes<HTMLDivElement>>): import("react
|
|
3
|
+
export declare function DGPopover(props: PropsWithChildren<PopoverRootProps>): import("react").JSX.Element;
|
|
4
|
+
export declare function DGPopoverAnchor(props: PropsWithChildren<HTMLAttributes<HTMLDivElement>>): import("react").JSX.Element;
|
|
5
5
|
interface DGPopoverContentProps {
|
|
6
6
|
ref: RefObject<HTMLDivElement | null>;
|
|
7
7
|
}
|
|
8
|
-
export declare function DGPopoverContent(props: DGPopoverContentProps): import("react
|
|
8
|
+
export declare function DGPopoverContent(props: DGPopoverContentProps): import("react").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -19,6 +19,7 @@ var GridViewport = (0, react.memo)(function GridViewport(props) {
|
|
|
19
19
|
const rowCount = (0, _cerberus_design_signals.useRead)(store.rowCount);
|
|
20
20
|
const staticRows = (0, _cerberus_design_signals.useRead)(store.rows);
|
|
21
21
|
const pending = (0, _cerberus_design_signals.useRead)(store.pending);
|
|
22
|
+
const pendingVariant = (0, _cerberus_design_signals.useRead)(store.pendingVariant);
|
|
22
23
|
const shouldLock = (0, _cerberus_design_signals.createComputed)(() => rowCount <= 0);
|
|
23
24
|
const hasNonSkeleton = (0, react.useMemo)(() => {
|
|
24
25
|
const overlays = props.overlays;
|
|
@@ -70,7 +71,7 @@ var GridViewport = (0, react.memo)(function GridViewport(props) {
|
|
|
70
71
|
}),
|
|
71
72
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_cerberus_design_react.Show, {
|
|
72
73
|
when: pending,
|
|
73
|
-
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_overlays.PendingOverlay, { variant:
|
|
74
|
+
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_overlays.PendingOverlay, { variant: pendingVariant })
|
|
74
75
|
}),
|
|
75
76
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_popover_client.DGPopoverContent, { ref: props.rootRef })
|
|
76
77
|
]
|
|
@@ -4,5 +4,5 @@ interface GridViewportProps {
|
|
|
4
4
|
rootRef: RefObject<HTMLDivElement | null>;
|
|
5
5
|
overlays?: OverlaySlots;
|
|
6
6
|
}
|
|
7
|
-
export declare const GridViewport: MemoExoticComponent<(props: GridViewportProps) => import("react
|
|
7
|
+
export declare const GridViewport: MemoExoticComponent<(props: GridViewportProps) => import("react").JSX.Element>;
|
|
8
8
|
export {};
|
|
@@ -4,5 +4,5 @@ interface GridViewportProps {
|
|
|
4
4
|
rootRef: RefObject<HTMLDivElement | null>;
|
|
5
5
|
overlays?: OverlaySlots;
|
|
6
6
|
}
|
|
7
|
-
export declare const GridViewport: MemoExoticComponent<(props: GridViewportProps) => import("react
|
|
7
|
+
export declare const GridViewport: MemoExoticComponent<(props: GridViewportProps) => import("react").JSX.Element>;
|
|
8
8
|
export {};
|
|
@@ -19,6 +19,7 @@ var GridViewport = memo(function GridViewport(props) {
|
|
|
19
19
|
const rowCount = useRead(store.rowCount);
|
|
20
20
|
const staticRows = useRead(store.rows);
|
|
21
21
|
const pending = useRead(store.pending);
|
|
22
|
+
const pendingVariant = useRead(store.pendingVariant);
|
|
22
23
|
const shouldLock = createComputed(() => rowCount <= 0);
|
|
23
24
|
const hasNonSkeleton = useMemo(() => {
|
|
24
25
|
const overlays = props.overlays;
|
|
@@ -70,7 +71,7 @@ var GridViewport = memo(function GridViewport(props) {
|
|
|
70
71
|
}),
|
|
71
72
|
/* @__PURE__ */ jsx(Show, {
|
|
72
73
|
when: pending,
|
|
73
|
-
children: () => /* @__PURE__ */ jsx(PendingOverlay, { variant:
|
|
74
|
+
children: () => /* @__PURE__ */ jsx(PendingOverlay, { variant: pendingVariant })
|
|
74
75
|
}),
|
|
75
76
|
/* @__PURE__ */ jsx(DGPopoverContent, { ref: props.rootRef })
|
|
76
77
|
]
|
|
@@ -2,5 +2,5 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { GridStore } from './types';
|
|
3
3
|
export declare function DataGridProvider<TData>(props: PropsWithChildren<{
|
|
4
4
|
createStore: () => GridStore<TData>;
|
|
5
|
-
}>): import("react
|
|
5
|
+
}>): import("react").JSX.Element;
|
|
6
6
|
export declare function useDataGridContext<TData>(): GridStore<TData>;
|
package/dist/context.client.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { GridStore } from './types';
|
|
3
3
|
export declare function DataGridProvider<TData>(props: PropsWithChildren<{
|
|
4
4
|
createStore: () => GridStore<TData>;
|
|
5
|
-
}>): import("react
|
|
5
|
+
}>): import("react").JSX.Element;
|
|
6
6
|
export declare function useDataGridContext<TData>(): GridStore<TData>;
|
package/dist/stores/layout.cjs
CHANGED
|
@@ -4,71 +4,82 @@ let _cerberus_design_signals = require("@cerberus-design/signals");
|
|
|
4
4
|
//#region src/stores/layout.ts
|
|
5
5
|
function createLayoutStore(options) {
|
|
6
6
|
const [containerWidth, setContainerWidth] = (0, _cerberus_design_signals.createSignal)(0);
|
|
7
|
+
const [phase, setPhase] = (0, _cerberus_design_signals.createSignal)("initialPending");
|
|
7
8
|
const [pending, setPending] = (0, _cerberus_design_signals.createSignal)(options.pending ?? false);
|
|
8
9
|
const [hasSkeleton] = (0, _cerberus_design_signals.createSignal)(options.overlays?.pending === "skeleton");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (col.pinned() === "left") {
|
|
41
|
-
vars[`--col-${col.id}-left`] = `${leftOffset}px`;
|
|
42
|
-
leftOffset += finalWidth;
|
|
43
|
-
}
|
|
10
|
+
const rootCssVars = (0, _cerberus_design_signals.createComputed)(() => {
|
|
11
|
+
const vars = {};
|
|
12
|
+
const visibleCols = [];
|
|
13
|
+
const cols = options.columns();
|
|
14
|
+
const cWidth = containerWidth();
|
|
15
|
+
let fixedSpace = 0;
|
|
16
|
+
let flexCount = 0;
|
|
17
|
+
for (let i = 0; i < cols.length; i++) {
|
|
18
|
+
const col = cols[i];
|
|
19
|
+
if (!col.isVisible()) continue;
|
|
20
|
+
visibleCols.push(col);
|
|
21
|
+
if (col.isFlex()) flexCount++;
|
|
22
|
+
else fixedSpace += col.width();
|
|
23
|
+
const order = options.orderedColumns().findIndex((orderedCol) => orderedCol.id === col.id);
|
|
24
|
+
vars[`--col-${col.id}-order`] = `${order}`;
|
|
25
|
+
}
|
|
26
|
+
const remainingSpace = Math.max(0, cWidth - fixedSpace);
|
|
27
|
+
const flexWidth = flexCount > 0 ? remainingSpace / flexCount : 0;
|
|
28
|
+
let leftOffset = 0;
|
|
29
|
+
let totalW = 0;
|
|
30
|
+
const computedWidths = new Float64Array(visibleCols.length);
|
|
31
|
+
for (let i = 0; i < visibleCols.length; i++) {
|
|
32
|
+
const col = visibleCols[i];
|
|
33
|
+
let finalWidth = col.width();
|
|
34
|
+
if (col.isFlex()) finalWidth = Math.max(col.original.minWidth ?? 150, flexWidth);
|
|
35
|
+
computedWidths[i] = finalWidth;
|
|
36
|
+
totalW += finalWidth;
|
|
37
|
+
vars[`--col-${col.id}-width`] = `${finalWidth}px`;
|
|
38
|
+
if (col.pinned() === "left") {
|
|
39
|
+
vars[`--col-${col.id}-left`] = `${leftOffset}px`;
|
|
40
|
+
leftOffset += finalWidth;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
}
|
|
43
|
+
let rightOffset = 0;
|
|
44
|
+
for (let i = visibleCols.length - 1; i >= 0; i--) {
|
|
45
|
+
const col = visibleCols[i];
|
|
46
|
+
if (col.pinned() === "right") {
|
|
47
|
+
vars[`--col-${col.id}-right`] = `${rightOffset}px`;
|
|
48
|
+
rightOffset += computedWidths[i];
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
}
|
|
51
|
+
vars["--total-grid-width"] = `${totalW}px`;
|
|
52
|
+
vars["--row-height"] = `${options.rowSize()}px`;
|
|
53
|
+
const theme = {
|
|
54
|
+
...require_const.DEFAULT_THEME,
|
|
55
|
+
...options.theme
|
|
56
|
+
};
|
|
57
|
+
vars["--border"] = theme.border;
|
|
58
|
+
vars["--border-color"] = theme.borderColor;
|
|
59
|
+
vars["--rounded"] = theme.rounded;
|
|
60
|
+
vars["--row-bg-color"] = theme.rowBgColor;
|
|
61
|
+
vars["--row-even-bg-color"] = theme.rowEvenBgColor;
|
|
62
|
+
vars["--row-hover-bg-color"] = theme.rowHoverBgColor;
|
|
63
|
+
vars["--head-cell-bg-color"] = theme.headCellBgColor;
|
|
64
|
+
vars["--head-cell-border-bottom-color"] = theme.headCellBorderBottomColor;
|
|
65
|
+
vars["--grid-cell-border-color"] = theme.gridCellBorderColor;
|
|
66
|
+
vars["--grid-cell-pinned-border-color"] = theme.gridCellPinnedBorderColor;
|
|
67
|
+
return vars;
|
|
68
|
+
});
|
|
69
|
+
const totalWidth = (0, _cerberus_design_signals.createComputed)(() => options.columns().reduce((acc, c) => acc + c.width(), 0));
|
|
70
|
+
return {
|
|
71
|
+
phase,
|
|
72
|
+
pending,
|
|
73
|
+
pendingVariant: (0, _cerberus_design_signals.createComputed)(() => {
|
|
74
|
+
const isPending = pending();
|
|
75
|
+
const currentPhase = phase();
|
|
76
|
+
if (!isPending) return void 0;
|
|
77
|
+
if (currentPhase === "initialPending" && options.overlays?.initial) return options.overlays.initial;
|
|
78
|
+
return options.overlays?.pending;
|
|
70
79
|
}),
|
|
71
|
-
|
|
80
|
+
hasSkeleton,
|
|
81
|
+
rootCssVars,
|
|
82
|
+
totalWidth,
|
|
72
83
|
resizeColumn: (colId, delta) => {
|
|
73
84
|
const columns = options.columns();
|
|
74
85
|
const col = columns.find((c) => c.id === colId);
|
|
@@ -90,6 +101,9 @@ function createLayoutStore(options) {
|
|
|
90
101
|
},
|
|
91
102
|
updatePending: (newState) => {
|
|
92
103
|
setPending(newState);
|
|
104
|
+
const currentPhase = phase();
|
|
105
|
+
if (newState && currentPhase === "initial") setPhase("initialPending");
|
|
106
|
+
else if (!newState && (currentPhase === "initialPending" || currentPhase === "initial")) setPhase("mounted");
|
|
93
107
|
}
|
|
94
108
|
};
|
|
95
109
|
}
|
package/dist/stores/layout.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Accessor, Setter } from '@cerberus-design/signals';
|
|
2
|
-
import { GridOptions, PinnedState } from '../types';
|
|
2
|
+
import { GridOptions, LoadingVariant, PinnedState } from '../types';
|
|
3
3
|
import { DataStore } from './data';
|
|
4
|
-
type LayoutStore = {
|
|
4
|
+
export type LayoutStore = {
|
|
5
|
+
phase: Accessor<Phase>;
|
|
5
6
|
pending: Accessor<boolean>;
|
|
7
|
+
pendingVariant: Accessor<LoadingVariant>;
|
|
6
8
|
hasSkeleton: Accessor<boolean>;
|
|
7
9
|
rootCssVars: Accessor<Record<string, string>>;
|
|
8
10
|
totalWidth: Accessor<number>;
|
|
@@ -11,6 +13,7 @@ type LayoutStore = {
|
|
|
11
13
|
togglePinned: (colId: string, state: PinnedState) => void;
|
|
12
14
|
updatePending: (newState: boolean) => void;
|
|
13
15
|
};
|
|
16
|
+
type Phase = 'initial' | 'initialPending' | 'mounted';
|
|
14
17
|
type LayoutGridOptions<T> = Omit<GridOptions<T>, 'columns' | 'rowSize'>;
|
|
15
18
|
type Options<T> = {
|
|
16
19
|
columns: DataStore<T>['columns'];
|
package/dist/stores/layout.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Accessor, Setter } from '@cerberus-design/signals';
|
|
2
|
-
import { GridOptions, PinnedState } from '../types';
|
|
2
|
+
import { GridOptions, LoadingVariant, PinnedState } from '../types';
|
|
3
3
|
import { DataStore } from './data';
|
|
4
|
-
type LayoutStore = {
|
|
4
|
+
export type LayoutStore = {
|
|
5
|
+
phase: Accessor<Phase>;
|
|
5
6
|
pending: Accessor<boolean>;
|
|
7
|
+
pendingVariant: Accessor<LoadingVariant>;
|
|
6
8
|
hasSkeleton: Accessor<boolean>;
|
|
7
9
|
rootCssVars: Accessor<Record<string, string>>;
|
|
8
10
|
totalWidth: Accessor<number>;
|
|
@@ -11,6 +13,7 @@ type LayoutStore = {
|
|
|
11
13
|
togglePinned: (colId: string, state: PinnedState) => void;
|
|
12
14
|
updatePending: (newState: boolean) => void;
|
|
13
15
|
};
|
|
16
|
+
type Phase = 'initial' | 'initialPending' | 'mounted';
|
|
14
17
|
type LayoutGridOptions<T> = Omit<GridOptions<T>, 'columns' | 'rowSize'>;
|
|
15
18
|
type Options<T> = {
|
|
16
19
|
columns: DataStore<T>['columns'];
|
package/dist/stores/layout.js
CHANGED
|
@@ -4,71 +4,82 @@ import { createComputed, createSignal } from "@cerberus-design/signals";
|
|
|
4
4
|
//#region src/stores/layout.ts
|
|
5
5
|
function createLayoutStore(options) {
|
|
6
6
|
const [containerWidth, setContainerWidth] = createSignal(0);
|
|
7
|
+
const [phase, setPhase] = createSignal("initialPending");
|
|
7
8
|
const [pending, setPending] = createSignal(options.pending ?? false);
|
|
8
9
|
const [hasSkeleton] = createSignal(options.overlays?.pending === "skeleton");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (col.pinned() === "left") {
|
|
41
|
-
vars[`--col-${col.id}-left`] = `${leftOffset}px`;
|
|
42
|
-
leftOffset += finalWidth;
|
|
43
|
-
}
|
|
10
|
+
const rootCssVars = createComputed(() => {
|
|
11
|
+
const vars = {};
|
|
12
|
+
const visibleCols = [];
|
|
13
|
+
const cols = options.columns();
|
|
14
|
+
const cWidth = containerWidth();
|
|
15
|
+
let fixedSpace = 0;
|
|
16
|
+
let flexCount = 0;
|
|
17
|
+
for (let i = 0; i < cols.length; i++) {
|
|
18
|
+
const col = cols[i];
|
|
19
|
+
if (!col.isVisible()) continue;
|
|
20
|
+
visibleCols.push(col);
|
|
21
|
+
if (col.isFlex()) flexCount++;
|
|
22
|
+
else fixedSpace += col.width();
|
|
23
|
+
const order = options.orderedColumns().findIndex((orderedCol) => orderedCol.id === col.id);
|
|
24
|
+
vars[`--col-${col.id}-order`] = `${order}`;
|
|
25
|
+
}
|
|
26
|
+
const remainingSpace = Math.max(0, cWidth - fixedSpace);
|
|
27
|
+
const flexWidth = flexCount > 0 ? remainingSpace / flexCount : 0;
|
|
28
|
+
let leftOffset = 0;
|
|
29
|
+
let totalW = 0;
|
|
30
|
+
const computedWidths = new Float64Array(visibleCols.length);
|
|
31
|
+
for (let i = 0; i < visibleCols.length; i++) {
|
|
32
|
+
const col = visibleCols[i];
|
|
33
|
+
let finalWidth = col.width();
|
|
34
|
+
if (col.isFlex()) finalWidth = Math.max(col.original.minWidth ?? 150, flexWidth);
|
|
35
|
+
computedWidths[i] = finalWidth;
|
|
36
|
+
totalW += finalWidth;
|
|
37
|
+
vars[`--col-${col.id}-width`] = `${finalWidth}px`;
|
|
38
|
+
if (col.pinned() === "left") {
|
|
39
|
+
vars[`--col-${col.id}-left`] = `${leftOffset}px`;
|
|
40
|
+
leftOffset += finalWidth;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
}
|
|
43
|
+
let rightOffset = 0;
|
|
44
|
+
for (let i = visibleCols.length - 1; i >= 0; i--) {
|
|
45
|
+
const col = visibleCols[i];
|
|
46
|
+
if (col.pinned() === "right") {
|
|
47
|
+
vars[`--col-${col.id}-right`] = `${rightOffset}px`;
|
|
48
|
+
rightOffset += computedWidths[i];
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
}
|
|
51
|
+
vars["--total-grid-width"] = `${totalW}px`;
|
|
52
|
+
vars["--row-height"] = `${options.rowSize()}px`;
|
|
53
|
+
const theme = {
|
|
54
|
+
...DEFAULT_THEME,
|
|
55
|
+
...options.theme
|
|
56
|
+
};
|
|
57
|
+
vars["--border"] = theme.border;
|
|
58
|
+
vars["--border-color"] = theme.borderColor;
|
|
59
|
+
vars["--rounded"] = theme.rounded;
|
|
60
|
+
vars["--row-bg-color"] = theme.rowBgColor;
|
|
61
|
+
vars["--row-even-bg-color"] = theme.rowEvenBgColor;
|
|
62
|
+
vars["--row-hover-bg-color"] = theme.rowHoverBgColor;
|
|
63
|
+
vars["--head-cell-bg-color"] = theme.headCellBgColor;
|
|
64
|
+
vars["--head-cell-border-bottom-color"] = theme.headCellBorderBottomColor;
|
|
65
|
+
vars["--grid-cell-border-color"] = theme.gridCellBorderColor;
|
|
66
|
+
vars["--grid-cell-pinned-border-color"] = theme.gridCellPinnedBorderColor;
|
|
67
|
+
return vars;
|
|
68
|
+
});
|
|
69
|
+
const totalWidth = createComputed(() => options.columns().reduce((acc, c) => acc + c.width(), 0));
|
|
70
|
+
return {
|
|
71
|
+
phase,
|
|
72
|
+
pending,
|
|
73
|
+
pendingVariant: createComputed(() => {
|
|
74
|
+
const isPending = pending();
|
|
75
|
+
const currentPhase = phase();
|
|
76
|
+
if (!isPending) return void 0;
|
|
77
|
+
if (currentPhase === "initialPending" && options.overlays?.initial) return options.overlays.initial;
|
|
78
|
+
return options.overlays?.pending;
|
|
70
79
|
}),
|
|
71
|
-
|
|
80
|
+
hasSkeleton,
|
|
81
|
+
rootCssVars,
|
|
82
|
+
totalWidth,
|
|
72
83
|
resizeColumn: (colId, delta) => {
|
|
73
84
|
const columns = options.columns();
|
|
74
85
|
const col = columns.find((c) => c.id === colId);
|
|
@@ -90,6 +101,9 @@ function createLayoutStore(options) {
|
|
|
90
101
|
},
|
|
91
102
|
updatePending: (newState) => {
|
|
92
103
|
setPending(newState);
|
|
104
|
+
const currentPhase = phase();
|
|
105
|
+
if (newState && currentPhase === "initial") setPhase("initialPending");
|
|
106
|
+
else if (!newState && (currentPhase === "initialPending" || currentPhase === "initial")) setPhase("mounted");
|
|
93
107
|
}
|
|
94
108
|
};
|
|
95
109
|
}
|
package/dist/types.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import { PageDetails, EnforceNoProperties, PaginationRootProps } from '@cerberus
|
|
|
2
2
|
import { Setter, Accessor } from '@cerberus-design/signals';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { RowSize } from './const';
|
|
5
|
+
import { LayoutStore } from './stores';
|
|
5
6
|
export interface GridOptions<TData> {
|
|
6
7
|
/**
|
|
7
8
|
* The full Array of data you want the grid to render.
|
|
@@ -145,7 +146,7 @@ export type SortState = {
|
|
|
145
146
|
id: string;
|
|
146
147
|
desc: boolean;
|
|
147
148
|
};
|
|
148
|
-
export interface GridStore<TData> {
|
|
149
|
+
export interface GridStore<TData> extends LayoutStore {
|
|
149
150
|
columns: Accessor<InternalColumn<TData>[]>;
|
|
150
151
|
rows: Accessor<TData[]>;
|
|
151
152
|
pending: Accessor<boolean>;
|
|
@@ -169,7 +170,6 @@ export interface GridStore<TData> {
|
|
|
169
170
|
rowSize: Accessor<number>;
|
|
170
171
|
totalWidth: Accessor<number>;
|
|
171
172
|
resizeColumn: (colId: string, delta: number) => void;
|
|
172
|
-
setContainerWidth: (val: number) => void;
|
|
173
173
|
setPage: (details: PageDetails) => void;
|
|
174
174
|
setPageSize: (size: number) => void;
|
|
175
175
|
setGlobalFilter: (val: BaseFilterState) => void;
|
|
@@ -241,10 +241,19 @@ export type OverlaySlots = {
|
|
|
241
241
|
*/
|
|
242
242
|
noContent?: ReactNode;
|
|
243
243
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
244
|
+
* When provided (and the DataGrid has finished the initial pending phase), the
|
|
245
|
+
* `pending` overlay will be displayed within the Grid Viewport any time
|
|
246
|
+
* the `DataGrid.pending` prop is set to `true`.
|
|
246
247
|
*/
|
|
247
248
|
pending?: LoadingVariant;
|
|
249
|
+
/**
|
|
250
|
+
* When provided, the `initial` overlay will be displayed within the Grid Viewport
|
|
251
|
+
* when the DataGrid has not yet finished the initial pending phase. This is triggered
|
|
252
|
+
* by the `DataGrid.pending` prop being set to `true` for the first time on the initial load.
|
|
253
|
+
*
|
|
254
|
+
* Once the `DataGrid.pending` prop is set to `false`, the `overlays.pending` slot will be used.
|
|
255
|
+
*/
|
|
256
|
+
initial?: LoadingVariant;
|
|
248
257
|
};
|
|
249
258
|
export type ThemeOptions = {
|
|
250
259
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PageDetails, EnforceNoProperties, PaginationRootProps } from '@cerberus
|
|
|
2
2
|
import { Setter, Accessor } from '@cerberus-design/signals';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { RowSize } from './const';
|
|
5
|
+
import { LayoutStore } from './stores';
|
|
5
6
|
export interface GridOptions<TData> {
|
|
6
7
|
/**
|
|
7
8
|
* The full Array of data you want the grid to render.
|
|
@@ -145,7 +146,7 @@ export type SortState = {
|
|
|
145
146
|
id: string;
|
|
146
147
|
desc: boolean;
|
|
147
148
|
};
|
|
148
|
-
export interface GridStore<TData> {
|
|
149
|
+
export interface GridStore<TData> extends LayoutStore {
|
|
149
150
|
columns: Accessor<InternalColumn<TData>[]>;
|
|
150
151
|
rows: Accessor<TData[]>;
|
|
151
152
|
pending: Accessor<boolean>;
|
|
@@ -169,7 +170,6 @@ export interface GridStore<TData> {
|
|
|
169
170
|
rowSize: Accessor<number>;
|
|
170
171
|
totalWidth: Accessor<number>;
|
|
171
172
|
resizeColumn: (colId: string, delta: number) => void;
|
|
172
|
-
setContainerWidth: (val: number) => void;
|
|
173
173
|
setPage: (details: PageDetails) => void;
|
|
174
174
|
setPageSize: (size: number) => void;
|
|
175
175
|
setGlobalFilter: (val: BaseFilterState) => void;
|
|
@@ -241,10 +241,19 @@ export type OverlaySlots = {
|
|
|
241
241
|
*/
|
|
242
242
|
noContent?: ReactNode;
|
|
243
243
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
244
|
+
* When provided (and the DataGrid has finished the initial pending phase), the
|
|
245
|
+
* `pending` overlay will be displayed within the Grid Viewport any time
|
|
246
|
+
* the `DataGrid.pending` prop is set to `true`.
|
|
246
247
|
*/
|
|
247
248
|
pending?: LoadingVariant;
|
|
249
|
+
/**
|
|
250
|
+
* When provided, the `initial` overlay will be displayed within the Grid Viewport
|
|
251
|
+
* when the DataGrid has not yet finished the initial pending phase. This is triggered
|
|
252
|
+
* by the `DataGrid.pending` prop being set to `true` for the first time on the initial load.
|
|
253
|
+
*
|
|
254
|
+
* Once the `DataGrid.pending` prop is set to `false`, the `overlays.pending` slot will be used.
|
|
255
|
+
*/
|
|
256
|
+
initial?: LoadingVariant;
|
|
248
257
|
};
|
|
249
258
|
export type ThemeOptions = {
|
|
250
259
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/data-grid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-next-e13bf01",
|
|
4
4
|
"description": "The Cerberus Design React DataGrid component.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data grid",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cerberus-design/react": "1.
|
|
31
|
-
"@cerberus-design/signals": "1.
|
|
30
|
+
"@cerberus-design/react": "1.5.0-next-e13bf01",
|
|
31
|
+
"@cerberus-design/signals": "1.5.0-next-e13bf01"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@pandacss/dev": "^1.11.
|
|
35
|
-
"@types/react": "^19.2.
|
|
34
|
+
"@pandacss/dev": "^1.11.2",
|
|
35
|
+
"@types/react": "^19.2.16",
|
|
36
36
|
"@types/react-dom": "^19.2.3",
|
|
37
|
-
"@vitejs/plugin-react": "^6.0.
|
|
37
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
38
38
|
"globby": "^16.2.0",
|
|
39
|
-
"react": "^19.2.
|
|
40
|
-
"react-dom": "^19.2.
|
|
39
|
+
"react": "^19.2.7",
|
|
40
|
+
"react-dom": "^19.2.7",
|
|
41
41
|
"vite": "^8.0.14",
|
|
42
42
|
"vite-plugin-dts": "^5.0.1",
|
|
43
|
-
"@cerberus/panda-preset": "1.
|
|
43
|
+
"@cerberus/panda-preset": "1.5.0-next-e13bf01",
|
|
44
44
|
"styled-system": "0.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|