@versini/ui-datagrid 1.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/131.js +3 -4
- package/dist/298.js +1 -1
- package/dist/46.js +1 -1
- package/dist/511.js +1 -1
- package/dist/926.js +1 -1
- package/dist/DataGrid/DataGridTypes.d.ts +18 -1
- package/dist/DataGrid/index.js +1 -1
- package/dist/DataGridAnimated/index.js +1 -1
- package/dist/DataGridBody/DataGridBody.d.ts +1 -1
- package/dist/DataGridBody/getBodyClass.d.ts +0 -1
- package/dist/DataGridBody/index.js +17 -4
- package/dist/DataGridBody/useColumnMeasurement.d.ts +1 -1
- package/dist/DataGridCell/index.js +1 -1
- package/dist/DataGridCellSort/index.js +1 -1
- package/dist/DataGridConstants/index.js +1 -1
- package/dist/DataGridFooter/index.js +1 -1
- package/dist/DataGridHeader/index.js +1 -1
- package/dist/DataGridInfinite/DataGridInfiniteBody.d.ts +28 -2
- package/dist/DataGridInfinite/index.js +17 -4
- package/dist/DataGridRow/index.js +1 -1
- package/dist/DataGridSorting/index.js +1 -1
- package/package.json +2 -2
package/dist/131.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v1.0
|
|
2
|
+
@versini/ui-datagrid v1.2.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -13,7 +13,6 @@ import { useRef, useContext, useLayoutEffect } from "./511.js";
|
|
|
13
13
|
* are provided, or define their own grid otherwise.
|
|
14
14
|
*
|
|
15
15
|
* @param className - Additional class name to merge
|
|
16
|
-
*
|
|
17
16
|
*/ function getBodyClass(className) {
|
|
18
17
|
return clsx("contents", className);
|
|
19
18
|
}
|
|
@@ -54,14 +53,14 @@ import { useRef, useContext, useLayoutEffect } from "./511.js";
|
|
|
54
53
|
* @param bodyRef - Ref to the body element containing the rows
|
|
55
54
|
* @param contentDependency - Dependency that changes when content changes (children or renderedContent)
|
|
56
55
|
*
|
|
57
|
-
*/ function useColumnMeasurement(bodyRef, contentDependency) {
|
|
56
|
+
*/ function useColumnMeasurement(bodyRef, contentDependency, noData = false) {
|
|
58
57
|
const ctx = useContext(DataGridContext);
|
|
59
58
|
const prevWidthsRef = useRef([]);
|
|
60
59
|
// biome-ignore lint/correctness/useExhaustiveDependencies: contentDependency triggers remeasurement when rows change
|
|
61
60
|
useLayoutEffect(()=>{
|
|
62
61
|
const element = bodyRef.current;
|
|
63
62
|
const needsMeasurement = ctx.columns && (ctx.stickyHeader || ctx.stickyFooter);
|
|
64
|
-
if (!element || !needsMeasurement || !ctx.setMeasuredColumnWidths) {
|
|
63
|
+
if (noData || !element || !needsMeasurement || !ctx.setMeasuredColumnWidths) {
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
67
66
|
const firstRow = element.querySelector('[role="row"]');
|
package/dist/298.js
CHANGED
package/dist/46.js
CHANGED
package/dist/511.js
CHANGED
package/dist/926.js
CHANGED
|
@@ -99,11 +99,28 @@ export type DataGridHeaderProps = {
|
|
|
99
99
|
*/
|
|
100
100
|
className?: string;
|
|
101
101
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
102
|
-
export type DataGridBodyProps = {
|
|
102
|
+
export type DataGridBodyProps = ({
|
|
103
|
+
/**
|
|
104
|
+
* If true, applies styles for an empty state (e.g. removing extra row borders).
|
|
105
|
+
* Used when there are no rows to display.
|
|
106
|
+
*/
|
|
107
|
+
noData: true;
|
|
108
|
+
/**
|
|
109
|
+
* The content of the body (DataGridRow elements).
|
|
110
|
+
*/
|
|
111
|
+
children?: React.ReactNode;
|
|
112
|
+
} | {
|
|
113
|
+
/**
|
|
114
|
+
* If true, applies styles for an empty state (e.g. removing extra row borders).
|
|
115
|
+
* Used when there are no rows to display.
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
noData?: false;
|
|
103
119
|
/**
|
|
104
120
|
* The content of the body (DataGridRow elements).
|
|
105
121
|
*/
|
|
106
122
|
children: React.ReactNode;
|
|
123
|
+
}) & {
|
|
107
124
|
/**
|
|
108
125
|
* CSS class to apply to the body.
|
|
109
126
|
*/
|
package/dist/DataGrid/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DataGridBodyProps } from "../DataGrid/DataGridTypes";
|
|
2
|
-
export declare const DataGridBody: ({ className, children, ...rest }: DataGridBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DataGridBody: ({ className, children, noData, ...rest }: DataGridBodyProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v1.0
|
|
2
|
+
@versini/ui-datagrid v1.2.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -16,11 +16,11 @@ import { CellWrapper } from "../46.js";
|
|
|
16
16
|
|
|
17
17
|
/* =============================================================================
|
|
18
18
|
* DataGridBody
|
|
19
|
-
* ========================================================================== */ const DataGridBody = ({ className, children, ...rest })=>{
|
|
19
|
+
* ========================================================================== */ const DataGridBody = ({ className, children, noData = false, ...rest })=>{
|
|
20
20
|
const ctx = useContext(DataGridContext);
|
|
21
21
|
const bodyRef = useRef(null);
|
|
22
22
|
// Measure column widths for sticky header/footer sync.
|
|
23
|
-
useColumnMeasurement(bodyRef, children);
|
|
23
|
+
useColumnMeasurement(bodyRef, children, noData);
|
|
24
24
|
const bodyClass = getBodyClass(className);
|
|
25
25
|
return /*#__PURE__*/ jsx(DataGridContext.Provider, {
|
|
26
26
|
value: {
|
|
@@ -32,7 +32,20 @@ import { CellWrapper } from "../46.js";
|
|
|
32
32
|
role: "rowgroup",
|
|
33
33
|
className: bodyClass,
|
|
34
34
|
...rest,
|
|
35
|
-
children:
|
|
35
|
+
children: noData ? /*#__PURE__*/ jsx("div", {
|
|
36
|
+
role: "row",
|
|
37
|
+
style: {
|
|
38
|
+
gridColumn: "1 / -1"
|
|
39
|
+
},
|
|
40
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
41
|
+
role: "gridcell",
|
|
42
|
+
style: {
|
|
43
|
+
textAlign: "center",
|
|
44
|
+
width: "100%"
|
|
45
|
+
},
|
|
46
|
+
children: children ?? "No Data"
|
|
47
|
+
})
|
|
48
|
+
}) : children
|
|
36
49
|
})
|
|
37
50
|
});
|
|
38
51
|
};
|
|
@@ -23,4 +23,4 @@ export declare function quantizeWidthToDevicePixels(width: number, devicePixelRa
|
|
|
23
23
|
* @param contentDependency - Dependency that changes when content changes (children or renderedContent)
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
export declare function useColumnMeasurement(bodyRef: React.RefObject<HTMLDivElement | null>, contentDependency: unknown): void;
|
|
26
|
+
export declare function useColumnMeasurement(bodyRef: React.RefObject<HTMLDivElement | null>, contentDependency: unknown, noData?: boolean): void;
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
export type DataGridInfiniteBodyProps<T> = {
|
|
1
|
+
export type DataGridInfiniteBodyProps<T> = ({
|
|
2
|
+
/**
|
|
3
|
+
* If true, displays an empty state instead of infinite scroll content.
|
|
4
|
+
* When noData is true, data, children, and scroll-related props are optional.
|
|
5
|
+
*/
|
|
6
|
+
noData: true;
|
|
7
|
+
/**
|
|
8
|
+
* The full dataset to render progressively.
|
|
9
|
+
*/
|
|
10
|
+
data?: T[];
|
|
11
|
+
/**
|
|
12
|
+
* Render function for each row. Should return a DataGridRow element. The
|
|
13
|
+
* consumer is responsible for providing the key prop on the returned element.
|
|
14
|
+
*/
|
|
15
|
+
children?: (item: T, index: number) => React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Custom content to display in the empty state. Defaults to "No Data".
|
|
18
|
+
*/
|
|
19
|
+
noDataContent?: React.ReactNode;
|
|
20
|
+
} | {
|
|
21
|
+
/**
|
|
22
|
+
* If true, displays an empty state instead of infinite scroll content.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
noData?: false;
|
|
2
26
|
/**
|
|
3
27
|
* The full dataset to render progressively.
|
|
4
28
|
*/
|
|
@@ -8,6 +32,8 @@ export type DataGridInfiniteBodyProps<T> = {
|
|
|
8
32
|
* consumer is responsible for providing the key prop on the returned element.
|
|
9
33
|
*/
|
|
10
34
|
children: (item: T, index: number) => React.ReactNode;
|
|
35
|
+
noDataContent?: never;
|
|
36
|
+
}) & {
|
|
11
37
|
/**
|
|
12
38
|
* Number of items to show initially and to add on each scroll.
|
|
13
39
|
* @default 20
|
|
@@ -87,6 +113,6 @@ export type DataGridInfiniteBodyRef = {
|
|
|
87
113
|
* ```
|
|
88
114
|
*
|
|
89
115
|
*/
|
|
90
|
-
export declare function DataGridInfiniteBody<T>({ data, children: renderRow, batchSize, threshold, rootMargin, onVisibleCountChange, className, ref, }: DataGridInfiniteBodyProps<T> & {
|
|
116
|
+
export declare function DataGridInfiniteBody<T>({ data, children: renderRow, batchSize, threshold, rootMargin, onVisibleCountChange, className, noData, noDataContent, ref, }: DataGridInfiniteBodyProps<T> & {
|
|
91
117
|
ref?: React.Ref<DataGridInfiniteBodyRef>;
|
|
92
118
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v1.0
|
|
2
|
+
@versini/ui-datagrid v1.2.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -75,7 +75,7 @@ const ROW_INDEX_DATA_ATTR = "data-row-index";
|
|
|
75
75
|
* </DataGrid>
|
|
76
76
|
* ```
|
|
77
77
|
*
|
|
78
|
-
*/ function DataGridInfiniteBody({ data, children: renderRow, batchSize = DEFAULT_BATCH_SIZE, threshold = DEFAULT_THRESHOLD, rootMargin = DEFAULT_ROOT_MARGIN, onVisibleCountChange, className, ref }) {
|
|
78
|
+
*/ function DataGridInfiniteBody({ data = [], children: renderRow, batchSize = DEFAULT_BATCH_SIZE, threshold = DEFAULT_THRESHOLD, rootMargin = DEFAULT_ROOT_MARGIN, onVisibleCountChange, className, noData = false, noDataContent, ref }) {
|
|
79
79
|
const ctx = useContext(DataGridContext);
|
|
80
80
|
const bodyRef = useRef(null);
|
|
81
81
|
const observerRef = useRef(null);
|
|
@@ -297,7 +297,7 @@ const ROW_INDEX_DATA_ATTR = "data-row-index";
|
|
|
297
297
|
bodyContextBase
|
|
298
298
|
]);
|
|
299
299
|
// Measure column widths for sticky header/footer sync.
|
|
300
|
-
useColumnMeasurement(bodyRef, renderedContent);
|
|
300
|
+
useColumnMeasurement(bodyRef, renderedContent, noData);
|
|
301
301
|
const bodyClass = getBodyClass(className);
|
|
302
302
|
return /*#__PURE__*/ jsx(DataGridContext.Provider, {
|
|
303
303
|
value: {
|
|
@@ -308,7 +308,20 @@ const ROW_INDEX_DATA_ATTR = "data-row-index";
|
|
|
308
308
|
ref: bodyRef,
|
|
309
309
|
role: "rowgroup",
|
|
310
310
|
className: bodyClass,
|
|
311
|
-
children:
|
|
311
|
+
children: noData ? /*#__PURE__*/ jsx("div", {
|
|
312
|
+
role: "row",
|
|
313
|
+
style: {
|
|
314
|
+
gridColumn: "1 / -1"
|
|
315
|
+
},
|
|
316
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
317
|
+
role: "gridcell",
|
|
318
|
+
style: {
|
|
319
|
+
textAlign: "center",
|
|
320
|
+
width: "100%"
|
|
321
|
+
},
|
|
322
|
+
children: noDataContent ?? "No Data"
|
|
323
|
+
})
|
|
324
|
+
}) : renderedContent
|
|
312
325
|
})
|
|
313
326
|
});
|
|
314
327
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-datagrid",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"sideEffects": [
|
|
99
99
|
"**/*.css"
|
|
100
100
|
],
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "4fcf4b9c61ae979d4dfc6b054c9df706ceeb3619"
|
|
102
102
|
}
|