@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.
Files changed (34) hide show
  1. package/dist/{DataGridBody/useColumnMeasurement.js → 131.js} +14 -7
  2. package/dist/298.js +215 -0
  3. package/dist/{DataGridConstants/DataGridConstants.js → 46.js} +1 -3
  4. package/dist/511.js +9 -0
  5. package/dist/926.js +15 -0
  6. package/dist/DataGrid/index.js +165 -7
  7. package/dist/DataGridAnimated/index.js +159 -6
  8. package/dist/DataGridBody/index.js +33 -4
  9. package/dist/DataGridCell/index.js +37 -4
  10. package/dist/DataGridCellSort/index.js +138 -4
  11. package/dist/DataGridConstants/index.js +2 -6
  12. package/dist/DataGridFooter/index.js +79 -4
  13. package/dist/DataGridHeader/index.js +110 -4
  14. package/dist/DataGridInfinite/index.js +312 -4
  15. package/dist/DataGridRow/index.js +89 -4
  16. package/dist/DataGridSorting/index.js +225 -7
  17. package/dist/utilities/classes.d.ts +7 -29
  18. package/package.json +3 -3
  19. package/dist/DataGrid/DataGrid.js +0 -183
  20. package/dist/DataGrid/DataGridContext.js +0 -16
  21. package/dist/DataGrid/DataGridTypes.js +0 -9
  22. package/dist/DataGridAnimated/AnimatedWrapper.js +0 -53
  23. package/dist/DataGridAnimated/useAnimatedHeight.js +0 -131
  24. package/dist/DataGridBody/DataGridBody.js +0 -55
  25. package/dist/DataGridBody/getBodyClass.js +0 -23
  26. package/dist/DataGridCell/DataGridCell.js +0 -51
  27. package/dist/DataGridCellSort/ButtonSort.js +0 -67
  28. package/dist/DataGridCellSort/DataGridCellSort.js +0 -111
  29. package/dist/DataGridFooter/DataGridFooter.js +0 -98
  30. package/dist/DataGridHeader/DataGridHeader.js +0 -129
  31. package/dist/DataGridInfinite/DataGridInfiniteBody.js +0 -334
  32. package/dist/DataGridRow/DataGridRow.js +0 -108
  33. package/dist/DataGridSorting/sortingUtils.js +0 -234
  34. package/dist/utilities/classes.js +0 -267
@@ -1,13 +1,42 @@
1
1
  /*!
2
- @versini/ui-datagrid v0.8.0
2
+ @versini/ui-datagrid v0.8.2
3
3
  © 2026 gizmette.com
4
4
  */
5
5
 
6
- import { DataGridBody } from "./DataGridBody.js";
6
+ import { useRef, useContext, jsx } from "../511.js";
7
+ import { DataGridContext } from "../926.js";
8
+ import { getBodyClass, useColumnMeasurement } from "../131.js";
9
+ import { CellWrapper } from "../46.js";
7
10
 
8
- ;// CONCATENATED MODULE: external "./DataGridBody.js"
9
11
 
10
- ;// CONCATENATED MODULE: ./src/DataGridBody/index.ts
12
+
13
+
14
+
15
+
16
+
17
+ /* =============================================================================
18
+ * DataGridBody
19
+ * ========================================================================== */ const DataGridBody = ({ className, children, ...rest })=>{
20
+ const ctx = useContext(DataGridContext);
21
+ const bodyRef = useRef(null);
22
+ // Measure column widths for sticky header/footer sync.
23
+ useColumnMeasurement(bodyRef, children);
24
+ const bodyClass = getBodyClass(className);
25
+ return /*#__PURE__*/ jsx(DataGridContext.Provider, {
26
+ value: {
27
+ ...ctx,
28
+ cellWrapper: CellWrapper.BODY
29
+ },
30
+ children: /*#__PURE__*/ jsx("div", {
31
+ ref: bodyRef,
32
+ role: "rowgroup",
33
+ className: bodyClass,
34
+ ...rest,
35
+ children: children
36
+ })
37
+ });
38
+ };
39
+
11
40
 
12
41
 
13
42
  export { DataGridBody };
@@ -1,13 +1,46 @@
1
1
  /*!
2
- @versini/ui-datagrid v0.8.0
2
+ @versini/ui-datagrid v0.8.2
3
3
  © 2026 gizmette.com
4
4
  */
5
5
 
6
- import { DataGridCell } from "./DataGridCell.js";
6
+ import { jsx } from "../511.js";
7
+ import { DataGridContext } from "../926.js";
8
+ import { getCellRole, getCellClasses } from "../298.js";
7
9
 
8
- ;// CONCATENATED MODULE: external "./DataGridCell.js"
9
10
 
10
- ;// CONCATENATED MODULE: ./src/DataGridCell/index.ts
11
+
12
+
13
+ /* =============================================================================
14
+ * DataGridCell
15
+ * ========================================================================== */ const DataGridCell = ({ className, children, align, borderLeft, borderRight, colSpan, style, ...rest })=>{
16
+ return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
17
+ children: ({ mode, compact, cellWrapper })=>{
18
+ const mainClasses = getCellClasses({
19
+ cellWrapper,
20
+ className,
21
+ mode,
22
+ compact,
23
+ align,
24
+ borderLeft,
25
+ borderRight
26
+ });
27
+ const role = getCellRole(cellWrapper);
28
+ // Apply grid-column span for colSpan > 1.
29
+ const cellStyle = colSpan && colSpan > 1 ? {
30
+ ...style,
31
+ gridColumn: `span ${colSpan}`
32
+ } : style;
33
+ return /*#__PURE__*/ jsx("div", {
34
+ role: role,
35
+ className: mainClasses,
36
+ style: cellStyle,
37
+ ...rest,
38
+ children: children
39
+ });
40
+ }
41
+ });
42
+ };
43
+
11
44
 
12
45
 
13
46
  export { DataGridCell };
@@ -1,13 +1,147 @@
1
1
  /*!
2
- @versini/ui-datagrid v0.8.0
2
+ @versini/ui-datagrid v0.8.2
3
3
  © 2026 gizmette.com
4
4
  */
5
5
 
6
- import { DataGridCellSort } from "./DataGridCellSort.js";
6
+ import { IconSort, IconSortDown, IconSortUp } from "@versini/ui-icons";
7
+ import { jsxs, jsx } from "../511.js";
8
+ import { DataGridContext, clsx } from "../926.js";
9
+ import { BlurEffects } from "../46.js";
10
+ import { getCellClasses, getTextColorClassesForHeaderFooter } from "../298.js";
7
11
 
8
- ;// CONCATENATED MODULE: external "./DataGridCellSort.js"
9
12
 
10
- ;// CONCATENATED MODULE: ./src/DataGridCellSort/index.ts
13
+
14
+
15
+
16
+
17
+ const getActiveIndicatorClasses = (active)=>{
18
+ if (!active) {
19
+ return "";
20
+ }
21
+ return clsx("relative", "focus-within:static", "focus-within:after:border-transparent", "after:absolute", "after:content-['']", "after:border-b-2", "after:-bottom-1", "after:left-0", "after:right-0", // the small border at the bottom of the button when it is active (sorted)
22
+ "after:border-table-light");
23
+ };
24
+ const ButtonSort = ({ active = false, className, onClick, labelRight, children, blurEffect, mode })=>{
25
+ const hasBlur = Boolean(blurEffect && blurEffect !== BlurEffects.NONE);
26
+ const buttonClasses = clsx(// Base styles
27
+ "flex items-center cursor-pointer", // Size - small
28
+ "h-6 px-1 sm:px-2", // Font
29
+ "text-sm font-bold", // Radius - small
30
+ "rounded-xs", // Text color
31
+ getTextColorClassesForHeaderFooter({
32
+ mode,
33
+ hasBlur
34
+ }), // Focus styles
35
+ "focus:outline", "focus:outline-2", "focus:outline-offset-2", "focus:outline-focus-medium", // Hover styles
36
+ "hover:text-copy-light-hover", "hover:bg-action-darker-hover", // Active styles
37
+ "active:text-copy-medium-active", "active:bg-action-dark-active", // Custom className
38
+ className);
39
+ const wrapperClasses = getActiveIndicatorClasses(active);
40
+ return /*#__PURE__*/ jsx("div", {
41
+ className: wrapperClasses,
42
+ children: /*#__PURE__*/ jsxs("button", {
43
+ className: buttonClasses,
44
+ type: "button",
45
+ onClick: onClick,
46
+ children: [
47
+ /*#__PURE__*/ jsx("span", {
48
+ className: "text-copy-light",
49
+ children: children
50
+ }),
51
+ labelRight && /*#__PURE__*/ jsx("span", {
52
+ className: "pl-2",
53
+ children: labelRight
54
+ })
55
+ ]
56
+ })
57
+ });
58
+ };
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+ /* =============================================================================
67
+ * DataGridCellSort
68
+ * ========================================================================== */ const DataGridCellSort = ({ className, children, cellId, onSort, sortDirection, sortedCell, slotLeft, slotRight, buttonClassName, align, ...rest })=>{
69
+ const isSorted = sortedCell === cellId;
70
+ const handleSort = ()=>{
71
+ if (onSort) {
72
+ // Convert false to undefined for the callback.
73
+ const currentDirection = isSorted && sortDirection ? sortDirection : undefined;
74
+ onSort(cellId, currentDirection);
75
+ }
76
+ };
77
+ const getSortIcon = ()=>{
78
+ if (isSorted && sortDirection === "asc") {
79
+ return /*#__PURE__*/ jsx(IconSortUp, {
80
+ size: "size-4",
81
+ monotone: true
82
+ });
83
+ }
84
+ if (isSorted && sortDirection === "desc") {
85
+ return /*#__PURE__*/ jsx(IconSortDown, {
86
+ size: "size-4",
87
+ monotone: true
88
+ });
89
+ }
90
+ return /*#__PURE__*/ jsx(IconSort, {
91
+ size: "size-4",
92
+ monotone: true
93
+ });
94
+ };
95
+ const getAriaSort = ()=>{
96
+ if (isSorted && sortDirection === "asc") {
97
+ return "ascending";
98
+ }
99
+ if (isSorted && sortDirection === "desc") {
100
+ return "descending";
101
+ }
102
+ return "other";
103
+ };
104
+ return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
105
+ children: ({ mode, compact, cellWrapper, blurEffect })=>{
106
+ const mainClasses = getCellClasses({
107
+ cellWrapper,
108
+ className,
109
+ mode,
110
+ compact,
111
+ align
112
+ });
113
+ // Flex container for alignment of button within the cell.
114
+ const contentClasses = clsx("flex", {
115
+ "justify-start": align === "left" || !align,
116
+ "justify-center": align === "center",
117
+ "justify-end": align === "right"
118
+ });
119
+ return /*#__PURE__*/ jsx("div", {
120
+ className: mainClasses,
121
+ role: "columnheader",
122
+ "aria-sort": getAriaSort(),
123
+ ...rest,
124
+ children: /*#__PURE__*/ jsxs("div", {
125
+ className: contentClasses,
126
+ children: [
127
+ slotLeft,
128
+ /*#__PURE__*/ jsx(ButtonSort, {
129
+ mode: mode,
130
+ blurEffect: blurEffect,
131
+ active: isSorted,
132
+ className: buttonClassName,
133
+ onClick: handleSort,
134
+ labelRight: children,
135
+ children: getSortIcon()
136
+ }),
137
+ slotRight
138
+ ]
139
+ })
140
+ });
141
+ }
142
+ });
143
+ };
144
+
11
145
 
12
146
 
13
147
  export { DataGridCellSort };
@@ -1,13 +1,9 @@
1
1
  /*!
2
- @versini/ui-datagrid v0.8.0
2
+ @versini/ui-datagrid v0.8.2
3
3
  © 2026 gizmette.com
4
4
  */
5
5
 
6
- import { BlurEffects, CellWrapper, SortDirections, ThemeModes } from "./DataGridConstants.js";
7
6
 
8
- ;// CONCATENATED MODULE: external "./DataGridConstants.js"
9
7
 
10
- ;// CONCATENATED MODULE: ./src/DataGridConstants/index.ts
11
8
 
12
-
13
- export { BlurEffects, CellWrapper, SortDirections, ThemeModes };
9
+ export { BlurEffects, CellWrapper, SortDirections, ThemeModes } from "../46.js";
@@ -1,13 +1,88 @@
1
1
  /*!
2
- @versini/ui-datagrid v0.8.0
2
+ @versini/ui-datagrid v0.8.2
3
3
  © 2026 gizmette.com
4
4
  */
5
5
 
6
- import { DataGridFooter } from "./DataGridFooter.js";
6
+ import { useLayoutEffect, useRef, useEffect, jsx } from "../511.js";
7
+ import { DataGridContext } from "../926.js";
8
+ import { CellWrapper } from "../46.js";
9
+ import { getFooterClasses } from "../298.js";
7
10
 
8
- ;// CONCATENATED MODULE: external "./DataGridFooter.js"
9
11
 
10
- ;// CONCATENATED MODULE: ./src/DataGridFooter/index.ts
12
+
13
+
14
+
15
+
16
+ /* =============================================================================
17
+ * DataGridFooter
18
+ * ========================================================================== */ const DataGridFooter = ({ className, children, ...rest })=>{
19
+ return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
20
+ children: (ctx)=>/*#__PURE__*/ jsx(DataGridFooterInner, {
21
+ className: className,
22
+ ctx: ctx,
23
+ ...rest,
24
+ children: children
25
+ })
26
+ });
27
+ };
28
+ DataGridFooter.displayName = "DataGridFooter";
29
+ /**
30
+ * Inner component to handle the useEffect for registering footer. Separated to
31
+ * avoid hooks inside Consumer render prop.
32
+ */ const DataGridFooterInner = ({ className, ctx, children, ...rest })=>{
33
+ const footerRef = useRef(null);
34
+ /**
35
+ * Register this footer with the parent DataGrid on mount. This enables sticky
36
+ * footer behavior regardless of nesting depth.
37
+ */ useEffect(()=>{
38
+ ctx.registerFooter?.();
39
+ return ()=>{
40
+ ctx.unregisterFooter?.();
41
+ };
42
+ }, [
43
+ ctx.registerFooter,
44
+ ctx.unregisterFooter
45
+ ]);
46
+ /**
47
+ * Measure and report footer height for dynamic padding calculation. Uses
48
+ * ResizeObserver to handle dynamic content changes.
49
+ */ useLayoutEffect(()=>{
50
+ const element = footerRef.current;
51
+ if (!element || !ctx.stickyFooter || !ctx.setFooterHeight) {
52
+ return;
53
+ }
54
+ const observer = new ResizeObserver((entries)=>{
55
+ const height = entries[0]?.borderBoxSize?.[0]?.blockSize;
56
+ if (height !== undefined) {
57
+ ctx.setFooterHeight?.(height);
58
+ }
59
+ });
60
+ observer.observe(element);
61
+ return ()=>observer.disconnect();
62
+ }, [
63
+ ctx.stickyFooter,
64
+ ctx.setFooterHeight
65
+ ]);
66
+ return /*#__PURE__*/ jsx(DataGridContext.Provider, {
67
+ value: {
68
+ ...ctx,
69
+ cellWrapper: CellWrapper.FOOTER
70
+ },
71
+ children: /*#__PURE__*/ jsx("div", {
72
+ ref: footerRef,
73
+ role: "rowgroup",
74
+ className: getFooterClasses({
75
+ className,
76
+ stickyFooter: ctx.stickyFooter,
77
+ mode: ctx.mode,
78
+ blurEffect: ctx.blurEffect
79
+ }),
80
+ ...rest,
81
+ children: children
82
+ })
83
+ });
84
+ };
85
+
11
86
 
12
87
 
13
88
  export { DataGridFooter };
@@ -1,13 +1,119 @@
1
1
  /*!
2
- @versini/ui-datagrid v0.8.0
2
+ @versini/ui-datagrid v0.8.2
3
3
  © 2026 gizmette.com
4
4
  */
5
5
 
6
- import { DataGridHeader } from "./DataGridHeader.js";
6
+ import { jsxs, useLayoutEffect, useId, useRef, useEffect, jsx } from "../511.js";
7
+ import { DataGridContext } from "../926.js";
8
+ import { CellWrapper } from "../46.js";
9
+ import { getCaptionClasses, getHeaderClasses } from "../298.js";
7
10
 
8
- ;// CONCATENATED MODULE: external "./DataGridHeader.js"
9
11
 
10
- ;// CONCATENATED MODULE: ./src/DataGridHeader/index.ts
12
+
13
+
14
+
15
+
16
+ /* =============================================================================
17
+ * DataGridHeader
18
+ * ========================================================================== */ const DataGridHeader = ({ caption, captionClassName, className, children, ...rest })=>{
19
+ const captionId = useId();
20
+ return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
21
+ children: (ctx)=>/*#__PURE__*/ jsx(DataGridHeaderInner, {
22
+ caption: caption,
23
+ captionClassName: captionClassName,
24
+ captionId: captionId,
25
+ className: className,
26
+ ctx: ctx,
27
+ ...rest,
28
+ children: children
29
+ })
30
+ });
31
+ };
32
+ DataGridHeader.displayName = "DataGridHeader";
33
+ /**
34
+ * Inner component to handle the useEffect for registering captionId and header.
35
+ * Separated to avoid hooks inside Consumer render prop.
36
+ */ const DataGridHeaderInner = ({ caption, captionClassName, captionId, className, ctx, children, ...rest })=>{
37
+ const headerRef = useRef(null);
38
+ /**
39
+ * Register this header with the parent DataGrid on mount. This enables sticky
40
+ * header behavior regardless of nesting depth.
41
+ */ useEffect(()=>{
42
+ ctx.registerHeader?.();
43
+ return ()=>{
44
+ ctx.unregisterHeader?.();
45
+ };
46
+ }, [
47
+ ctx.registerHeader,
48
+ ctx.unregisterHeader
49
+ ]);
50
+ // Register the caption ID with the parent DataGrid for aria-labelledby.
51
+ useEffect(()=>{
52
+ if (caption && ctx.setCaptionId) {
53
+ ctx.setCaptionId(captionId);
54
+ }
55
+ return ()=>{
56
+ if (ctx.setCaptionId) {
57
+ ctx.setCaptionId(undefined);
58
+ }
59
+ };
60
+ }, [
61
+ caption,
62
+ captionId,
63
+ ctx.setCaptionId
64
+ ]);
65
+ /**
66
+ * Measure and report header height for dynamic padding calculation. Uses
67
+ * ResizeObserver to handle dynamic content changes (text wrapping, etc.).
68
+ */ useLayoutEffect(()=>{
69
+ const element = headerRef.current;
70
+ if (!element || !ctx.stickyHeader || !ctx.setHeaderHeight) {
71
+ return;
72
+ }
73
+ const observer = new ResizeObserver((entries)=>{
74
+ const height = entries[0]?.borderBoxSize?.[0]?.blockSize;
75
+ if (height !== undefined) {
76
+ ctx.setHeaderHeight?.(height);
77
+ }
78
+ });
79
+ observer.observe(element);
80
+ return ()=>observer.disconnect();
81
+ }, [
82
+ ctx.stickyHeader,
83
+ ctx.setHeaderHeight
84
+ ]);
85
+ return /*#__PURE__*/ jsx(DataGridContext.Provider, {
86
+ value: {
87
+ ...ctx,
88
+ cellWrapper: CellWrapper.HEADER
89
+ },
90
+ children: /*#__PURE__*/ jsxs("div", {
91
+ ref: headerRef,
92
+ role: "rowgroup",
93
+ className: getHeaderClasses({
94
+ className,
95
+ stickyHeader: ctx.stickyHeader,
96
+ mode: ctx.mode,
97
+ blurEffect: ctx.blurEffect
98
+ }),
99
+ ...rest,
100
+ children: [
101
+ caption && /*#__PURE__*/ jsx("div", {
102
+ id: captionId,
103
+ className: getCaptionClasses({
104
+ captionClassName,
105
+ mode: ctx.mode,
106
+ hasBlur: Boolean(ctx.blurEffect && ctx.blurEffect !== "none"),
107
+ stickyHeader: Boolean(ctx.stickyHeader)
108
+ }),
109
+ children: caption
110
+ }),
111
+ children
112
+ ]
113
+ })
114
+ });
115
+ };
116
+
11
117
 
12
118
 
13
119
  export { DataGridHeader };