@axinom/mosaic-ui 0.66.0-rc.13 → 0.66.0-rc.15
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/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts.map +1 -1
- package/dist/components/List/ListHeader/ColumnLabel/ColumnLabel.d.ts.map +1 -1
- package/dist/components/List/ListHeader/ListHeader.d.ts.map +1 -1
- package/dist/components/List/ListRow/ListRow.d.ts.map +1 -1
- package/dist/components/List/ListRow/ListRowCell/ListRowCell.d.ts +15 -0
- package/dist/components/List/ListRow/ListRowCell/ListRowCell.d.ts.map +1 -0
- package/dist/components/List/ListRow/ListRowCell/renderData.d.ts +9 -0
- package/dist/components/List/ListRow/ListRowCell/renderData.d.ts.map +1 -0
- package/dist/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.d.ts.map +1 -1
- package/dist/components/Utils/Postgraphile/CreateConnectionRenderer.d.ts +1 -1
- package/dist/components/Utils/Postgraphile/CreateConnectionRenderer.d.ts.map +1 -1
- package/dist/helpers/idleCallbackHelpers.d.ts +42 -0
- package/dist/helpers/idleCallbackHelpers.d.ts.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/hooks/useResize/useResize.d.ts +3 -0
- package/dist/hooks/useResize/useResize.d.ts.map +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DynamicDataList/DynamicDataList.scss +1 -0
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.scss +10 -0
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.spec.tsx +2 -0
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.tsx +65 -49
- package/src/components/List/List.scss +1 -0
- package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.spec.tsx +4 -4
- package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.tsx +5 -1
- package/src/components/List/ListHeader/ListHeader.scss +10 -1
- package/src/components/List/ListHeader/ListHeader.spec.tsx +2 -0
- package/src/components/List/ListHeader/ListHeader.tsx +60 -50
- package/src/components/List/ListRow/ListRow.scss +0 -27
- package/src/components/List/ListRow/ListRow.spec.tsx +10 -8
- package/src/components/List/ListRow/ListRow.tsx +20 -152
- package/src/components/List/ListRow/ListRowCell/ListRowCell.scss +26 -0
- package/src/components/List/ListRow/ListRowCell/ListRowCell.spec.tsx +491 -0
- package/src/components/List/ListRow/ListRowCell/ListRowCell.tsx +57 -0
- package/src/components/List/ListRow/ListRowCell/renderData.tsx +124 -0
- package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.spec.tsx +191 -80
- package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.tsx +63 -34
- package/src/components/Utils/Postgraphile/CreateConnectionRenderer.spec.ts +48 -12
- package/src/components/Utils/Postgraphile/CreateConnectionRenderer.tsx +5 -4
- package/src/helpers/idleCallbackHelpers.ts +66 -0
- package/src/helpers/index.ts +5 -0
- package/src/hooks/useResize/useResize.ts +36 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type for the callback handle returned by scheduleIdleCallback.
|
|
3
|
+
* Can be either a number (from requestIdleCallback) or a NodeJS.Timeout (from setTimeout).
|
|
4
|
+
*/
|
|
5
|
+
export type IdleCallbackHandle = number | NodeJS.Timeout;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Safely schedules a callback to be executed when the browser is idle.
|
|
9
|
+
* Falls back to setTimeout if requestIdleCallback is not available.
|
|
10
|
+
*
|
|
11
|
+
* @param callback - The function to execute during idle time
|
|
12
|
+
* @param options - Optional configuration (timeout in ms)
|
|
13
|
+
* @returns A handle that can be passed to cancelScheduledCallback
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const handle = scheduleIdleCallback(() => {
|
|
18
|
+
* console.log('Running during idle time');
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Later, if needed:
|
|
22
|
+
* cancelScheduledCallback(handle);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function scheduleIdleCallback(
|
|
26
|
+
callback: IdleRequestCallback,
|
|
27
|
+
options?: IdleRequestOptions,
|
|
28
|
+
): IdleCallbackHandle {
|
|
29
|
+
if (typeof requestIdleCallback !== 'undefined') {
|
|
30
|
+
return requestIdleCallback(callback, options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Fallback to setTimeout for browsers that don't support requestIdleCallback
|
|
34
|
+
// Use a short timeout to approximate idle behavior
|
|
35
|
+
const timeout = options?.timeout ?? 1;
|
|
36
|
+
return setTimeout(() => {
|
|
37
|
+
const deadline: IdleDeadline = {
|
|
38
|
+
didTimeout: false,
|
|
39
|
+
timeRemaining: () => 50, // Approximate 50ms of available time
|
|
40
|
+
};
|
|
41
|
+
callback(deadline);
|
|
42
|
+
}, timeout);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Cancels a callback scheduled with scheduleIdleCallback.
|
|
47
|
+
* Works with both requestIdleCallback and setTimeout fallback.
|
|
48
|
+
*
|
|
49
|
+
* @param handle - The handle returned by scheduleIdleCallback
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const handle = scheduleIdleCallback(() => {
|
|
54
|
+
* console.log('This might not run');
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* cancelScheduledCallback(handle);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function cancelScheduledCallback(handle: IdleCallbackHandle): void {
|
|
61
|
+
if (typeof cancelIdleCallback !== 'undefined' && typeof handle === 'number') {
|
|
62
|
+
cancelIdleCallback(handle);
|
|
63
|
+
} else {
|
|
64
|
+
clearTimeout(handle as NodeJS.Timeout);
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/helpers/index.ts
CHANGED
|
@@ -19,7 +19,13 @@ export const useResize = <T extends Data>(
|
|
|
19
19
|
orgSize: string | undefined;
|
|
20
20
|
}[];
|
|
21
21
|
mouseDown: (index: number) => void;
|
|
22
|
+
isResizing: boolean;
|
|
23
|
+
resizePosition: number | undefined;
|
|
24
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
22
25
|
} => {
|
|
26
|
+
const currentGridColumns = React.useRef<string | undefined>(undefined);
|
|
27
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
28
|
+
|
|
23
29
|
const minCellWidth = 50;
|
|
24
30
|
|
|
25
31
|
const cols = useMemo(
|
|
@@ -35,6 +41,9 @@ export const useResize = <T extends Data>(
|
|
|
35
41
|
);
|
|
36
42
|
|
|
37
43
|
const [activeIndex, setActiveIndex] = useState<number | undefined>(undefined);
|
|
44
|
+
const [resizePosition, setResizePosition] = useState<number | undefined>(
|
|
45
|
+
undefined,
|
|
46
|
+
);
|
|
38
47
|
const resizeStart = React.useRef<
|
|
39
48
|
{ mouse: number; width: number } | undefined
|
|
40
49
|
>(undefined);
|
|
@@ -59,6 +68,12 @@ export const useResize = <T extends Data>(
|
|
|
59
68
|
return;
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
// Calculate position relative to container
|
|
72
|
+
if (containerRef.current) {
|
|
73
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
74
|
+
setResizePosition(e.clientX - containerRect.left);
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
const gridColumns = cols.map((col, i) => {
|
|
63
78
|
if (!col.ref.current) {
|
|
64
79
|
return col.orgSize;
|
|
@@ -68,15 +83,17 @@ export const useResize = <T extends Data>(
|
|
|
68
83
|
const width = start.width + e.clientX - start.mouse;
|
|
69
84
|
if (width >= minCellWidth) {
|
|
70
85
|
return `${width}px`;
|
|
86
|
+
} else {
|
|
87
|
+
return `${minCellWidth}px`;
|
|
71
88
|
}
|
|
72
89
|
}
|
|
73
90
|
return `${col.ref.current.offsetWidth}px`;
|
|
74
91
|
});
|
|
75
92
|
|
|
76
|
-
|
|
93
|
+
currentGridColumns.current = gridColumns.join(' ');
|
|
77
94
|
}
|
|
78
95
|
},
|
|
79
|
-
[activeIndex, cols
|
|
96
|
+
[activeIndex, cols],
|
|
80
97
|
);
|
|
81
98
|
|
|
82
99
|
const mouseDown = (index: number): void => {
|
|
@@ -89,10 +106,19 @@ export const useResize = <T extends Data>(
|
|
|
89
106
|
}, [mouseMove]);
|
|
90
107
|
|
|
91
108
|
const mouseUp = useCallback(() => {
|
|
109
|
+
// Apply the new column sizes only if a resize actually happened
|
|
110
|
+
if (resizeStart.current !== undefined) {
|
|
111
|
+
onColumnSizesChanged(
|
|
112
|
+
currentGridColumns.current || cols.map((col) => col.orgSize).join(' '),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
92
116
|
setActiveIndex(undefined);
|
|
117
|
+
setResizePosition(undefined);
|
|
93
118
|
resizeStart.current = undefined;
|
|
119
|
+
currentGridColumns.current = undefined;
|
|
94
120
|
removeListeners();
|
|
95
|
-
}, [
|
|
121
|
+
}, [removeListeners, onColumnSizesChanged, cols]);
|
|
96
122
|
|
|
97
123
|
useEffect(() => {
|
|
98
124
|
if (activeIndex !== undefined) {
|
|
@@ -105,5 +131,11 @@ export const useResize = <T extends Data>(
|
|
|
105
131
|
};
|
|
106
132
|
}, [activeIndex, mouseMove, mouseUp, removeListeners]);
|
|
107
133
|
|
|
108
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
cols,
|
|
136
|
+
mouseDown,
|
|
137
|
+
isResizing: activeIndex !== undefined,
|
|
138
|
+
resizePosition,
|
|
139
|
+
containerRef,
|
|
140
|
+
};
|
|
109
141
|
};
|