@versini/ui-datagrid 0.1.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/LICENSE +21 -0
- package/README.md +294 -0
- package/dist/DataGrid/DataGrid.d.ts +2 -0
- package/dist/DataGrid/DataGrid.js +132 -0
- package/dist/DataGrid/DataGridContext.d.ts +2 -0
- package/dist/DataGrid/DataGridContext.js +16 -0
- package/dist/DataGrid/index.d.ts +2 -0
- package/dist/DataGrid/index.js +17 -0
- package/dist/DataGrid/utilities.d.ts +36 -0
- package/dist/DataGrid/utilities.js +99 -0
- package/dist/DataGridAnimated/AnimatedWrapper.d.ts +47 -0
- package/dist/DataGridAnimated/AnimatedWrapper.js +49 -0
- package/dist/DataGridAnimated/index.d.ts +4 -0
- package/dist/DataGridAnimated/index.js +17 -0
- package/dist/DataGridAnimated/useAnimatedHeight.d.ts +49 -0
- package/dist/DataGridAnimated/useAnimatedHeight.js +131 -0
- package/dist/DataGridBody/DataGridBody.d.ts +2 -0
- package/dist/DataGridBody/DataGridBody.js +38 -0
- package/dist/DataGridBody/index.d.ts +1 -0
- package/dist/DataGridBody/index.js +13 -0
- package/dist/DataGridCell/DataGridCell.d.ts +14 -0
- package/dist/DataGridCell/DataGridCell.js +77 -0
- package/dist/DataGridCell/index.d.ts +1 -0
- package/dist/DataGridCell/index.js +13 -0
- package/dist/DataGridCellSort/DataGridCellSort.d.ts +2 -0
- package/dist/DataGridCellSort/DataGridCellSort.js +107 -0
- package/dist/DataGridCellSort/index.d.ts +1 -0
- package/dist/DataGridCellSort/index.js +13 -0
- package/dist/DataGridConstants/DataGridConstants.d.ts +37 -0
- package/dist/DataGridConstants/DataGridConstants.js +38 -0
- package/dist/DataGridConstants/index.d.ts +1 -0
- package/dist/DataGridConstants/index.js +13 -0
- package/dist/DataGridFooter/DataGridFooter.d.ts +12 -0
- package/dist/DataGridFooter/DataGridFooter.js +81 -0
- package/dist/DataGridFooter/index.d.ts +1 -0
- package/dist/DataGridFooter/index.js +13 -0
- package/dist/DataGridHeader/DataGridHeader.d.ts +13 -0
- package/dist/DataGridHeader/DataGridHeader.js +80 -0
- package/dist/DataGridHeader/index.d.ts +1 -0
- package/dist/DataGridHeader/index.js +13 -0
- package/dist/DataGridInfinite/InfiniteScrollMarker.d.ts +35 -0
- package/dist/DataGridInfinite/InfiniteScrollMarker.js +53 -0
- package/dist/DataGridInfinite/index.d.ts +4 -0
- package/dist/DataGridInfinite/index.js +17 -0
- package/dist/DataGridInfinite/useInfiniteScroll.d.ts +81 -0
- package/dist/DataGridInfinite/useInfiniteScroll.js +117 -0
- package/dist/DataGridRow/DataGridRow.d.ts +2 -0
- package/dist/DataGridRow/DataGridRow.js +75 -0
- package/dist/DataGridRow/index.d.ts +1 -0
- package/dist/DataGridRow/index.js +13 -0
- package/dist/DataGridSorting/index.d.ts +2 -0
- package/dist/DataGridSorting/index.js +18 -0
- package/dist/DataGridSorting/sortingUtils.d.ts +138 -0
- package/dist/DataGridSorting/sortingUtils.js +234 -0
- package/dist/DataGridVirtual/VirtualDataGrid.d.ts +114 -0
- package/dist/DataGridVirtual/VirtualDataGrid.js +181 -0
- package/dist/DataGridVirtual/index.d.ts +6 -0
- package/dist/DataGridVirtual/index.js +22 -0
- package/dist/DataGridVirtual/useVirtualDataGrid.d.ts +112 -0
- package/dist/DataGridVirtual/useVirtualDataGrid.js +89 -0
- package/package.json +103 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useAnimatedHeight } from "./useAnimatedHeight.js";
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "./useAnimatedHeight.js"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: ./src/DataGridAnimated/AnimatedWrapper.tsx
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper component that animates height changes when content changes.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { visibleCount } = useInfiniteScroll({ totalItems: data.length });
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <AnimatedWrapper dependency={visibleCount}>
|
|
25
|
+
* <DataGrid>
|
|
26
|
+
* <DataGridBody>
|
|
27
|
+
* {data.slice(0, visibleCount).map((item) => (
|
|
28
|
+
* <DataGridRow key={item.id}>...</DataGridRow>
|
|
29
|
+
* ))}
|
|
30
|
+
* </DataGridBody>
|
|
31
|
+
* </DataGrid>
|
|
32
|
+
* </AnimatedWrapper>
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
*/ const AnimatedWrapper = ({ children, dependency, duration, enabled = true, className })=>{
|
|
37
|
+
const { ref, style } = useAnimatedHeight(dependency, {
|
|
38
|
+
duration,
|
|
39
|
+
enabled
|
|
40
|
+
});
|
|
41
|
+
return /*#__PURE__*/ jsx("div", {
|
|
42
|
+
ref: ref,
|
|
43
|
+
style: style,
|
|
44
|
+
className: className,
|
|
45
|
+
children: children
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { AnimatedWrapper };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AnimatedWrapper } from "./AnimatedWrapper.js";
|
|
7
|
+
import { useAnimatedHeight } from "./useAnimatedHeight.js";
|
|
8
|
+
|
|
9
|
+
;// CONCATENATED MODULE: external "./AnimatedWrapper.js"
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "./useAnimatedHeight.js"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: ./src/DataGridAnimated/index.ts
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export { AnimatedWrapper, useAnimatedHeight };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type UseAnimatedHeightOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Animation duration in milliseconds.
|
|
4
|
+
* @default 300
|
|
5
|
+
*/
|
|
6
|
+
duration?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Whether animation is enabled.
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type UseAnimatedHeightReturn<T extends HTMLElement> = {
|
|
14
|
+
/**
|
|
15
|
+
* Ref to attach to the container element.
|
|
16
|
+
*/
|
|
17
|
+
ref: React.RefObject<T | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Style object to apply to the container.
|
|
20
|
+
*/
|
|
21
|
+
style: React.CSSProperties;
|
|
22
|
+
/**
|
|
23
|
+
* Whether an animation is currently in progress.
|
|
24
|
+
*/
|
|
25
|
+
isAnimating: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Hook that provides smooth height animations when content changes.
|
|
29
|
+
*
|
|
30
|
+
* Uses FLIP technique: captures height before render via a persistent ref, then
|
|
31
|
+
* animates from old height to new height after the DOM updates.
|
|
32
|
+
*
|
|
33
|
+
* @param dependency - Value that triggers animation when changed.
|
|
34
|
+
* @param options - Configuration options.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const items = useMemo(() => data.slice(0, visibleCount), [data, visibleCount]);
|
|
39
|
+
* const { ref, style } = useAnimatedHeight(items.length);
|
|
40
|
+
*
|
|
41
|
+
* return (
|
|
42
|
+
* <div ref={ref} style={style}>
|
|
43
|
+
* {items.map((item) => <Row key={item.id} {...item} />)}
|
|
44
|
+
* </div>
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export declare function useAnimatedHeight<T, E extends HTMLElement = HTMLDivElement>(dependency: T, options?: UseAnimatedHeightOptions): UseAnimatedHeightReturn<E>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "react"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: ./src/DataGridAnimated/useAnimatedHeight.ts
|
|
11
|
+
|
|
12
|
+
const DEFAULT_ANIMATION_DURATION = 300;
|
|
13
|
+
/**
|
|
14
|
+
* Hook that provides smooth height animations when content changes.
|
|
15
|
+
*
|
|
16
|
+
* Uses FLIP technique: captures height before render via a persistent ref, then
|
|
17
|
+
* animates from old height to new height after the DOM updates.
|
|
18
|
+
*
|
|
19
|
+
* @param dependency - Value that triggers animation when changed.
|
|
20
|
+
* @param options - Configuration options.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const items = useMemo(() => data.slice(0, visibleCount), [data, visibleCount]);
|
|
25
|
+
* const { ref, style } = useAnimatedHeight(items.length);
|
|
26
|
+
*
|
|
27
|
+
* return (
|
|
28
|
+
* <div ref={ref} style={style}>
|
|
29
|
+
* {items.map((item) => <Row key={item.id} {...item} />)}
|
|
30
|
+
* </div>
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
*/ function useAnimatedHeight(dependency, options) {
|
|
35
|
+
const { duration = DEFAULT_ANIMATION_DURATION, enabled = true } = options ?? {};
|
|
36
|
+
const ref = useRef(null);
|
|
37
|
+
const [animationState, setAnimationState] = useState({
|
|
38
|
+
height: "auto",
|
|
39
|
+
isAnimating: false
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Track the last measured height persistently. This ref is updated AFTER each
|
|
43
|
+
* animation completes, so it holds the "before" value when dependency changes.
|
|
44
|
+
*/ const lastHeightRef = useRef(0);
|
|
45
|
+
const prevDependencyRef = useRef(dependency);
|
|
46
|
+
const animationFrameRef = useRef(0);
|
|
47
|
+
const timeoutRef = useRef(null);
|
|
48
|
+
useLayoutEffect(()=>{
|
|
49
|
+
if (!ref.current || !enabled) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* On first render or when not animating, just record the current height.
|
|
54
|
+
*/ if (lastHeightRef.current === 0) {
|
|
55
|
+
lastHeightRef.current = ref.current.offsetHeight;
|
|
56
|
+
prevDependencyRef.current = dependency;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* If dependency hasn't changed, nothing to animate.
|
|
61
|
+
*/ if (prevDependencyRef.current === dependency) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
prevDependencyRef.current = dependency;
|
|
65
|
+
const previousHeight = lastHeightRef.current;
|
|
66
|
+
const newHeight = ref.current.scrollHeight;
|
|
67
|
+
/**
|
|
68
|
+
* Update the stored height for next time.
|
|
69
|
+
*/ lastHeightRef.current = newHeight;
|
|
70
|
+
/**
|
|
71
|
+
* If heights are the same or previous was 0, no animation needed.
|
|
72
|
+
*/ if (previousHeight === newHeight || previousHeight === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Cancel any ongoing animation.
|
|
77
|
+
*/ if (timeoutRef.current) {
|
|
78
|
+
clearTimeout(timeoutRef.current);
|
|
79
|
+
}
|
|
80
|
+
if (animationFrameRef.current) {
|
|
81
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Lock to the previous height immediately.
|
|
85
|
+
*/ setAnimationState({
|
|
86
|
+
height: previousHeight,
|
|
87
|
+
isAnimating: true
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Use double RAF to ensure the browser has painted the locked height, then
|
|
91
|
+
* transition to the new height.
|
|
92
|
+
*/ animationFrameRef.current = requestAnimationFrame(()=>{
|
|
93
|
+
animationFrameRef.current = requestAnimationFrame(()=>{
|
|
94
|
+
setAnimationState({
|
|
95
|
+
height: newHeight,
|
|
96
|
+
isAnimating: true
|
|
97
|
+
});
|
|
98
|
+
timeoutRef.current = setTimeout(()=>{
|
|
99
|
+
setAnimationState({
|
|
100
|
+
height: "auto",
|
|
101
|
+
isAnimating: false
|
|
102
|
+
});
|
|
103
|
+
}, duration);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return ()=>{
|
|
107
|
+
if (timeoutRef.current) {
|
|
108
|
+
clearTimeout(timeoutRef.current);
|
|
109
|
+
}
|
|
110
|
+
if (animationFrameRef.current) {
|
|
111
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}, [
|
|
115
|
+
dependency,
|
|
116
|
+
duration,
|
|
117
|
+
enabled
|
|
118
|
+
]);
|
|
119
|
+
const style = enabled ? {
|
|
120
|
+
height: animationState.height === "auto" ? "auto" : `${animationState.height}px`,
|
|
121
|
+
overflow: animationState.isAnimating ? "hidden" : undefined,
|
|
122
|
+
transition: animationState.isAnimating ? `height ${duration}ms ease-out` : undefined
|
|
123
|
+
} : {};
|
|
124
|
+
return {
|
|
125
|
+
ref,
|
|
126
|
+
style,
|
|
127
|
+
isAnimating: animationState.isAnimating
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { useAnimatedHeight };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { DataGridContext } from "../DataGrid/DataGridContext.js";
|
|
8
|
+
import { CellWrapper } from "../DataGridConstants/index.js";
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "../DataGrid/DataGridContext.js"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: external "../DataGridConstants/index.js"
|
|
15
|
+
|
|
16
|
+
;// CONCATENATED MODULE: ./src/DataGridBody/DataGridBody.tsx
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/* =============================================================================
|
|
21
|
+
* DataGridBody
|
|
22
|
+
* ========================================================================== */ const DataGridBody = ({ className, children, ...rest })=>{
|
|
23
|
+
return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
|
|
24
|
+
children: (ctx)=>/*#__PURE__*/ jsx(DataGridContext.Provider, {
|
|
25
|
+
value: {
|
|
26
|
+
...ctx,
|
|
27
|
+
cellWrapper: CellWrapper.BODY
|
|
28
|
+
},
|
|
29
|
+
children: /*#__PURE__*/ jsx("tbody", {
|
|
30
|
+
className: className,
|
|
31
|
+
...rest,
|
|
32
|
+
children: children
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { DataGridBody };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataGridBody } from "./DataGridBody";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DataGridBody } from "./DataGridBody.js";
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "./DataGridBody.js"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: ./src/DataGridBody/index.ts
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export { DataGridBody };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DataGridCellProps } from "../DataGrid/DataGridTypes";
|
|
2
|
+
import { type CellWrapperType, type ThemeMode } from "../DataGridConstants";
|
|
3
|
+
export declare const getCellClasses: ({ cellWrapper, className, compact, align, active, mode, }: {
|
|
4
|
+
cellWrapper?: CellWrapperType;
|
|
5
|
+
className?: string;
|
|
6
|
+
mode?: ThemeMode;
|
|
7
|
+
compact?: boolean;
|
|
8
|
+
align?: "left" | "center" | "right";
|
|
9
|
+
active?: boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
mainClasses: string;
|
|
12
|
+
alignClasses: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const DataGridCell: ({ className, children, align, active, component, ...rest }: DataGridCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { DataGridContext } from "../DataGrid/DataGridContext.js";
|
|
9
|
+
import { CellWrapper } from "../DataGridConstants/index.js";
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: external "clsx"
|
|
14
|
+
|
|
15
|
+
;// CONCATENATED MODULE: external "../DataGrid/DataGridContext.js"
|
|
16
|
+
|
|
17
|
+
;// CONCATENATED MODULE: external "../DataGridConstants/index.js"
|
|
18
|
+
|
|
19
|
+
;// CONCATENATED MODULE: ./src/DataGridCell/DataGridCell.tsx
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const getCellClasses = ({ cellWrapper, className, compact, align, active, mode })=>{
|
|
25
|
+
const isHeader = cellWrapper === CellWrapper.HEADER;
|
|
26
|
+
const mainClasses = clsx(// Base padding.
|
|
27
|
+
{
|
|
28
|
+
"px-2 py-1": compact,
|
|
29
|
+
"px-4 py-3": !compact
|
|
30
|
+
}, // Header/footer specific styles.
|
|
31
|
+
{
|
|
32
|
+
"font-semibold": isHeader
|
|
33
|
+
}, // Active row indicator (left border on first cell).
|
|
34
|
+
{
|
|
35
|
+
"relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1": active,
|
|
36
|
+
"before:bg-table-active-dark": active && mode === "dark",
|
|
37
|
+
"before:bg-table-active-light": active && mode === "light",
|
|
38
|
+
"before:bg-table-active-dark dark:before:bg-table-active-light": active && mode === "system",
|
|
39
|
+
"before:bg-table-active-light dark:before:bg-table-active-dark": active && mode === "alt-system"
|
|
40
|
+
}, className);
|
|
41
|
+
const alignClasses = clsx("flex", {
|
|
42
|
+
"justify-start": align === "left" || !align,
|
|
43
|
+
"justify-center": align === "center",
|
|
44
|
+
"justify-end": align === "right"
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
mainClasses,
|
|
48
|
+
alignClasses
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/* =============================================================================
|
|
52
|
+
* DataGridCell
|
|
53
|
+
* ========================================================================== */ const DataGridCell = ({ className, children, align, active, component, ...rest })=>{
|
|
54
|
+
return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
|
|
55
|
+
children: ({ mode, compact, cellWrapper })=>{
|
|
56
|
+
const { mainClasses, alignClasses } = getCellClasses({
|
|
57
|
+
cellWrapper,
|
|
58
|
+
className,
|
|
59
|
+
mode,
|
|
60
|
+
compact,
|
|
61
|
+
align,
|
|
62
|
+
active
|
|
63
|
+
});
|
|
64
|
+
const Component = component || (cellWrapper === CellWrapper.HEADER || cellWrapper === CellWrapper.FOOTER ? "th" : "td");
|
|
65
|
+
return /*#__PURE__*/ jsx(Component, {
|
|
66
|
+
className: mainClasses,
|
|
67
|
+
...rest,
|
|
68
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
69
|
+
className: alignClasses,
|
|
70
|
+
children: children
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { DataGridCell, getCellClasses };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataGridCell } from "./DataGridCell";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DataGridCell } from "./DataGridCell.js";
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "./DataGridCell.js"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: ./src/DataGridCell/index.ts
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export { DataGridCell };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { DataGridCellSortProps } from "../DataGrid/DataGridTypes";
|
|
2
|
+
export declare const DataGridCellSort: ({ className, children, cellId, onSort, sortDirection, sortedCell, slotLeft, slotRight, buttonClassName, focusMode, ...rest }: DataGridCellSortProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ButtonSort_private } from "@versini/ui-button/private";
|
|
8
|
+
import { IconSort, IconSortDown, IconSortUp } from "@versini/ui-icons";
|
|
9
|
+
import { DataGridContext } from "../DataGrid/DataGridContext.js";
|
|
10
|
+
import { getCellClasses } from "../DataGridCell/DataGridCell.js";
|
|
11
|
+
import { CellWrapper } from "../DataGridConstants/index.js";
|
|
12
|
+
|
|
13
|
+
;// CONCATENATED MODULE: external "react/jsx-runtime"
|
|
14
|
+
|
|
15
|
+
;// CONCATENATED MODULE: external "@versini/ui-button/private"
|
|
16
|
+
|
|
17
|
+
;// CONCATENATED MODULE: external "@versini/ui-icons"
|
|
18
|
+
|
|
19
|
+
;// CONCATENATED MODULE: external "../DataGrid/DataGridContext.js"
|
|
20
|
+
|
|
21
|
+
;// CONCATENATED MODULE: external "../DataGridCell/DataGridCell.js"
|
|
22
|
+
|
|
23
|
+
;// CONCATENATED MODULE: external "../DataGridConstants/index.js"
|
|
24
|
+
|
|
25
|
+
;// CONCATENATED MODULE: ./src/DataGridCellSort/DataGridCellSort.tsx
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/* =============================================================================
|
|
33
|
+
* DataGridCellSort
|
|
34
|
+
* ========================================================================== */ const DataGridCellSort = ({ className, children, cellId, onSort, sortDirection, sortedCell, slotLeft, slotRight, buttonClassName, focusMode = "alt-system", ...rest })=>{
|
|
35
|
+
const isSorted = sortedCell === cellId;
|
|
36
|
+
const handleSort = ()=>{
|
|
37
|
+
if (onSort) {
|
|
38
|
+
// Convert false to undefined for the callback.
|
|
39
|
+
const currentDirection = isSorted && sortDirection ? sortDirection : undefined;
|
|
40
|
+
onSort(cellId, currentDirection);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const getSortIcon = ()=>{
|
|
44
|
+
if (isSorted && sortDirection === "asc") {
|
|
45
|
+
return /*#__PURE__*/ jsx(IconSortUp, {
|
|
46
|
+
className: "size-4",
|
|
47
|
+
monotone: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (isSorted && sortDirection === "desc") {
|
|
51
|
+
return /*#__PURE__*/ jsx(IconSortDown, {
|
|
52
|
+
className: "size-4",
|
|
53
|
+
monotone: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/ jsx(IconSort, {
|
|
57
|
+
className: "size-4",
|
|
58
|
+
monotone: true
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const getAriaSort = ()=>{
|
|
62
|
+
if (isSorted && sortDirection === "asc") {
|
|
63
|
+
return "ascending";
|
|
64
|
+
}
|
|
65
|
+
if (isSorted && sortDirection === "desc") {
|
|
66
|
+
return "descending";
|
|
67
|
+
}
|
|
68
|
+
return "other";
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/ jsx(DataGridContext.Consumer, {
|
|
71
|
+
children: ({ mode, compact, cellWrapper })=>{
|
|
72
|
+
const { mainClasses, alignClasses } = getCellClasses({
|
|
73
|
+
cellWrapper,
|
|
74
|
+
className,
|
|
75
|
+
mode,
|
|
76
|
+
compact
|
|
77
|
+
});
|
|
78
|
+
const Component = cellWrapper === CellWrapper.HEADER || cellWrapper === CellWrapper.FOOTER ? "th" : "td";
|
|
79
|
+
return /*#__PURE__*/ jsx(Component, {
|
|
80
|
+
className: mainClasses,
|
|
81
|
+
role: "columnheader",
|
|
82
|
+
"aria-sort": getAriaSort(),
|
|
83
|
+
...rest,
|
|
84
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
85
|
+
className: alignClasses,
|
|
86
|
+
children: [
|
|
87
|
+
slotLeft,
|
|
88
|
+
/*#__PURE__*/ jsx(ButtonSort_private, {
|
|
89
|
+
active: isSorted,
|
|
90
|
+
className: buttonClassName,
|
|
91
|
+
onClick: handleSort,
|
|
92
|
+
noBorder: true,
|
|
93
|
+
focusMode: focusMode,
|
|
94
|
+
mode: mode,
|
|
95
|
+
fullWidth: true,
|
|
96
|
+
labelRight: children,
|
|
97
|
+
children: getSortIcon()
|
|
98
|
+
}),
|
|
99
|
+
slotRight
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { DataGridCellSort };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataGridCellSort } from "./DataGridCellSort";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DataGridCellSort } from "./DataGridCellSort.js";
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "./DataGridCellSort.js"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: ./src/DataGridCellSort/index.ts
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export { DataGridCellSort };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sort direction constants for DataGrid sorting.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SortDirections: {
|
|
5
|
+
readonly ASC: "asc";
|
|
6
|
+
readonly DESC: "desc";
|
|
7
|
+
};
|
|
8
|
+
export type SortDirection = typeof SortDirections.ASC | typeof SortDirections.DESC;
|
|
9
|
+
/**
|
|
10
|
+
* Blur effect intensity options for sticky header/footer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BlurEffects: {
|
|
13
|
+
readonly NONE: "none";
|
|
14
|
+
readonly SMALL: "small";
|
|
15
|
+
readonly MEDIUM: "medium";
|
|
16
|
+
readonly LARGE: "large";
|
|
17
|
+
};
|
|
18
|
+
export type BlurEffect = typeof BlurEffects.NONE | typeof BlurEffects.SMALL | typeof BlurEffects.MEDIUM | typeof BlurEffects.LARGE;
|
|
19
|
+
/**
|
|
20
|
+
* Theme mode options for DataGrid.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ThemeModes: {
|
|
23
|
+
readonly DARK: "dark";
|
|
24
|
+
readonly LIGHT: "light";
|
|
25
|
+
readonly SYSTEM: "system";
|
|
26
|
+
readonly ALT_SYSTEM: "alt-system";
|
|
27
|
+
};
|
|
28
|
+
export type ThemeMode = typeof ThemeModes.DARK | typeof ThemeModes.LIGHT | typeof ThemeModes.SYSTEM | typeof ThemeModes.ALT_SYSTEM;
|
|
29
|
+
/**
|
|
30
|
+
* Cell wrapper types for internal context.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CellWrapper: {
|
|
33
|
+
readonly HEADER: "header";
|
|
34
|
+
readonly BODY: "body";
|
|
35
|
+
readonly FOOTER: "footer";
|
|
36
|
+
};
|
|
37
|
+
export type CellWrapperType = typeof CellWrapper.HEADER | typeof CellWrapper.BODY | typeof CellWrapper.FOOTER;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
;// CONCATENATED MODULE: ./src/DataGridConstants/DataGridConstants.ts
|
|
8
|
+
/**
|
|
9
|
+
* Sort direction constants for DataGrid sorting.
|
|
10
|
+
*/ const SortDirections = {
|
|
11
|
+
ASC: "asc",
|
|
12
|
+
DESC: "desc"
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Blur effect intensity options for sticky header/footer.
|
|
16
|
+
*/ const BlurEffects = {
|
|
17
|
+
NONE: "none",
|
|
18
|
+
SMALL: "small",
|
|
19
|
+
MEDIUM: "medium",
|
|
20
|
+
LARGE: "large"
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Theme mode options for DataGrid.
|
|
24
|
+
*/ const ThemeModes = {
|
|
25
|
+
DARK: "dark",
|
|
26
|
+
LIGHT: "light",
|
|
27
|
+
SYSTEM: "system",
|
|
28
|
+
ALT_SYSTEM: "alt-system"
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Cell wrapper types for internal context.
|
|
32
|
+
*/ const CellWrapper = {
|
|
33
|
+
HEADER: "header",
|
|
34
|
+
BODY: "body",
|
|
35
|
+
FOOTER: "footer"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { BlurEffects, CellWrapper, SortDirections, ThemeModes };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type BlurEffect, BlurEffects, CellWrapper, type CellWrapperType, type SortDirection, SortDirections, type ThemeMode, ThemeModes, } from "./DataGridConstants";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
@versini/ui-datagrid v0.1.0
|
|
3
|
+
© 2026 gizmette.com
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BlurEffects, CellWrapper, SortDirections, ThemeModes } from "./DataGridConstants.js";
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: external "./DataGridConstants.js"
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: ./src/DataGridConstants/index.ts
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export { BlurEffects, CellWrapper, SortDirections, ThemeModes };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DataGridFooterProps } from "../DataGrid/DataGridTypes";
|
|
2
|
+
import { type BlurEffect, type ThemeMode } from "../DataGridConstants/DataGridConstants";
|
|
3
|
+
/**
|
|
4
|
+
* Generates classes for the DataGridFooter.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getFooterClasses: ({ className, stickyFooter, mode, blurEffect, }: {
|
|
7
|
+
mode: ThemeMode;
|
|
8
|
+
blurEffect?: BlurEffect;
|
|
9
|
+
className?: string;
|
|
10
|
+
stickyFooter?: boolean;
|
|
11
|
+
}) => string;
|
|
12
|
+
export declare const DataGridFooter: ({ className, children, ...rest }: DataGridFooterProps) => import("react/jsx-runtime").JSX.Element;
|