@versini/ui-datagrid 0.8.0 → 0.8.2
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/{DataGridBody/useColumnMeasurement.js → 131.js} +14 -7
- package/dist/298.js +215 -0
- package/dist/{DataGridConstants/DataGridConstants.js → 46.js} +1 -3
- package/dist/511.js +9 -0
- package/dist/926.js +15 -0
- package/dist/DataGrid/index.js +165 -7
- package/dist/DataGridAnimated/index.js +159 -6
- package/dist/DataGridBody/index.js +33 -4
- package/dist/DataGridCell/index.js +37 -4
- package/dist/DataGridCellSort/index.js +138 -4
- package/dist/DataGridConstants/index.js +2 -6
- package/dist/DataGridFooter/index.js +79 -4
- package/dist/DataGridHeader/index.js +110 -4
- package/dist/DataGridInfinite/index.js +312 -4
- package/dist/DataGridRow/index.js +89 -4
- package/dist/DataGridSorting/index.js +225 -7
- package/dist/utilities/classes.d.ts +7 -29
- package/package.json +3 -3
- package/dist/DataGrid/DataGrid.js +0 -183
- package/dist/DataGrid/DataGridContext.js +0 -16
- package/dist/DataGrid/DataGridTypes.js +0 -9
- package/dist/DataGridAnimated/AnimatedWrapper.js +0 -53
- package/dist/DataGridAnimated/useAnimatedHeight.js +0 -131
- package/dist/DataGridBody/DataGridBody.js +0 -55
- package/dist/DataGridBody/getBodyClass.js +0 -23
- package/dist/DataGridCell/DataGridCell.js +0 -51
- package/dist/DataGridCellSort/ButtonSort.js +0 -67
- package/dist/DataGridCellSort/DataGridCellSort.js +0 -111
- package/dist/DataGridFooter/DataGridFooter.js +0 -98
- package/dist/DataGridHeader/DataGridHeader.js +0 -129
- package/dist/DataGridInfinite/DataGridInfiniteBody.js +0 -334
- package/dist/DataGridRow/DataGridRow.js +0 -108
- package/dist/DataGridSorting/sortingUtils.js +0 -234
- package/dist/utilities/classes.js +0 -267
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
@versini/ui-datagrid v0.8.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 })=>{
|
|
24
|
-
return clsx({
|
|
25
|
-
"text-copy-light": mode === "dark",
|
|
26
|
-
"text-copy-dark": mode === "light",
|
|
27
|
-
"text-copy-light dark:text-copy-dark": mode === "system",
|
|
28
|
-
"text-copy-dark dark:text-copy-light": mode === "alt-system"
|
|
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
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Surface background classes (main container backgrounds). Used by: DataGrid
|
|
40
|
-
* wrapper.
|
|
41
|
-
*/ const getSurfaceBackgroundClasses = ({ mode })=>clsx({
|
|
42
|
-
"bg-surface-darker": mode === "dark" || mode === "system",
|
|
43
|
-
"bg-surface-light": mode === "light" || mode === "alt-system",
|
|
44
|
-
"dark:bg-surface-light": mode === "system",
|
|
45
|
-
"dark:bg-surface-darker": mode === "alt-system"
|
|
46
|
-
});
|
|
47
|
-
/**
|
|
48
|
-
* Header/footer background classes (with optional blur transparency). Used by:
|
|
49
|
-
* DataGridHeader, DataGridFooter.
|
|
50
|
-
*/ const getHeaderFooterBackgroundClasses = ({ hasBlur, sticky })=>{
|
|
51
|
-
return clsx({
|
|
52
|
-
// Semi-transparent for blur effect.
|
|
53
|
-
"bg-surface-medium/50 dark:bg-surface-medium/50": hasBlur && sticky,
|
|
54
|
-
// Solid backgrounds.
|
|
55
|
-
"bg-surface-medium-light dark:bg-surface-medium-light": !hasBlur
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Border color classes for rows. Used by: DataGridRow.
|
|
60
|
-
*/ const getBorderClasses = ({ mode })=>clsx({
|
|
61
|
-
"border-table-dark": mode === "dark" || mode === "system",
|
|
62
|
-
"border-table-light": mode === "light" || mode === "alt-system",
|
|
63
|
-
"dark:border-table-light": mode === "system",
|
|
64
|
-
"dark:border-table-dark": mode === "alt-system"
|
|
65
|
-
});
|
|
66
|
-
/**
|
|
67
|
-
* Blur effect classes for sticky elements. Used by: DataGridHeader,
|
|
68
|
-
* DataGridFooter.
|
|
69
|
-
*/ const getBlurClasses = ({ blurEffect })=>clsx({
|
|
70
|
-
"backdrop-blur-sm": blurEffect === BlurEffects.SMALL,
|
|
71
|
-
"backdrop-blur-md": blurEffect === BlurEffects.MEDIUM,
|
|
72
|
-
"backdrop-blur-lg": blurEffect === BlurEffects.LARGE
|
|
73
|
-
});
|
|
74
|
-
/**
|
|
75
|
-
* ============================================================================
|
|
76
|
-
* Composite Class Generators (component-specific combinations)
|
|
77
|
-
* ============================================================================
|
|
78
|
-
*/ /**
|
|
79
|
-
* Loading text classes for loading state.
|
|
80
|
-
*/ const getLoadingTextClasses = ({ mode })=>clsx("text-lg font-medium", {
|
|
81
|
-
"text-copy-dark": mode === "light",
|
|
82
|
-
"text-copy-light": mode === "dark",
|
|
83
|
-
"text-copy-dark dark:text-copy-light": mode === "alt-system",
|
|
84
|
-
"text-copy-light dark:text-copy-dark": mode === "system"
|
|
85
|
-
});
|
|
86
|
-
/**
|
|
87
|
-
* Overlay classes for loading state.
|
|
88
|
-
*/ const getOverlayClasses = ({ mode })=>({
|
|
89
|
-
inner: "relative",
|
|
90
|
-
overlay: clsx("absolute inset-0 z-20 cursor-not-allowed rounded-lg", "backdrop-blur-xs bg-white/30 dark:bg-black/30"),
|
|
91
|
-
loadingWrapper: clsx("absolute z-30 top-0 left-0 right-0 h-[min(100%,100vh)]", "flex items-center justify-center", "pointer-events-none"),
|
|
92
|
-
loadingText: getLoadingTextClasses({
|
|
93
|
-
mode
|
|
94
|
-
})
|
|
95
|
-
});
|
|
96
|
-
/**
|
|
97
|
-
* Generates classes for the main DataGrid wrapper and grid.
|
|
98
|
-
*/ const getDataGridClasses = ({ mode, className, wrapperClassName, stickyHeader, stickyFooter, loading })=>{
|
|
99
|
-
const overlayClasses = loading ? getOverlayClasses({
|
|
100
|
-
mode
|
|
101
|
-
}) : null;
|
|
102
|
-
const hasSticky = stickyHeader || stickyFooter;
|
|
103
|
-
return {
|
|
104
|
-
overlay: overlayClasses?.overlay ?? "",
|
|
105
|
-
inner: overlayClasses?.inner ?? "",
|
|
106
|
-
loadingWrapper: overlayClasses?.loadingWrapper ?? "",
|
|
107
|
-
loadingText: overlayClasses?.loadingText ?? "",
|
|
108
|
-
wrapper: clsx("not-prose relative w-full rounded-lg shadow-md", {
|
|
109
|
-
"overflow-x-auto": !hasSticky && !loading,
|
|
110
|
-
"overflow-hidden flex flex-col": hasSticky || loading
|
|
111
|
-
}, getSurfaceBackgroundClasses({
|
|
112
|
-
mode
|
|
113
|
-
}), getTextColorClasses({
|
|
114
|
-
mode
|
|
115
|
-
}), wrapperClassName),
|
|
116
|
-
scrollableContent: clsx("overflow-y-auto overflow-x-hidden rounded-[inherit] flex-1 min-h-0"),
|
|
117
|
-
grid: clsx("my-0 w-full text-left text-sm grid", className, getTextColorClasses({
|
|
118
|
-
mode
|
|
119
|
-
}))
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Generates classes for the DataGridHeader wrapper.
|
|
124
|
-
*/ const getHeaderClasses = ({ className, stickyHeader, mode, blurEffect })=>{
|
|
125
|
-
const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
|
|
126
|
-
if (!stickyHeader) {
|
|
127
|
-
return clsx("contents", getHeaderFooterBackgroundClasses({
|
|
128
|
-
hasBlur,
|
|
129
|
-
sticky: false
|
|
130
|
-
}), getTextColorClassesForHeaderFooter({
|
|
131
|
-
mode,
|
|
132
|
-
hasBlur
|
|
133
|
-
}), className);
|
|
134
|
-
}
|
|
135
|
-
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({
|
|
136
|
-
hasBlur,
|
|
137
|
-
sticky: true
|
|
138
|
-
}), getTextColorClassesForHeaderFooter({
|
|
139
|
-
mode,
|
|
140
|
-
hasBlur
|
|
141
|
-
}), stickyHeader && getBlurClasses({
|
|
142
|
-
blurEffect
|
|
143
|
-
}), className);
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* Generates classes for the caption element inside DataGridHeader.
|
|
147
|
-
* Needs explicit styling since the parent may use `display: contents`
|
|
148
|
-
* when not sticky, which doesn't render a box and breaks CSS inheritance.
|
|
149
|
-
*/ const getCaptionClasses = ({ captionClassName, mode, hasBlur, stickyHeader })=>{
|
|
150
|
-
/**
|
|
151
|
-
* When sticky, the header wrapper renders a box with background/text colors.
|
|
152
|
-
* When NOT sticky, the header uses `display: contents` so the caption needs
|
|
153
|
-
* its own background and text color styling.
|
|
154
|
-
*/ const needsOwnBackground = !stickyHeader;
|
|
155
|
-
return clsx("py-2 text-sm text-center font-bold col-span-full", getTextColorClassesForHeaderFooter({
|
|
156
|
-
mode,
|
|
157
|
-
hasBlur
|
|
158
|
-
}), needsOwnBackground && getHeaderFooterBackgroundClasses({
|
|
159
|
-
hasBlur,
|
|
160
|
-
sticky: false
|
|
161
|
-
}), captionClassName);
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Generates classes for the DataGridFooter.
|
|
165
|
-
*/ /**
|
|
166
|
-
* Generates classes for the DataGridFooter.
|
|
167
|
-
*/ const getFooterClasses = ({ className, stickyFooter, mode, blurEffect })=>{
|
|
168
|
-
const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
|
|
169
|
-
if (!stickyFooter) {
|
|
170
|
-
return clsx("contents", getTextColorClassesForHeaderFooter({
|
|
171
|
-
mode,
|
|
172
|
-
hasBlur
|
|
173
|
-
}), className);
|
|
174
|
-
}
|
|
175
|
-
return clsx("flex flex-col", "border-t border-table-medium", {
|
|
176
|
-
"absolute left-0 right-0 z-20 bottom-0 rounded-b-lg shadow-[0_-10px_15px_-3px_rgba(0,0,0,0.1)]": stickyFooter
|
|
177
|
-
}, getHeaderFooterBackgroundClasses({
|
|
178
|
-
hasBlur,
|
|
179
|
-
sticky: Boolean(stickyFooter)
|
|
180
|
-
}), stickyFooter && getBlurClasses({
|
|
181
|
-
blurEffect
|
|
182
|
-
}), getTextColorClassesForHeaderFooter({
|
|
183
|
-
mode,
|
|
184
|
-
hasBlur
|
|
185
|
-
}), className);
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Generates classes for DataGridRow. When rowIndex is provided (e.g., from
|
|
189
|
-
* DataGridInfiniteBody), explicit odd/even classes are used instead of CSS
|
|
190
|
-
* :nth-child selectors, which don't work with wrapper elements.
|
|
191
|
-
*/ const getRowClasses = ({ mode, className, cellWrapper, isLastRow, stickyHeader, stickyFooter })=>{
|
|
192
|
-
const layoutClass = "group grid items-center";
|
|
193
|
-
if (cellWrapper === CellWrapper.HEADER || cellWrapper === CellWrapper.FOOTER) {
|
|
194
|
-
/**
|
|
195
|
-
* When not sticky, the parent wrapper uses `display: contents` which
|
|
196
|
-
* doesn't render a box. In this case, we need to apply background and
|
|
197
|
-
* border styling directly to the row.
|
|
198
|
-
*/ const isHeader = cellWrapper === CellWrapper.HEADER;
|
|
199
|
-
const parentUsesContents = isHeader ? !stickyHeader : !stickyFooter;
|
|
200
|
-
if (parentUsesContents) {
|
|
201
|
-
return clsx(layoutClass, getHeaderFooterBackgroundClasses({
|
|
202
|
-
hasBlur: false,
|
|
203
|
-
sticky: false
|
|
204
|
-
}), {
|
|
205
|
-
"border-b border-table-medium shadow-md": isHeader,
|
|
206
|
-
"border-t border-table-medium": !isHeader
|
|
207
|
-
}, className);
|
|
208
|
-
}
|
|
209
|
-
return clsx(layoutClass, className);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Border classes: use explicit border-0 for last row when isLastRow is
|
|
213
|
-
* provided, otherwise fall back to CSS :last-child selector.
|
|
214
|
-
*/ const borderClasses = isLastRow !== undefined ? isLastRow ? "border-b border-b-transparent dark:border-b-transparent" // Last row: transparent border to maintain spacing
|
|
215
|
-
: "border-b" : "border-b last:border-0"; // Fallback to CSS :last-child
|
|
216
|
-
return clsx(layoutClass, borderClasses, "hover:bg-surface-medium hover:text-copy-light", getBorderClasses({
|
|
217
|
-
mode
|
|
218
|
-
}), className);
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Generates classes for DataGridCell.
|
|
222
|
-
*/ const getCellClasses = ({ cellWrapper, className, compact, align, mode, borderLeft, borderRight })=>{
|
|
223
|
-
const isHeader = cellWrapper === CellWrapper.HEADER;
|
|
224
|
-
const isFooter = cellWrapper === CellWrapper.FOOTER;
|
|
225
|
-
return clsx(// Base padding.
|
|
226
|
-
{
|
|
227
|
-
"px-2 py-1": compact,
|
|
228
|
-
"px-4 py-3": !compact
|
|
229
|
-
}, // Text alignment.
|
|
230
|
-
{
|
|
231
|
-
"text-left justify-start": align === "left" || !align,
|
|
232
|
-
"text-center justify-center": align === "center",
|
|
233
|
-
"text-right justify-end": align === "right"
|
|
234
|
-
}, // Header/footer specific styles.
|
|
235
|
-
{
|
|
236
|
-
"font-bold": isHeader || isFooter
|
|
237
|
-
}, // Active row indicator.
|
|
238
|
-
"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.
|
|
239
|
-
{
|
|
240
|
-
"first:group-data-active:before:bg-table-active-dark": mode === "dark",
|
|
241
|
-
"first:group-data-active:before:bg-table-active-light": mode === "light",
|
|
242
|
-
"first:group-data-active:before:bg-table-active-dark dark:first:group-data-active:before:bg-table-active-light": mode === "system",
|
|
243
|
-
"first:group-data-active:before:bg-table-active-light dark:first:group-data-active:before:bg-table-active-dark": mode === "alt-system"
|
|
244
|
-
}, // Vertical borders.
|
|
245
|
-
{
|
|
246
|
-
"self-stretch flex items-center": borderLeft || borderRight,
|
|
247
|
-
"border-l border-l-table-dark": borderLeft && mode === "dark",
|
|
248
|
-
"border-l border-l-table-light": borderLeft && mode === "light",
|
|
249
|
-
"border-l border-l-table-dark dark:border-l-table-light": borderLeft && mode === "system",
|
|
250
|
-
"border-l border-l-table-light dark:border-l-table-dark": borderLeft && mode === "alt-system",
|
|
251
|
-
"border-r border-r-table-dark": borderRight && mode === "dark",
|
|
252
|
-
"border-r border-r-table-light": borderRight && mode === "light",
|
|
253
|
-
"border-r border-r-table-dark dark:border-r-table-light": borderRight && mode === "system",
|
|
254
|
-
"border-r border-r-table-light dark:border-r-table-dark": borderRight && mode === "alt-system"
|
|
255
|
-
}, className);
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* Returns the appropriate ARIA role for the cell based on the cell wrapper
|
|
259
|
-
* type.
|
|
260
|
-
*/ const getCellRole = (cellWrapper)=>{
|
|
261
|
-
if (cellWrapper === CellWrapper.HEADER) {
|
|
262
|
-
return "columnheader";
|
|
263
|
-
}
|
|
264
|
-
return "gridcell";
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
export { getBlurClasses, getBorderClasses, getCaptionClasses, getCellClasses, getCellRole, getDataGridClasses, getFooterClasses, getHeaderClasses, getHeaderFooterBackgroundClasses, getLoadingTextClasses, getOverlayClasses, getRowClasses, getSurfaceBackgroundClasses, getTextColorClasses, getTextColorClassesForHeaderFooter };
|