@versini/ui-datagrid 0.4.7 → 0.6.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/DataGrid/DataGrid.d.ts +1 -1
- package/dist/DataGrid/DataGrid.js +4 -4
- package/dist/DataGrid/DataGridContext.js +1 -1
- package/dist/DataGrid/DataGridTypes.d.ts +5 -0
- package/dist/DataGrid/DataGridTypes.js +1 -1
- package/dist/DataGrid/index.js +1 -1
- package/dist/DataGridAnimated/AnimatedWrapper.js +1 -1
- package/dist/DataGridAnimated/index.js +1 -1
- package/dist/DataGridAnimated/useAnimatedHeight.js +1 -1
- package/dist/DataGridBody/DataGridBody.js +2 -2
- package/dist/DataGridBody/getBodyClass.d.ts +4 -5
- package/dist/DataGridBody/getBodyClass.js +6 -7
- package/dist/DataGridBody/index.js +1 -1
- package/dist/DataGridBody/useColumnMeasurement.js +1 -1
- package/dist/DataGridCell/DataGridCell.js +1 -1
- package/dist/DataGridCell/index.js +1 -1
- package/dist/DataGridCellSort/DataGridCellSort.js +3 -2
- package/dist/DataGridCellSort/index.js +1 -1
- package/dist/DataGridConstants/DataGridConstants.js +1 -1
- package/dist/DataGridConstants/index.js +1 -1
- package/dist/DataGridFooter/DataGridFooter.js +2 -4
- package/dist/DataGridFooter/index.js +1 -1
- package/dist/DataGridHeader/DataGridHeader.js +5 -5
- package/dist/DataGridHeader/index.js +1 -1
- package/dist/DataGridInfinite/DataGridInfiniteBody.js +2 -2
- package/dist/DataGridInfinite/index.js +1 -1
- package/dist/DataGridRow/DataGridRow.js +1 -2
- package/dist/DataGridRow/index.js +1 -1
- package/dist/DataGridSorting/index.js +1 -1
- package/dist/DataGridSorting/sortingUtils.js +1 -1
- package/dist/utilities/classes.d.ts +19 -12
- package/dist/utilities/classes.js +63 -40
- package/package.json +8 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DataGridProps } from "./DataGridTypes";
|
|
2
|
-
export declare const DataGrid: ({ className, wrapperClassName, children, mode, compact, stickyHeader, stickyFooter, blurEffect, maxHeight, loading, columns, ...rest }: DataGridProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DataGrid: ({ className, wrapperClassName, children, mode, compact, stickyHeader, stickyFooter, blurEffect, maxHeight, loading, columns, noBorder, ...rest }: DataGridProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ import { DataGridContext } from "./DataGridContext.js";
|
|
|
27
27
|
|
|
28
28
|
/* =============================================================================
|
|
29
29
|
* DataGrid (main component)
|
|
30
|
-
* ========================================================================== */ const DataGrid = ({ className, wrapperClassName, children, mode = "system", compact = false, stickyHeader = false, stickyFooter = false, blurEffect = BlurEffects.NONE, maxHeight, loading = false, columns, ...rest })=>{
|
|
30
|
+
* ========================================================================== */ const DataGrid = ({ className, wrapperClassName, children, mode = "system", compact = false, stickyHeader = false, stickyFooter = false, blurEffect = BlurEffects.NONE, maxHeight, loading = false, columns, noBorder = false, ...rest })=>{
|
|
31
31
|
/**
|
|
32
32
|
* Track registered header/footer components via context registration. Uses
|
|
33
33
|
* counter-based tracking to properly handle multiple instances. Components
|
|
@@ -76,7 +76,7 @@ import { DataGridContext } from "./DataGridContext.js";
|
|
|
76
76
|
stickyHeader: effectiveStickyHeader,
|
|
77
77
|
stickyFooter: effectiveStickyFooter,
|
|
78
78
|
loading: Boolean(loading),
|
|
79
|
-
|
|
79
|
+
noBorder
|
|
80
80
|
}), [
|
|
81
81
|
mode,
|
|
82
82
|
className,
|
|
@@ -84,7 +84,7 @@ import { DataGridContext } from "./DataGridContext.js";
|
|
|
84
84
|
effectiveStickyHeader,
|
|
85
85
|
effectiveStickyFooter,
|
|
86
86
|
loading,
|
|
87
|
-
|
|
87
|
+
noBorder
|
|
88
88
|
]);
|
|
89
89
|
const contextValue = useMemo(()=>({
|
|
90
90
|
mode,
|
|
@@ -78,6 +78,11 @@ export type DataGridProps = {
|
|
|
78
78
|
* @example ["200px", "1fr", "min-content"] - Fixed, flexible, and content-sized columns
|
|
79
79
|
*/
|
|
80
80
|
columns?: ReadonlyArray<DataGridColumnSize>;
|
|
81
|
+
/**
|
|
82
|
+
* Whether or not to render the DataGrid with a border.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
noBorder?: boolean;
|
|
81
86
|
};
|
|
82
87
|
export type DataGridHeaderProps = {
|
|
83
88
|
/**
|
package/dist/DataGrid/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -36,7 +36,7 @@ import { useColumnMeasurement } from "./useColumnMeasurement.js";
|
|
|
36
36
|
const bodyRef = useRef(null);
|
|
37
37
|
// Measure column widths for sticky header/footer sync.
|
|
38
38
|
useColumnMeasurement(bodyRef, children);
|
|
39
|
-
const bodyClass = getBodyClass(
|
|
39
|
+
const bodyClass = getBodyClass(className);
|
|
40
40
|
return /*#__PURE__*/ jsx(DataGridContext.Provider, {
|
|
41
41
|
value: {
|
|
42
42
|
...ctx,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get the CSS class for a DataGrid body element.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Get the CSS class for a DataGrid body element. Uses display:contents so the
|
|
3
|
+
* body doesn't interfere with the grid flow. Rows will use subgrid when columns
|
|
4
|
+
* are provided, or define their own grid otherwise.
|
|
5
5
|
*
|
|
6
|
-
* @param hasColumns - Whether the DataGrid has columns defined
|
|
7
6
|
* @param className - Additional class name to merge
|
|
8
7
|
*
|
|
9
8
|
*/
|
|
10
|
-
export declare function getBodyClass(
|
|
9
|
+
export declare function getBodyClass(className?: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -10,15 +10,14 @@ import clsx from "clsx";
|
|
|
10
10
|
;// CONCATENATED MODULE: ./src/DataGridBody/getBodyClass.ts
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Get the CSS class for a DataGrid body element.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Get the CSS class for a DataGrid body element. Uses display:contents so the
|
|
14
|
+
* body doesn't interfere with the grid flow. Rows will use subgrid when columns
|
|
15
|
+
* are provided, or define their own grid otherwise.
|
|
16
16
|
*
|
|
17
|
-
* @param hasColumns - Whether the DataGrid has columns defined
|
|
18
17
|
* @param className - Additional class name to merge
|
|
19
18
|
*
|
|
20
|
-
*/ function getBodyClass(
|
|
21
|
-
return
|
|
19
|
+
*/ function getBodyClass(className) {
|
|
20
|
+
return clsx("contents", className);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export { getBodyClass };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -97,8 +97,9 @@ import { getCellClasses } from "../utilities/classes.js";
|
|
|
97
97
|
onClick: handleSort,
|
|
98
98
|
noBorder: true,
|
|
99
99
|
focusMode: focusMode,
|
|
100
|
-
mode:
|
|
100
|
+
mode: "light",
|
|
101
101
|
labelRight: children,
|
|
102
|
+
noBackground: true,
|
|
102
103
|
children: getSortIcon()
|
|
103
104
|
}),
|
|
104
105
|
slotRight
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -42,7 +42,6 @@ DataGridFooter.displayName = "DataGridFooter";
|
|
|
42
42
|
* Inner component to handle the useEffect for registering footer. Separated to
|
|
43
43
|
* avoid hooks inside Consumer render prop.
|
|
44
44
|
*/ const DataGridFooterInner = ({ className, ctx, children, ...rest })=>{
|
|
45
|
-
const hasColumns = Boolean(ctx.columns);
|
|
46
45
|
const footerRef = useRef(null);
|
|
47
46
|
/**
|
|
48
47
|
* Register this footer with the parent DataGrid on mount. This enables sticky
|
|
@@ -88,8 +87,7 @@ DataGridFooter.displayName = "DataGridFooter";
|
|
|
88
87
|
className,
|
|
89
88
|
stickyFooter: ctx.stickyFooter,
|
|
90
89
|
mode: ctx.mode,
|
|
91
|
-
blurEffect: ctx.blurEffect
|
|
92
|
-
hasColumns
|
|
90
|
+
blurEffect: ctx.blurEffect
|
|
93
91
|
}),
|
|
94
92
|
...rest,
|
|
95
93
|
children: children
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -46,7 +46,6 @@ DataGridHeader.displayName = "DataGridHeader";
|
|
|
46
46
|
* Inner component to handle the useEffect for registering captionId and header.
|
|
47
47
|
* Separated to avoid hooks inside Consumer render prop.
|
|
48
48
|
*/ const DataGridHeaderInner = ({ caption, captionClassName, captionId, className, ctx, children, ...rest })=>{
|
|
49
|
-
const hasColumns = Boolean(ctx.columns);
|
|
50
49
|
const headerRef = useRef(null);
|
|
51
50
|
/**
|
|
52
51
|
* Register this header with the parent DataGrid on mount. This enables sticky
|
|
@@ -107,8 +106,7 @@ DataGridHeader.displayName = "DataGridHeader";
|
|
|
107
106
|
className,
|
|
108
107
|
stickyHeader: ctx.stickyHeader,
|
|
109
108
|
mode: ctx.mode,
|
|
110
|
-
blurEffect: ctx.blurEffect
|
|
111
|
-
hasColumns
|
|
109
|
+
blurEffect: ctx.blurEffect
|
|
112
110
|
}),
|
|
113
111
|
...rest,
|
|
114
112
|
children: [
|
|
@@ -116,7 +114,9 @@ DataGridHeader.displayName = "DataGridHeader";
|
|
|
116
114
|
id: captionId,
|
|
117
115
|
className: getCaptionClasses({
|
|
118
116
|
captionClassName,
|
|
119
|
-
|
|
117
|
+
mode: ctx.mode,
|
|
118
|
+
hasBlur: Boolean(ctx.blurEffect && ctx.blurEffect !== "none"),
|
|
119
|
+
stickyHeader: Boolean(ctx.stickyHeader)
|
|
120
120
|
}),
|
|
121
121
|
children: caption
|
|
122
122
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -313,7 +313,7 @@ const ROW_INDEX_DATA_ATTR = "data-row-index";
|
|
|
313
313
|
]);
|
|
314
314
|
// Measure column widths for sticky header/footer sync.
|
|
315
315
|
useColumnMeasurement(bodyRef, renderedContent);
|
|
316
|
-
const bodyClass = getBodyClass(
|
|
316
|
+
const bodyClass = getBodyClass(className);
|
|
317
317
|
return /*#__PURE__*/ jsx(DataGridContext.Provider, {
|
|
318
318
|
value: {
|
|
319
319
|
...ctx,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -90,7 +90,6 @@ import { getRowClasses } from "../utilities/classes.js";
|
|
|
90
90
|
className,
|
|
91
91
|
cellWrapper,
|
|
92
92
|
isLastRow,
|
|
93
|
-
hasColumns: Boolean(columns),
|
|
94
93
|
stickyHeader,
|
|
95
94
|
stickyFooter
|
|
96
95
|
}),
|
|
@@ -11,6 +11,10 @@ import { type BlurEffect, type CellWrapperType, type ThemeMode } from "../DataGr
|
|
|
11
11
|
export declare const getTextColorClasses: ({ mode }: {
|
|
12
12
|
mode: ThemeMode;
|
|
13
13
|
}) => string;
|
|
14
|
+
export declare const getTextColorClassesForHeaderFooter: ({ mode, hasBlur, }: {
|
|
15
|
+
mode: ThemeMode;
|
|
16
|
+
hasBlur: boolean;
|
|
17
|
+
}) => string;
|
|
14
18
|
/**
|
|
15
19
|
* Surface background classes (main container backgrounds). Used by: DataGrid
|
|
16
20
|
* wrapper.
|
|
@@ -22,8 +26,7 @@ export declare const getSurfaceBackgroundClasses: ({ mode }: {
|
|
|
22
26
|
* Header/footer background classes (with optional blur transparency). Used by:
|
|
23
27
|
* DataGridHeader, DataGridFooter.
|
|
24
28
|
*/
|
|
25
|
-
export declare const getHeaderFooterBackgroundClasses: ({
|
|
26
|
-
mode: ThemeMode;
|
|
29
|
+
export declare const getHeaderFooterBackgroundClasses: ({ hasBlur, sticky, }: {
|
|
27
30
|
hasBlur: boolean;
|
|
28
31
|
sticky: boolean;
|
|
29
32
|
}) => string;
|
|
@@ -65,11 +68,11 @@ export declare const getOverlayClasses: ({ mode }: {
|
|
|
65
68
|
/**
|
|
66
69
|
* Generates classes for the main DataGrid wrapper and grid.
|
|
67
70
|
*/
|
|
68
|
-
export declare const getDataGridClasses: ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, loading,
|
|
71
|
+
export declare const getDataGridClasses: ({ mode, noBorder, className, wrapperClassName, stickyHeader, stickyFooter, loading, }: {
|
|
69
72
|
mode: ThemeMode;
|
|
73
|
+
noBorder?: boolean;
|
|
70
74
|
className?: string;
|
|
71
75
|
loading?: boolean;
|
|
72
|
-
hasColumns?: boolean;
|
|
73
76
|
stickyFooter?: boolean;
|
|
74
77
|
stickyHeader?: boolean;
|
|
75
78
|
wrapperClassName?: string;
|
|
@@ -85,28 +88,33 @@ export declare const getDataGridClasses: ({ mode, className, wrapperClassName, s
|
|
|
85
88
|
/**
|
|
86
89
|
* Generates classes for the DataGridHeader wrapper.
|
|
87
90
|
*/
|
|
88
|
-
export declare const getHeaderClasses: ({ className, stickyHeader, mode, blurEffect,
|
|
91
|
+
export declare const getHeaderClasses: ({ className, stickyHeader, mode, blurEffect, }: {
|
|
89
92
|
mode: ThemeMode;
|
|
90
93
|
blurEffect?: BlurEffect;
|
|
91
94
|
className?: string;
|
|
92
|
-
hasColumns?: boolean;
|
|
93
95
|
stickyHeader?: boolean;
|
|
94
96
|
}) => string;
|
|
95
97
|
/**
|
|
96
98
|
* Generates classes for the caption element inside DataGridHeader.
|
|
99
|
+
* Needs explicit styling since the parent may use `display: contents`
|
|
100
|
+
* when not sticky, which doesn't render a box and breaks CSS inheritance.
|
|
97
101
|
*/
|
|
98
|
-
export declare const getCaptionClasses: ({ captionClassName,
|
|
102
|
+
export declare const getCaptionClasses: ({ captionClassName, mode, hasBlur, stickyHeader, }: {
|
|
99
103
|
captionClassName?: string;
|
|
100
|
-
|
|
104
|
+
mode: ThemeMode;
|
|
105
|
+
hasBlur: boolean;
|
|
106
|
+
stickyHeader: boolean;
|
|
101
107
|
}) => string;
|
|
102
108
|
/**
|
|
103
109
|
* Generates classes for the DataGridFooter.
|
|
104
110
|
*/
|
|
105
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Generates classes for the DataGridFooter.
|
|
113
|
+
*/
|
|
114
|
+
export declare const getFooterClasses: ({ className, stickyFooter, mode, blurEffect, }: {
|
|
106
115
|
mode: ThemeMode;
|
|
107
116
|
blurEffect?: BlurEffect;
|
|
108
117
|
className?: string;
|
|
109
|
-
hasColumns?: boolean;
|
|
110
118
|
stickyFooter?: boolean;
|
|
111
119
|
}) => string;
|
|
112
120
|
/**
|
|
@@ -114,12 +122,11 @@ export declare const getFooterClasses: ({ className, stickyFooter, mode, blurEff
|
|
|
114
122
|
* DataGridInfiniteBody), explicit odd/even classes are used instead of CSS
|
|
115
123
|
* :nth-child selectors, which don't work with wrapper elements.
|
|
116
124
|
*/
|
|
117
|
-
export declare const getRowClasses: ({ mode, className, cellWrapper, isLastRow,
|
|
125
|
+
export declare const getRowClasses: ({ mode, className, cellWrapper, isLastRow, stickyHeader, stickyFooter, }: {
|
|
118
126
|
mode: ThemeMode;
|
|
119
127
|
cellWrapper?: CellWrapperType;
|
|
120
128
|
className?: string;
|
|
121
129
|
isLastRow?: boolean;
|
|
122
|
-
hasColumns?: boolean;
|
|
123
130
|
stickyHeader?: boolean;
|
|
124
131
|
stickyFooter?: boolean;
|
|
125
132
|
}) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.6.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -20,12 +20,21 @@ import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants
|
|
|
20
20
|
*/ /**
|
|
21
21
|
* Text color classes based on theme mode. Used by: DataGrid wrapper, grid,
|
|
22
22
|
* spinner, header/footer copy.
|
|
23
|
-
*/ const getTextColorClasses = ({ mode })=>
|
|
23
|
+
*/ const getTextColorClasses = ({ mode })=>{
|
|
24
|
+
return clsx({
|
|
24
25
|
"text-copy-light": mode === "dark",
|
|
25
26
|
"text-copy-dark": mode === "light",
|
|
26
27
|
"text-copy-light dark:text-copy-dark": mode === "system",
|
|
27
28
|
"text-copy-dark dark:text-copy-light": mode === "alt-system"
|
|
28
29
|
});
|
|
30
|
+
};
|
|
31
|
+
const getTextColorClassesForHeaderFooter = ({ mode, hasBlur })=>{
|
|
32
|
+
return clsx({
|
|
33
|
+
"text-copy-dark": mode === "dark" && !hasBlur || mode === "light",
|
|
34
|
+
"text-copy-light dark:text-copy-dark": mode === "system" && hasBlur,
|
|
35
|
+
"text-copy-dark dark:text-copy-dark": (mode === "system" || mode === "alt-system") && !hasBlur
|
|
36
|
+
});
|
|
37
|
+
};
|
|
29
38
|
/**
|
|
30
39
|
* Surface background classes (main container backgrounds). Used by: DataGrid
|
|
31
40
|
* wrapper.
|
|
@@ -38,18 +47,14 @@ import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants
|
|
|
38
47
|
/**
|
|
39
48
|
* Header/footer background classes (with optional blur transparency). Used by:
|
|
40
49
|
* DataGridHeader, DataGridFooter.
|
|
41
|
-
*/ const getHeaderFooterBackgroundClasses = ({
|
|
50
|
+
*/ const getHeaderFooterBackgroundClasses = ({ hasBlur, sticky })=>{
|
|
51
|
+
return clsx({
|
|
42
52
|
// Semi-transparent for blur effect.
|
|
43
|
-
"bg-surface-
|
|
44
|
-
"bg-surface-medium/50": hasBlur && sticky && (mode === "light" || mode === "alt-system"),
|
|
45
|
-
"dark:bg-surface-medium/50": hasBlur && sticky && mode === "system",
|
|
46
|
-
"dark:bg-surface-darkest/50": hasBlur && sticky && mode === "alt-system",
|
|
53
|
+
"bg-surface-medium/50 dark:bg-surface-medium/50": hasBlur && sticky,
|
|
47
54
|
// Solid backgrounds.
|
|
48
|
-
"bg-surface-
|
|
49
|
-
"bg-surface-medium-light": !hasBlur && (mode === "light" || mode === "alt-system"),
|
|
50
|
-
"dark:bg-surface-medium-light": !hasBlur && mode === "system",
|
|
51
|
-
"dark:bg-surface-darkest": !hasBlur && mode === "alt-system"
|
|
55
|
+
"bg-surface-medium-light dark:bg-surface-medium-light": !hasBlur
|
|
52
56
|
});
|
|
57
|
+
};
|
|
53
58
|
/**
|
|
54
59
|
* Border color classes for rows. Used by: DataGridRow.
|
|
55
60
|
*/ const getBorderClasses = ({ mode })=>clsx({
|
|
@@ -90,7 +95,7 @@ import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants
|
|
|
90
95
|
});
|
|
91
96
|
/**
|
|
92
97
|
* Generates classes for the main DataGrid wrapper and grid.
|
|
93
|
-
*/ const getDataGridClasses = ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, loading
|
|
98
|
+
*/ const getDataGridClasses = ({ mode, noBorder, className, wrapperClassName, stickyHeader, stickyFooter, loading })=>{
|
|
94
99
|
const overlayClasses = loading ? getOverlayClasses({
|
|
95
100
|
mode
|
|
96
101
|
}) : null;
|
|
@@ -101,6 +106,7 @@ import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants
|
|
|
101
106
|
loadingWrapper: overlayClasses?.loadingWrapper ?? "",
|
|
102
107
|
loadingText: overlayClasses?.loadingText ?? "",
|
|
103
108
|
wrapper: clsx("not-prose relative w-full rounded-lg shadow-md", {
|
|
109
|
+
"ring-2 ring-table-dark": !noBorder,
|
|
104
110
|
"overflow-x-auto": !hasSticky && !loading,
|
|
105
111
|
"overflow-hidden flex flex-col": hasSticky || loading
|
|
106
112
|
}, getSurfaceBackgroundClasses({
|
|
@@ -109,74 +115,91 @@ import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants
|
|
|
109
115
|
mode
|
|
110
116
|
}), wrapperClassName),
|
|
111
117
|
scrollableContent: clsx("overflow-y-auto overflow-x-hidden rounded-[inherit] flex-1 min-h-0"),
|
|
112
|
-
grid: clsx("my-0 w-full text-left text-sm
|
|
118
|
+
grid: clsx("my-0 w-full text-left text-sm grid", className, getTextColorClasses({
|
|
113
119
|
mode
|
|
114
120
|
}))
|
|
115
121
|
};
|
|
116
122
|
};
|
|
117
123
|
/**
|
|
118
124
|
* Generates classes for the DataGridHeader wrapper.
|
|
119
|
-
*/ const getHeaderClasses = ({ className, stickyHeader, mode, blurEffect
|
|
125
|
+
*/ const getHeaderClasses = ({ className, stickyHeader, mode, blurEffect })=>{
|
|
120
126
|
const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
|
|
121
|
-
if (
|
|
127
|
+
if (!stickyHeader) {
|
|
122
128
|
return clsx("contents", getHeaderFooterBackgroundClasses({
|
|
123
|
-
mode,
|
|
124
129
|
hasBlur,
|
|
125
|
-
sticky:
|
|
126
|
-
}),
|
|
127
|
-
mode
|
|
130
|
+
sticky: false
|
|
131
|
+
}), getTextColorClassesForHeaderFooter({
|
|
132
|
+
mode,
|
|
133
|
+
hasBlur
|
|
128
134
|
}), className);
|
|
129
135
|
}
|
|
130
|
-
return clsx("flex flex-col", "border-b border-table-medium shadow-md", {
|
|
131
|
-
"absolute left-0 right-0 z-20 top-0 rounded-t-lg": stickyHeader
|
|
132
|
-
}, getHeaderFooterBackgroundClasses({
|
|
133
|
-
mode,
|
|
136
|
+
return clsx("flex flex-col", "border-b border-table-medium shadow-md", "absolute left-0 right-0 z-20 top-0 rounded-t-lg", getHeaderFooterBackgroundClasses({
|
|
134
137
|
hasBlur,
|
|
135
|
-
sticky:
|
|
136
|
-
}),
|
|
137
|
-
mode
|
|
138
|
+
sticky: true
|
|
139
|
+
}), getTextColorClassesForHeaderFooter({
|
|
140
|
+
mode,
|
|
141
|
+
hasBlur
|
|
138
142
|
}), stickyHeader && getBlurClasses({
|
|
139
143
|
blurEffect
|
|
140
144
|
}), className);
|
|
141
145
|
};
|
|
142
146
|
/**
|
|
143
147
|
* Generates classes for the caption element inside DataGridHeader.
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
* Needs explicit styling since the parent may use `display: contents`
|
|
149
|
+
* when not sticky, which doesn't render a box and breaks CSS inheritance.
|
|
150
|
+
*/ const getCaptionClasses = ({ captionClassName, mode, hasBlur, stickyHeader })=>{
|
|
151
|
+
/**
|
|
152
|
+
* When sticky, the header wrapper renders a box with background/text colors.
|
|
153
|
+
* When NOT sticky, the header uses `display: contents` so the caption needs
|
|
154
|
+
* its own background and text color styling.
|
|
155
|
+
*/ const needsOwnBackground = !stickyHeader;
|
|
156
|
+
return clsx("py-2 text-sm text-center font-bold col-span-full", getTextColorClassesForHeaderFooter({
|
|
157
|
+
mode,
|
|
158
|
+
hasBlur
|
|
159
|
+
}), needsOwnBackground && getHeaderFooterBackgroundClasses({
|
|
160
|
+
hasBlur,
|
|
161
|
+
sticky: false
|
|
162
|
+
}), captionClassName);
|
|
146
163
|
};
|
|
147
164
|
/**
|
|
148
165
|
* Generates classes for the DataGridFooter.
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
166
|
+
*/ /**
|
|
167
|
+
* Generates classes for the DataGridFooter.
|
|
168
|
+
*/ const getFooterClasses = ({ className, stickyFooter, mode, blurEffect })=>{
|
|
153
169
|
const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
|
|
170
|
+
if (!stickyFooter) {
|
|
171
|
+
return clsx("contents", getTextColorClassesForHeaderFooter({
|
|
172
|
+
mode,
|
|
173
|
+
hasBlur
|
|
174
|
+
}), className);
|
|
175
|
+
}
|
|
154
176
|
return clsx("flex flex-col", "border-t border-table-medium", {
|
|
155
177
|
"absolute left-0 right-0 z-20 bottom-0 rounded-b-lg shadow-[0_-10px_15px_-3px_rgba(0,0,0,0.1)]": stickyFooter
|
|
156
178
|
}, getHeaderFooterBackgroundClasses({
|
|
157
|
-
mode,
|
|
158
179
|
hasBlur,
|
|
159
180
|
sticky: Boolean(stickyFooter)
|
|
160
181
|
}), stickyFooter && getBlurClasses({
|
|
161
182
|
blurEffect
|
|
183
|
+
}), getTextColorClassesForHeaderFooter({
|
|
184
|
+
mode,
|
|
185
|
+
hasBlur
|
|
162
186
|
}), className);
|
|
163
187
|
};
|
|
164
188
|
/**
|
|
165
189
|
* Generates classes for DataGridRow. When rowIndex is provided (e.g., from
|
|
166
190
|
* DataGridInfiniteBody), explicit odd/even classes are used instead of CSS
|
|
167
191
|
* :nth-child selectors, which don't work with wrapper elements.
|
|
168
|
-
*/ const getRowClasses = ({ mode, className, cellWrapper, isLastRow,
|
|
192
|
+
*/ const getRowClasses = ({ mode, className, cellWrapper, isLastRow, stickyHeader, stickyFooter })=>{
|
|
169
193
|
const layoutClass = "group grid items-center";
|
|
170
194
|
if (cellWrapper === CellWrapper.HEADER || cellWrapper === CellWrapper.FOOTER) {
|
|
171
195
|
/**
|
|
172
|
-
* When
|
|
173
|
-
*
|
|
174
|
-
*
|
|
196
|
+
* When not sticky, the parent wrapper uses `display: contents` which
|
|
197
|
+
* doesn't render a box. In this case, we need to apply background and
|
|
198
|
+
* border styling directly to the row.
|
|
175
199
|
*/ const isHeader = cellWrapper === CellWrapper.HEADER;
|
|
176
|
-
const parentUsesContents = isHeader ?
|
|
200
|
+
const parentUsesContents = isHeader ? !stickyHeader : !stickyFooter;
|
|
177
201
|
if (parentUsesContents) {
|
|
178
202
|
return clsx(layoutClass, getHeaderFooterBackgroundClasses({
|
|
179
|
-
mode,
|
|
180
203
|
hasBlur: false,
|
|
181
204
|
sticky: false
|
|
182
205
|
}), {
|
|
@@ -242,4 +265,4 @@ import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants
|
|
|
242
265
|
return "gridcell";
|
|
243
266
|
};
|
|
244
267
|
|
|
245
|
-
export { getBlurClasses, getBorderClasses, getCaptionClasses, getCellClasses, getCellRole, getDataGridClasses, getFooterClasses, getHeaderClasses, getHeaderFooterBackgroundClasses, getLoadingTextClasses, getOverlayClasses, getRowClasses, getSurfaceBackgroundClasses, getTextColorClasses };
|
|
268
|
+
export { getBlurClasses, getBorderClasses, getCaptionClasses, getCellClasses, getCellRole, getDataGridClasses, getFooterClasses, getHeaderClasses, getHeaderFooterBackgroundClasses, getLoadingTextClasses, getOverlayClasses, getRowClasses, getSurfaceBackgroundClasses, getTextColorClasses, getTextColorClassesForHeaderFooter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-datagrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"build:js": "rslib build",
|
|
68
68
|
"build:types": "echo 'Types now built with rslib'",
|
|
69
69
|
"build": "npm-run-all --serial clean build:check build:js",
|
|
70
|
-
"clean": "rimraf dist tmp coverage",
|
|
70
|
+
"clean": "rimraf dist tmp test-results playwright-report playwright/.cache coverage",
|
|
71
71
|
"dev:js": "rslib build --watch",
|
|
72
72
|
"dev:types": "echo 'Types now watched with rslib'",
|
|
73
73
|
"dev": "rslib build --watch",
|
|
@@ -77,6 +77,11 @@
|
|
|
77
77
|
"start": "static-server dist --port 5173",
|
|
78
78
|
"test:coverage:ui": "vitest --coverage --ui",
|
|
79
79
|
"test:coverage": "vitest run --coverage",
|
|
80
|
+
"test:update": "vitest run --update",
|
|
81
|
+
"test:visual": "playwright test -c playwright-ct.config.ts",
|
|
82
|
+
"test:visual:report": "playwright show-report playwright-report",
|
|
83
|
+
"test:visual:update": "playwright test -c playwright-ct.config.ts --update-snapshots",
|
|
84
|
+
"test:visual:ui": "playwright test -c playwright-ct.config.ts --ui",
|
|
80
85
|
"test:watch": "vitest",
|
|
81
86
|
"test": "vitest run"
|
|
82
87
|
},
|
|
@@ -94,5 +99,5 @@
|
|
|
94
99
|
"sideEffects": [
|
|
95
100
|
"**/*.css"
|
|
96
101
|
],
|
|
97
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "a933817303d7fbc7682562b7db2579f93c1b9b42"
|
|
98
103
|
}
|