@versini/ui-datagrid 0.3.7 → 0.4.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/README.md +106 -29
- package/dist/DataGrid/DataGrid.js +7 -7
- package/dist/DataGrid/DataGridContext.js +1 -1
- package/dist/DataGrid/index.js +1 -1
- package/dist/DataGridAnimated/AnimatedWrapper.d.ts +11 -7
- package/dist/DataGridAnimated/AnimatedWrapper.js +12 -8
- package/dist/DataGridAnimated/index.js +1 -1
- package/dist/DataGridAnimated/useAnimatedHeight.js +1 -1
- package/dist/DataGridBody/DataGridBody.js +12 -54
- package/dist/DataGridBody/getBodyClass.d.ts +9 -0
- package/dist/DataGridBody/getBodyClass.js +23 -0
- package/dist/DataGridBody/index.js +1 -1
- package/dist/DataGridBody/useColumnMeasurement.d.ts +10 -0
- package/dist/DataGridBody/useColumnMeasurement.js +67 -0
- package/dist/DataGridCell/DataGridCell.d.ts +0 -10
- package/dist/DataGridCell/DataGridCell.js +4 -58
- package/dist/DataGridCell/index.js +1 -1
- package/dist/DataGridCellSort/DataGridCellSort.js +3 -3
- 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.d.ts +0 -15
- package/dist/DataGridFooter/DataGridFooter.js +6 -42
- package/dist/DataGridFooter/index.js +1 -1
- package/dist/DataGridHeader/DataGridHeader.d.ts +0 -27
- package/dist/DataGridHeader/DataGridHeader.js +6 -54
- package/dist/DataGridHeader/index.js +1 -1
- package/dist/DataGridInfinite/DataGridInfiniteBody.d.ts +52 -0
- package/dist/DataGridInfinite/DataGridInfiniteBody.js +309 -0
- package/dist/DataGridInfinite/index.d.ts +2 -4
- package/dist/DataGridInfinite/index.js +4 -8
- package/dist/DataGridRow/DataGridRow.js +10 -34
- 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 +150 -0
- package/dist/utilities/classes.js +249 -0
- package/package.json +2 -2
- package/dist/DataGrid/utilities.d.ts +0 -44
- package/dist/DataGrid/utilities.js +0 -92
- package/dist/DataGridInfinite/InfiniteScrollMarker.d.ts +0 -31
- package/dist/DataGridInfinite/InfiniteScrollMarker.js +0 -54
- package/dist/DataGridInfinite/useInfiniteScroll.d.ts +0 -92
- package/dist/DataGridInfinite/useInfiniteScroll.js +0 -136
- package/dist/common/utilities.d.ts +0 -15
- package/dist/common/utilities.js +0 -48
|
@@ -1,55 +1,30 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-datagrid v0.
|
|
2
|
+
@versini/ui-datagrid v0.4.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import clsx from "clsx";
|
|
8
7
|
import react from "react";
|
|
9
8
|
import { DataGridContext } from "../DataGrid/DataGridContext.js";
|
|
10
9
|
import { CellWrapper } from "../DataGridConstants/index.js";
|
|
10
|
+
import { getRowClasses } from "../utilities/classes.js";
|
|
11
11
|
|
|
12
12
|
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
13
13
|
|
|
14
|
-
;// CONCATENATED MODULE: external "clsx"
|
|
15
|
-
|
|
16
14
|
;// CONCATENATED MODULE: external "react"
|
|
17
15
|
|
|
18
16
|
;// CONCATENATED MODULE: external "../DataGrid/DataGridContext.js"
|
|
19
17
|
|
|
20
18
|
;// CONCATENATED MODULE: external "../DataGridConstants/index.js"
|
|
21
19
|
|
|
20
|
+
;// CONCATENATED MODULE: external "../utilities/classes.js"
|
|
21
|
+
|
|
22
22
|
;// CONCATENATED MODULE: ./src/DataGridRow/DataGridRow.tsx
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
const getRowClasses = ({ mode, className, cellWrapper })=>{
|
|
29
|
-
// Always use CSS Grid for proper column alignment, with vertical centering.
|
|
30
|
-
// `group` enables child cells to use group-data-[active] for active row indicator.
|
|
31
|
-
const layoutClass = "group grid items-center";
|
|
32
|
-
if (cellWrapper === CellWrapper.HEADER || cellWrapper === CellWrapper.FOOTER) {
|
|
33
|
-
/**
|
|
34
|
-
* When in a sticky header/footer, don't apply background to row since the
|
|
35
|
-
* background is applied to the rowgroup for blur effect to work.
|
|
36
|
-
*/ return clsx(layoutClass, className);
|
|
37
|
-
}
|
|
38
|
-
return clsx(layoutClass, "border-b last:border-0", {
|
|
39
|
-
"border-table-dark": mode === "dark" || mode === "system",
|
|
40
|
-
"border-table-light": mode === "light" || mode === "alt-system",
|
|
41
|
-
"dark:border-table-light": mode === "system",
|
|
42
|
-
"dark:border-table-dark": mode === "alt-system",
|
|
43
|
-
"odd:bg-table-dark-odd even:bg-table-dark-even": mode === "dark",
|
|
44
|
-
"hover:bg-table-dark-hover": mode === "dark",
|
|
45
|
-
"odd:bg-table-light-odd even:bg-table-light-even": mode === "light",
|
|
46
|
-
"hover:bg-table-light-hover": mode === "light",
|
|
47
|
-
"odd:bg-table-dark-odd even:bg-table-dark-even dark:odd:bg-table-light-odd dark:even:bg-table-light-even": mode === "system",
|
|
48
|
-
"hover:bg-table-dark-hover dark:hover:bg-table-light-hover": mode === "system",
|
|
49
|
-
"odd:bg-table-light-odd even:bg-table-light-even dark:odd:bg-table-dark-odd dark:even:bg-table-dark-even": mode === "alt-system",
|
|
50
|
-
"hover:bg-table-light-hover dark::hover:bg-table-dark-hover": mode === "alt-system"
|
|
51
|
-
}, className);
|
|
52
|
-
};
|
|
53
28
|
/* =============================================================================
|
|
54
29
|
* DataGridRow
|
|
55
30
|
* ========================================================================== */ const DataGridRow = ({ className, children, active, style: userStyle, ...rest })=>{
|
|
@@ -79,11 +54,12 @@ const getRowClasses = ({ mode, className, cellWrapper })=>{
|
|
|
79
54
|
*/ let rowStyle;
|
|
80
55
|
if (columns) {
|
|
81
56
|
if (isInStickyContext) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Sticky elements can't use subgrid. Use measured widths from body if
|
|
59
|
+
* available for perfect alignment. Also check that widths are valid
|
|
60
|
+
* (non-zero) - in test environments or before layout, measurements may be
|
|
61
|
+
* zero.
|
|
62
|
+
*/ const hasValidMeasurements = measuredColumnWidths && measuredColumnWidths.length === columns.length && measuredColumnWidths.some((w)=>w > 0);
|
|
87
63
|
if (hasValidMeasurements) {
|
|
88
64
|
rowStyle = {
|
|
89
65
|
gridTemplateColumns: measuredColumnWidths.map((w)=>`${w}px`).join(" ")
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { type BlurEffect, type CellWrapperType, type ThemeMode } from "../DataGridConstants/DataGridConstants";
|
|
2
|
+
/**
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* Primitive Theme Mappings (reusable building blocks)
|
|
5
|
+
* ============================================================================
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Text color classes based on theme mode. Used by: DataGrid wrapper, grid,
|
|
9
|
+
* spinner, header/footer copy.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getTextColorClasses: ({ mode }: {
|
|
12
|
+
mode: ThemeMode;
|
|
13
|
+
}) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Surface background classes (main container backgrounds). Used by: DataGrid
|
|
16
|
+
* wrapper.
|
|
17
|
+
*/
|
|
18
|
+
export declare const getSurfaceBackgroundClasses: ({ mode }: {
|
|
19
|
+
mode: ThemeMode;
|
|
20
|
+
}) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Header/footer background classes (with optional blur transparency). Used by:
|
|
23
|
+
* DataGridHeader, DataGridFooter.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getHeaderFooterBackgroundClasses: ({ mode, hasBlur, sticky, }: {
|
|
26
|
+
mode: ThemeMode;
|
|
27
|
+
hasBlur: boolean;
|
|
28
|
+
sticky: boolean;
|
|
29
|
+
}) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Border color classes for rows. Used by: DataGridRow.
|
|
32
|
+
*/
|
|
33
|
+
export declare const getBorderClasses: ({ mode }: {
|
|
34
|
+
mode: ThemeMode;
|
|
35
|
+
}) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Blur effect classes for sticky elements. Used by: DataGridHeader,
|
|
38
|
+
* DataGridFooter.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getBlurClasses: ({ blurEffect }: {
|
|
41
|
+
blurEffect?: BlurEffect;
|
|
42
|
+
}) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Shadow classes for sticky headers (downward glow).
|
|
45
|
+
*/
|
|
46
|
+
export declare const getStickyHeaderShadowClasses: ({ mode, stickyHeader, }: {
|
|
47
|
+
mode: ThemeMode;
|
|
48
|
+
stickyHeader?: boolean;
|
|
49
|
+
}) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Shadow classes for sticky footers (upward glow).
|
|
52
|
+
*/
|
|
53
|
+
export declare const getStickyFooterShadowClasses: ({ mode, stickyFooter, }: {
|
|
54
|
+
mode: ThemeMode;
|
|
55
|
+
stickyFooter?: boolean;
|
|
56
|
+
}) => string;
|
|
57
|
+
/**
|
|
58
|
+
* ============================================================================
|
|
59
|
+
* Composite Class Generators (component-specific combinations)
|
|
60
|
+
* ============================================================================
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Spinner classes for loading state.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getSpinnerClasses: ({ mode }: {
|
|
66
|
+
mode: ThemeMode;
|
|
67
|
+
}) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Overlay classes for disabled state.
|
|
70
|
+
*/
|
|
71
|
+
export declare const getOverlayClasses: ({ mode }: {
|
|
72
|
+
mode: ThemeMode;
|
|
73
|
+
}) => {
|
|
74
|
+
inner: string;
|
|
75
|
+
overlay: string;
|
|
76
|
+
spinnerWrapper: string;
|
|
77
|
+
spinner: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Generates classes for the main DataGrid wrapper and grid.
|
|
81
|
+
*/
|
|
82
|
+
export declare const getDataGridClasses: ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, disabled, hasColumns, }: {
|
|
83
|
+
mode: ThemeMode;
|
|
84
|
+
className?: string;
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
hasColumns?: boolean;
|
|
87
|
+
stickyFooter?: boolean;
|
|
88
|
+
stickyHeader?: boolean;
|
|
89
|
+
wrapperClassName?: string;
|
|
90
|
+
}) => {
|
|
91
|
+
overlay: string;
|
|
92
|
+
inner: string;
|
|
93
|
+
spinnerWrapper: string;
|
|
94
|
+
spinner: string;
|
|
95
|
+
wrapper: string;
|
|
96
|
+
scrollableContent: string;
|
|
97
|
+
grid: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Generates classes for the DataGridHeader wrapper.
|
|
101
|
+
*/
|
|
102
|
+
export declare const getHeaderClasses: ({ className, stickyHeader, mode, blurEffect, hasColumns, }: {
|
|
103
|
+
mode: ThemeMode;
|
|
104
|
+
blurEffect?: BlurEffect;
|
|
105
|
+
className?: string;
|
|
106
|
+
hasColumns?: boolean;
|
|
107
|
+
stickyHeader?: boolean;
|
|
108
|
+
}) => string;
|
|
109
|
+
/**
|
|
110
|
+
* Generates classes for the caption element inside DataGridHeader.
|
|
111
|
+
*/
|
|
112
|
+
export declare const getCaptionClasses: ({ captionClassName, hasColumns, }: {
|
|
113
|
+
captionClassName?: string;
|
|
114
|
+
hasColumns?: boolean;
|
|
115
|
+
}) => string;
|
|
116
|
+
/**
|
|
117
|
+
* Generates classes for the DataGridFooter.
|
|
118
|
+
*/
|
|
119
|
+
export declare const getFooterClasses: ({ className, stickyFooter, mode, blurEffect, hasColumns, }: {
|
|
120
|
+
mode: ThemeMode;
|
|
121
|
+
blurEffect?: BlurEffect;
|
|
122
|
+
className?: string;
|
|
123
|
+
hasColumns?: boolean;
|
|
124
|
+
stickyFooter?: boolean;
|
|
125
|
+
}) => string;
|
|
126
|
+
/**
|
|
127
|
+
* Generates classes for DataGridRow.
|
|
128
|
+
*/
|
|
129
|
+
export declare const getRowClasses: ({ mode, className, cellWrapper, }: {
|
|
130
|
+
mode: ThemeMode;
|
|
131
|
+
cellWrapper?: CellWrapperType;
|
|
132
|
+
className?: string;
|
|
133
|
+
}) => string;
|
|
134
|
+
/**
|
|
135
|
+
* Generates classes for DataGridCell.
|
|
136
|
+
*/
|
|
137
|
+
export declare const getCellClasses: ({ cellWrapper, className, compact, align, mode, borderLeft, borderRight, }: {
|
|
138
|
+
cellWrapper?: CellWrapperType;
|
|
139
|
+
className?: string;
|
|
140
|
+
mode?: ThemeMode;
|
|
141
|
+
compact?: boolean;
|
|
142
|
+
align?: "left" | "center" | "right";
|
|
143
|
+
borderLeft?: boolean;
|
|
144
|
+
borderRight?: boolean;
|
|
145
|
+
}) => string;
|
|
146
|
+
/**
|
|
147
|
+
* Returns the appropriate ARIA role for the cell based on the cell wrapper
|
|
148
|
+
* type.
|
|
149
|
+
*/
|
|
150
|
+
export declare const getCellRole: (cellWrapper?: CellWrapperType) => string;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.4.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { BlurEffects, CellWrapper } from "../DataGridConstants/DataGridConstants.js";
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "../DataGridConstants/DataGridConstants.js"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: ./src/utilities/classes.ts
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ============================================================================
|
|
18
|
+
* Primitive Theme Mappings (reusable building blocks)
|
|
19
|
+
* ============================================================================
|
|
20
|
+
*/ /**
|
|
21
|
+
* Text color classes based on theme mode. Used by: DataGrid wrapper, grid,
|
|
22
|
+
* spinner, header/footer copy.
|
|
23
|
+
*/ const getTextColorClasses = ({ mode })=>clsx({
|
|
24
|
+
"text-copy-light": mode === "dark",
|
|
25
|
+
"text-copy-dark": mode === "light",
|
|
26
|
+
"text-copy-light dark:text-copy-dark": mode === "system",
|
|
27
|
+
"text-copy-dark dark:text-copy-light": mode === "alt-system"
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Surface background classes (main container backgrounds). Used by: DataGrid
|
|
31
|
+
* wrapper.
|
|
32
|
+
*/ const getSurfaceBackgroundClasses = ({ mode })=>clsx({
|
|
33
|
+
"bg-surface-darker": mode === "dark" || mode === "system",
|
|
34
|
+
"bg-surface-light": mode === "light" || mode === "alt-system",
|
|
35
|
+
"dark:bg-surface-light": mode === "system",
|
|
36
|
+
"dark:bg-surface-darker": mode === "alt-system"
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Header/footer background classes (with optional blur transparency). Used by:
|
|
40
|
+
* DataGridHeader, DataGridFooter.
|
|
41
|
+
*/ const getHeaderFooterBackgroundClasses = ({ mode, hasBlur, sticky })=>clsx({
|
|
42
|
+
// Semi-transparent for blur effect.
|
|
43
|
+
"bg-surface-darkest/50": hasBlur && sticky && (mode === "dark" || mode === "system"),
|
|
44
|
+
"bg-surface-light/50": hasBlur && sticky && (mode === "light" || mode === "alt-system"),
|
|
45
|
+
"dark:bg-surface-light/50": hasBlur && sticky && mode === "system",
|
|
46
|
+
"dark:bg-surface-darkest/50": hasBlur && sticky && mode === "alt-system",
|
|
47
|
+
// Solid backgrounds.
|
|
48
|
+
"bg-surface-darkest": !hasBlur && (mode === "dark" || mode === "system"),
|
|
49
|
+
"bg-surface-light": !hasBlur && (mode === "light" || mode === "alt-system"),
|
|
50
|
+
"dark:bg-surface-light": !hasBlur && mode === "system",
|
|
51
|
+
"dark:bg-surface-darkest": !hasBlur && mode === "alt-system"
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Border color classes for rows. Used by: DataGridRow.
|
|
55
|
+
*/ const getBorderClasses = ({ mode })=>clsx({
|
|
56
|
+
"border-table-dark": mode === "dark" || mode === "system",
|
|
57
|
+
"border-table-light": mode === "light" || mode === "alt-system",
|
|
58
|
+
"dark:border-table-light": mode === "system",
|
|
59
|
+
"dark:border-table-dark": mode === "alt-system"
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Blur effect classes for sticky elements. Used by: DataGridHeader,
|
|
63
|
+
* DataGridFooter.
|
|
64
|
+
*/ const getBlurClasses = ({ blurEffect })=>clsx({
|
|
65
|
+
"backdrop-blur-sm": blurEffect === BlurEffects.SMALL,
|
|
66
|
+
"backdrop-blur-md": blurEffect === BlurEffects.MEDIUM,
|
|
67
|
+
"backdrop-blur-lg": blurEffect === BlurEffects.LARGE
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Shadow classes for sticky headers (downward glow).
|
|
71
|
+
*/ const getStickyHeaderShadowClasses = ({ mode, stickyHeader })=>clsx({
|
|
72
|
+
"shadow-[rgb(190_190_190_/20%)_0_0.5rem_1rem]": stickyHeader && mode === "dark",
|
|
73
|
+
"shadow-[rgb(190_190_190_/20%)_0_0.5rem_1rem] dark:shadow-[rgb(65_65_65_/30%)_0_0.5rem_1rem]": stickyHeader && mode === "system",
|
|
74
|
+
"shadow-[rgb(65_65_65_/30%)_0_0.5rem_1rem]": stickyHeader && mode === "light",
|
|
75
|
+
"shadow-[rgb(65_65_65_/30%)_0_0.5rem_1rem] dark:shadow-[rgb(190_190_190_/20%)_0_0.5rem_1rem]": stickyHeader && mode === "alt-system"
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Shadow classes for sticky footers (upward glow).
|
|
79
|
+
*/ const getStickyFooterShadowClasses = ({ mode, stickyFooter })=>clsx({
|
|
80
|
+
"shadow-[rgb(190_190_190_/20%)_0_-0.5rem_1rem]": stickyFooter && mode === "dark",
|
|
81
|
+
"shadow-[rgb(190_190_190_/20%)_0_-0.5rem_1rem] dark:shadow-[rgb(65_65_65_/30%)_0_-0.5rem_1rem]": stickyFooter && mode === "system",
|
|
82
|
+
"shadow-[rgb(65_65_65_/30%)_0_-0.5rem_1rem]": stickyFooter && mode === "light",
|
|
83
|
+
"shadow-[rgb(65_65_65_/30%)_0_-0.5rem_1rem] dark:shadow-[rgb(190_190_190_/20%)_0_-0.5rem_1rem]": stickyFooter && mode === "alt-system"
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* ============================================================================
|
|
87
|
+
* Composite Class Generators (component-specific combinations)
|
|
88
|
+
* ============================================================================
|
|
89
|
+
*/ /**
|
|
90
|
+
* Spinner classes for loading state.
|
|
91
|
+
*/ const getSpinnerClasses = ({ mode })=>clsx("size-8", "align-[-0.125em]", "border-4", "inline-block animate-spin rounded-full border-solid border-current border-r-transparent motion-reduce:animate-[spin_1.5s_linear_infinite]", {
|
|
92
|
+
"text-copy-dark": mode === "light",
|
|
93
|
+
"text-copy-light": mode === "dark",
|
|
94
|
+
"text-copy-dark dark:text-copy-light": mode === "alt-system",
|
|
95
|
+
"text-copy-light dark:text-copy-dark": mode === "system"
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Overlay classes for disabled state.
|
|
99
|
+
*/ const getOverlayClasses = ({ mode })=>({
|
|
100
|
+
inner: "relative",
|
|
101
|
+
overlay: clsx("absolute inset-0 z-20 cursor-not-allowed", "backdrop-blur-xs bg-white/30 dark:bg-black/30"),
|
|
102
|
+
spinnerWrapper: clsx("absolute z-30 top-0 left-0 right-0 h-[min(100%,100vh)]", "flex items-center justify-center", "pointer-events-none"),
|
|
103
|
+
spinner: getSpinnerClasses({
|
|
104
|
+
mode
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Generates classes for the main DataGrid wrapper and grid.
|
|
109
|
+
*/ const getDataGridClasses = ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, disabled, hasColumns })=>{
|
|
110
|
+
const overlayClasses = disabled ? getOverlayClasses({
|
|
111
|
+
mode
|
|
112
|
+
}) : null;
|
|
113
|
+
const hasSticky = stickyHeader || stickyFooter;
|
|
114
|
+
return {
|
|
115
|
+
overlay: overlayClasses?.overlay ?? "",
|
|
116
|
+
inner: overlayClasses?.inner ?? "",
|
|
117
|
+
spinnerWrapper: overlayClasses?.spinnerWrapper ?? "",
|
|
118
|
+
spinner: overlayClasses?.spinner ?? "",
|
|
119
|
+
wrapper: clsx("not-prose relative w-full rounded-lg shadow-md", {
|
|
120
|
+
"overflow-x-auto": !hasSticky && !disabled,
|
|
121
|
+
"overflow-hidden flex flex-col": hasSticky || disabled
|
|
122
|
+
}, getSurfaceBackgroundClasses({
|
|
123
|
+
mode
|
|
124
|
+
}), getTextColorClasses({
|
|
125
|
+
mode
|
|
126
|
+
}), wrapperClassName),
|
|
127
|
+
scrollableContent: clsx("overflow-y-auto overflow-x-hidden rounded-[inherit] flex-1 min-h-0"),
|
|
128
|
+
grid: clsx("my-0 w-full text-left text-sm", hasColumns ? "grid" : "flex flex-col", className, getTextColorClasses({
|
|
129
|
+
mode
|
|
130
|
+
}))
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Generates classes for the DataGridHeader wrapper.
|
|
135
|
+
*/ const getHeaderClasses = ({ className, stickyHeader, mode, blurEffect, hasColumns })=>{
|
|
136
|
+
const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
|
|
137
|
+
if (hasColumns && !stickyHeader) {
|
|
138
|
+
return clsx("contents", getHeaderFooterBackgroundClasses({
|
|
139
|
+
mode,
|
|
140
|
+
hasBlur,
|
|
141
|
+
sticky: Boolean(stickyHeader)
|
|
142
|
+
}), getTextColorClasses({
|
|
143
|
+
mode
|
|
144
|
+
}), className);
|
|
145
|
+
}
|
|
146
|
+
return clsx("flex flex-col", {
|
|
147
|
+
"absolute left-0 right-0 z-20 top-0 rounded-t-lg": stickyHeader
|
|
148
|
+
}, getHeaderFooterBackgroundClasses({
|
|
149
|
+
mode,
|
|
150
|
+
hasBlur,
|
|
151
|
+
sticky: Boolean(stickyHeader)
|
|
152
|
+
}), getTextColorClasses({
|
|
153
|
+
mode
|
|
154
|
+
}), stickyHeader && getBlurClasses({
|
|
155
|
+
blurEffect
|
|
156
|
+
}), className);
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Generates classes for the caption element inside DataGridHeader.
|
|
160
|
+
*/ const getCaptionClasses = ({ captionClassName, hasColumns })=>{
|
|
161
|
+
return clsx("py-2 text-sm text-center font-bold", hasColumns && "col-span-full", captionClassName);
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Generates classes for the DataGridFooter.
|
|
165
|
+
*/ const getFooterClasses = ({ className, stickyFooter, mode, blurEffect, hasColumns })=>{
|
|
166
|
+
if (hasColumns && !stickyFooter) {
|
|
167
|
+
return clsx("contents", className);
|
|
168
|
+
}
|
|
169
|
+
const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
|
|
170
|
+
return clsx("flex flex-col", {
|
|
171
|
+
"absolute left-0 right-0 z-20 bottom-0 rounded-b-lg": stickyFooter
|
|
172
|
+
}, getStickyFooterShadowClasses({
|
|
173
|
+
mode,
|
|
174
|
+
stickyFooter
|
|
175
|
+
}), getHeaderFooterBackgroundClasses({
|
|
176
|
+
mode,
|
|
177
|
+
hasBlur,
|
|
178
|
+
sticky: Boolean(stickyFooter)
|
|
179
|
+
}), stickyFooter && getBlurClasses({
|
|
180
|
+
blurEffect
|
|
181
|
+
}), className);
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Generates classes for DataGridRow.
|
|
185
|
+
*/ const getRowClasses = ({ mode, className, cellWrapper })=>{
|
|
186
|
+
const layoutClass = "group grid items-center";
|
|
187
|
+
if (cellWrapper === CellWrapper.HEADER || cellWrapper === CellWrapper.FOOTER) {
|
|
188
|
+
return clsx(layoutClass, className);
|
|
189
|
+
}
|
|
190
|
+
return clsx(layoutClass, "border-b last:border-0", getBorderClasses({
|
|
191
|
+
mode
|
|
192
|
+
}), {
|
|
193
|
+
"odd:bg-table-dark-odd even:bg-table-dark-even": mode === "dark",
|
|
194
|
+
"hover:bg-table-dark-hover": mode === "dark",
|
|
195
|
+
"odd:bg-table-light-odd even:bg-table-light-even": mode === "light",
|
|
196
|
+
"hover:bg-table-light-hover": mode === "light",
|
|
197
|
+
"odd:bg-table-dark-odd even:bg-table-dark-even dark:odd:bg-table-light-odd dark:even:bg-table-light-even": mode === "system",
|
|
198
|
+
"hover:bg-table-dark-hover dark:hover:bg-table-light-hover": mode === "system",
|
|
199
|
+
"odd:bg-table-light-odd even:bg-table-light-even dark:odd:bg-table-dark-odd dark:even:bg-table-dark-even": mode === "alt-system",
|
|
200
|
+
"hover:bg-table-light-hover dark:hover:bg-table-dark-hover": mode === "alt-system"
|
|
201
|
+
}, className);
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Generates classes for DataGridCell.
|
|
205
|
+
*/ const getCellClasses = ({ cellWrapper, className, compact, align, mode, borderLeft, borderRight })=>{
|
|
206
|
+
const isHeader = cellWrapper === CellWrapper.HEADER;
|
|
207
|
+
return clsx(// Base padding.
|
|
208
|
+
{
|
|
209
|
+
"px-2 py-1": compact,
|
|
210
|
+
"px-4 py-3": !compact
|
|
211
|
+
}, // Text alignment.
|
|
212
|
+
{
|
|
213
|
+
"text-left justify-start": align === "left" || !align,
|
|
214
|
+
"text-center justify-center": align === "center",
|
|
215
|
+
"text-right justify-end": align === "right"
|
|
216
|
+
}, // Header/footer specific styles.
|
|
217
|
+
{
|
|
218
|
+
"font-semibold": isHeader
|
|
219
|
+
}, // Active row indicator.
|
|
220
|
+
"first:group-data-[active]:relative", "first:group-data-[active]:before:absolute first:group-data-[active]:before:left-0 first:group-data-[active]:before:top-0 first:group-data-[active]:before:bottom-0 first:group-data-[active]:before:w-1", "first:group-data-[active]:self-stretch first:group-data-[active]:flex first:group-data-[active]:items-center", // Active indicator color based on theme mode.
|
|
221
|
+
{
|
|
222
|
+
"first:group-data-[active]:before:bg-table-active-dark": mode === "dark",
|
|
223
|
+
"first:group-data-[active]:before:bg-table-active-light": mode === "light",
|
|
224
|
+
"first:group-data-[active]:before:bg-table-active-dark dark:first:group-data-[active]:before:bg-table-active-light": mode === "system",
|
|
225
|
+
"first:group-data-[active]:before:bg-table-active-light dark:first:group-data-[active]:before:bg-table-active-dark": mode === "alt-system"
|
|
226
|
+
}, // Vertical borders.
|
|
227
|
+
{
|
|
228
|
+
"self-stretch flex items-center": borderLeft || borderRight,
|
|
229
|
+
"border-l border-l-table-dark": borderLeft && mode === "dark",
|
|
230
|
+
"border-l border-l-table-light": borderLeft && mode === "light",
|
|
231
|
+
"border-l border-l-table-dark dark:border-l-table-light": borderLeft && mode === "system",
|
|
232
|
+
"border-l border-l-table-light dark:border-l-table-dark": borderLeft && mode === "alt-system",
|
|
233
|
+
"border-r border-r-table-dark": borderRight && mode === "dark",
|
|
234
|
+
"border-r border-r-table-light": borderRight && mode === "light",
|
|
235
|
+
"border-r border-r-table-dark dark:border-r-table-light": borderRight && mode === "system",
|
|
236
|
+
"border-r border-r-table-light dark:border-r-table-dark": borderRight && mode === "alt-system"
|
|
237
|
+
}, className);
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Returns the appropriate ARIA role for the cell based on the cell wrapper
|
|
241
|
+
* type.
|
|
242
|
+
*/ const getCellRole = (cellWrapper)=>{
|
|
243
|
+
if (cellWrapper === CellWrapper.HEADER) {
|
|
244
|
+
return "columnheader";
|
|
245
|
+
}
|
|
246
|
+
return "gridcell";
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export { getBlurClasses, getBorderClasses, getCaptionClasses, getCellClasses, getCellRole, getDataGridClasses, getFooterClasses, getHeaderClasses, getHeaderFooterBackgroundClasses, getOverlayClasses, getRowClasses, getSpinnerClasses, getStickyFooterShadowClasses, getStickyHeaderShadowClasses, getSurfaceBackgroundClasses, getTextColorClasses };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-datagrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"sideEffects": [
|
|
95
95
|
"**/*.css"
|
|
96
96
|
],
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "fa25a9204c1b506f6eed099cc11e321b53bb0f05"
|
|
98
98
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type ThemeMode } from "../DataGridConstants/DataGridConstants";
|
|
2
|
-
/**
|
|
3
|
-
* Generates classes for the main DataGrid wrapper and grid. When sticky
|
|
4
|
-
* header/footer is enabled:
|
|
5
|
-
* - Outer wrapper has overflow-hidden
|
|
6
|
-
* - Scrollable area is a separate inner container with dynamic padding
|
|
7
|
-
* - Header/footer use position:absolute to overlay scrollbar
|
|
8
|
-
* - Padding is dynamically set via inline styles based on measured heights
|
|
9
|
-
*
|
|
10
|
-
* When columns prop is provided, the grid uses CSS Grid layout with subgrid
|
|
11
|
-
* support for proper column alignment across all rows.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare const getDataGridClasses: ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, disabled, hasColumns, }: {
|
|
15
|
-
mode: ThemeMode;
|
|
16
|
-
className?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
hasColumns?: boolean;
|
|
19
|
-
stickyFooter?: boolean;
|
|
20
|
-
stickyHeader?: boolean;
|
|
21
|
-
wrapperClassName?: string;
|
|
22
|
-
}) => {
|
|
23
|
-
overlay: string;
|
|
24
|
-
inner: string;
|
|
25
|
-
spinnerWrapper: string;
|
|
26
|
-
spinner: string;
|
|
27
|
-
/**
|
|
28
|
-
* Outer wrapper - overflow-hidden when sticky, like Panel's outerWrapper.
|
|
29
|
-
* Uses flex layout when sticky to allow scrollableContent to respect
|
|
30
|
-
* max-height.
|
|
31
|
-
*/
|
|
32
|
-
wrapper: string;
|
|
33
|
-
/**
|
|
34
|
-
* Scrollable content area for absolute-positioned header/footer. Padding is
|
|
35
|
-
* applied via inline styles based on measured header/footer heights,
|
|
36
|
-
* eliminating the need for hard-coded values that break when styles change.
|
|
37
|
-
*/
|
|
38
|
-
scrollableContent: string;
|
|
39
|
-
/**
|
|
40
|
-
* When columns are provided, use CSS Grid so rows can use subgrid for
|
|
41
|
-
* consistent column alignment. Otherwise, use flexbox.
|
|
42
|
-
*/
|
|
43
|
-
grid: string;
|
|
44
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
@versini/ui-datagrid v0.3.7
|
|
3
|
-
© 2026 gizmette.com
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import clsx from "clsx";
|
|
7
|
-
|
|
8
|
-
;// CONCATENATED MODULE: external "clsx"
|
|
9
|
-
|
|
10
|
-
;// CONCATENATED MODULE: ./src/DataGrid/utilities.ts
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Generates classes for the loading spinner.
|
|
14
|
-
*/ const getSpinnerClasses = ({ mode })=>{
|
|
15
|
-
return clsx("size-8", "align-[-0.125em]", "border-4", "inline-block animate-spin rounded-full border-solid border-current border-r-transparent motion-reduce:animate-[spin_1.5s_linear_infinite]", {
|
|
16
|
-
"text-copy-dark": mode === "light",
|
|
17
|
-
"text-copy-light": mode === "dark",
|
|
18
|
-
"text-copy-dark dark:text-copy-light": mode === "alt-system",
|
|
19
|
-
"text-copy-light dark:text-copy-dark": mode === "system"
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Generates classes for the loading overlay.
|
|
24
|
-
*/ const getOverlayClasses = ({ mode })=>{
|
|
25
|
-
return {
|
|
26
|
-
inner: "relative",
|
|
27
|
-
overlay: clsx("absolute inset-0 z-20 cursor-not-allowed", "backdrop-blur-xs bg-white/30 dark:bg-black/30"),
|
|
28
|
-
spinnerWrapper: clsx("absolute z-30 top-0 left-0 right-0 h-[min(100%,100vh)]", "flex items-center justify-center", "pointer-events-none"),
|
|
29
|
-
spinner: getSpinnerClasses({
|
|
30
|
-
mode
|
|
31
|
-
})
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Generates classes for the main DataGrid wrapper and grid. When sticky
|
|
36
|
-
* header/footer is enabled:
|
|
37
|
-
* - Outer wrapper has overflow-hidden
|
|
38
|
-
* - Scrollable area is a separate inner container with dynamic padding
|
|
39
|
-
* - Header/footer use position:absolute to overlay scrollbar
|
|
40
|
-
* - Padding is dynamically set via inline styles based on measured heights
|
|
41
|
-
*
|
|
42
|
-
* When columns prop is provided, the grid uses CSS Grid layout with subgrid
|
|
43
|
-
* support for proper column alignment across all rows.
|
|
44
|
-
*
|
|
45
|
-
*/ const getDataGridClasses = ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, disabled, hasColumns })=>{
|
|
46
|
-
const overlayClasses = disabled ? getOverlayClasses({
|
|
47
|
-
mode
|
|
48
|
-
}) : null;
|
|
49
|
-
const hasSticky = stickyHeader || stickyFooter;
|
|
50
|
-
return {
|
|
51
|
-
overlay: overlayClasses?.overlay ?? "",
|
|
52
|
-
inner: overlayClasses?.inner ?? "",
|
|
53
|
-
spinnerWrapper: overlayClasses?.spinnerWrapper ?? "",
|
|
54
|
-
spinner: overlayClasses?.spinner ?? "",
|
|
55
|
-
/**
|
|
56
|
-
* Outer wrapper - overflow-hidden when sticky, like Panel's outerWrapper.
|
|
57
|
-
* Uses flex layout when sticky to allow scrollableContent to respect
|
|
58
|
-
* max-height.
|
|
59
|
-
*/ wrapper: clsx("not-prose relative w-full rounded-lg shadow-md", {
|
|
60
|
-
"overflow-x-auto": !hasSticky && !disabled,
|
|
61
|
-
"overflow-hidden flex flex-col": hasSticky || disabled,
|
|
62
|
-
"bg-surface-darker": mode === "dark" || mode === "system",
|
|
63
|
-
"bg-surface-light": mode === "light" || mode === "alt-system",
|
|
64
|
-
"dark:bg-surface-light": mode === "system",
|
|
65
|
-
"dark:bg-surface-darker": mode === "alt-system",
|
|
66
|
-
"text-copy-light": mode === "dark",
|
|
67
|
-
"text-copy-dark": mode === "light",
|
|
68
|
-
"text-copy-light dark:text-copy-dark": mode === "system",
|
|
69
|
-
"text-copy-dark dark:text-copy-light": mode === "alt-system"
|
|
70
|
-
}, wrapperClassName),
|
|
71
|
-
/**
|
|
72
|
-
* Scrollable content area for absolute-positioned header/footer. Padding is
|
|
73
|
-
* applied via inline styles based on measured header/footer heights,
|
|
74
|
-
* eliminating the need for hard-coded values that break when styles change.
|
|
75
|
-
*/ scrollableContent: clsx(/**
|
|
76
|
-
* flex-1 + min-h-0 allows this to shrink within flex parent and enable
|
|
77
|
-
* scrolling. min-h-0 overrides the default min-height:auto that prevents
|
|
78
|
-
* flex items from shrinking.
|
|
79
|
-
*/ "overflow-y-auto overflow-x-hidden rounded-[inherit] flex-1 min-h-0"),
|
|
80
|
-
/**
|
|
81
|
-
* When columns are provided, use CSS Grid so rows can use subgrid for
|
|
82
|
-
* consistent column alignment. Otherwise, use flexbox.
|
|
83
|
-
*/ grid: clsx("my-0 w-full text-left text-sm", hasColumns ? "grid" : "flex flex-col", className, {
|
|
84
|
-
"text-copy-light": mode === "dark",
|
|
85
|
-
"text-copy-dark": mode === "light",
|
|
86
|
-
"text-copy-light dark:text-copy-dark": mode === "system",
|
|
87
|
-
"text-copy-dark dark:text-copy-light": mode === "alt-system"
|
|
88
|
-
})
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export { getDataGridClasses };
|