@axinom/mosaic-ui 0.66.0-rc.19 → 0.66.0-rc.20
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/ListHeader.d.ts.map +1 -1
- package/dist/hooks/useResize/ResizeIndicator.d.ts +8 -0
- package/dist/hooks/useResize/ResizeIndicator.d.ts.map +1 -0
- package/dist/hooks/useResize/useResize.d.ts +5 -5
- 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 +0 -1
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.scss +0 -10
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.tsx +5 -9
- package/src/components/List/List.scss +0 -1
- package/src/components/List/ListHeader/ListHeader.scss +0 -10
- package/src/components/List/ListHeader/ListHeader.tsx +5 -9
- package/src/hooks/useResize/ResizeIndicator.scss +7 -0
- package/src/hooks/useResize/ResizeIndicator.tsx +39 -0
- package/src/hooks/useResize/{useResize.ts → useResize.tsx} +14 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.66.0-rc.
|
|
3
|
+
"version": "0.66.0-rc.20",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "b3810ba1b0cda52a789d68955d474086d8745eda"
|
|
116
116
|
}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
@import '../../../styles/common.scss';
|
|
2
2
|
|
|
3
|
-
.resizeIndicator {
|
|
4
|
-
position: absolute;
|
|
5
|
-
top: 0;
|
|
6
|
-
bottom: 0;
|
|
7
|
-
width: 1px;
|
|
8
|
-
background-color: var(--explorer-list-row-border, #dddddd);
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
z-index: 10;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
3
|
.container {
|
|
14
4
|
background-color: var(
|
|
15
5
|
--explorer-background-color,
|
|
@@ -70,24 +70,20 @@ export const DynamicListHeader = <T extends Data>({
|
|
|
70
70
|
customStyles.top = 0;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const { cols, mouseDown,
|
|
74
|
-
|
|
73
|
+
const { cols, mouseDown, ResizeIndicator } = useResize(
|
|
74
|
+
columns,
|
|
75
|
+
onColumnSizesChanged,
|
|
76
|
+
);
|
|
75
77
|
|
|
76
78
|
return (
|
|
77
79
|
<>
|
|
78
|
-
{
|
|
79
|
-
<div
|
|
80
|
-
className={classes.resizeIndicator}
|
|
81
|
-
style={{ left: `${resizePosition}px` }}
|
|
82
|
-
/>
|
|
83
|
-
)}
|
|
80
|
+
{ResizeIndicator}
|
|
84
81
|
<div
|
|
85
82
|
className={clsx(
|
|
86
83
|
classes.container,
|
|
87
84
|
'dynamic-list-header-container',
|
|
88
85
|
className,
|
|
89
86
|
)}
|
|
90
|
-
ref={containerRef}
|
|
91
87
|
style={customStyles}
|
|
92
88
|
data-test-id="dynamic-list-header"
|
|
93
89
|
>
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
@import '../../../styles/common.scss';
|
|
2
2
|
|
|
3
|
-
.resizeIndicator {
|
|
4
|
-
position: absolute;
|
|
5
|
-
top: 0;
|
|
6
|
-
bottom: 0;
|
|
7
|
-
width: 1px;
|
|
8
|
-
background-color: var(--explorer-list-row-border, #dddddd);
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
z-index: 1;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
3
|
.container {
|
|
14
4
|
padding-left: 5px;
|
|
15
5
|
display: grid;
|
|
@@ -85,22 +85,18 @@ export const ListHeader = <T extends Data>({
|
|
|
85
85
|
alignItems: verticalTextAlign,
|
|
86
86
|
} as React.CSSProperties;
|
|
87
87
|
|
|
88
|
-
const { cols, mouseDown,
|
|
89
|
-
|
|
88
|
+
const { cols, mouseDown, ResizeIndicator } = useResize(
|
|
89
|
+
columns,
|
|
90
|
+
onColumnSizesChanged,
|
|
91
|
+
);
|
|
90
92
|
|
|
91
93
|
return (
|
|
92
94
|
<>
|
|
93
|
-
{
|
|
94
|
-
<div
|
|
95
|
-
className={classes.resizeIndicator}
|
|
96
|
-
style={{ left: `${resizePosition}px` }}
|
|
97
|
-
/>
|
|
98
|
-
)}
|
|
95
|
+
{ResizeIndicator}
|
|
99
96
|
<div
|
|
100
97
|
className={clsx(classes.container, 'list-header-container', className)}
|
|
101
98
|
style={customStyles}
|
|
102
99
|
data-test-id="list-header"
|
|
103
|
-
ref={containerRef}
|
|
104
100
|
>
|
|
105
101
|
{columns.map((column, i) => (
|
|
106
102
|
<div
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classes from './ResizeIndicator.scss';
|
|
3
|
+
|
|
4
|
+
interface ResizeIndicatorProps {
|
|
5
|
+
resizePosition: number | undefined;
|
|
6
|
+
isResizing: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const ResizeIndicator: React.FC<ResizeIndicatorProps> = ({
|
|
10
|
+
resizePosition,
|
|
11
|
+
isResizing,
|
|
12
|
+
}) => {
|
|
13
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
14
|
+
const getResizeIndicatorBounds = (): React.CSSProperties => {
|
|
15
|
+
if (containerRef.current) {
|
|
16
|
+
const listWrapper = containerRef.current.parentElement;
|
|
17
|
+
if (listWrapper) {
|
|
18
|
+
const rect = listWrapper.getBoundingClientRect();
|
|
19
|
+
return {
|
|
20
|
+
left: `${resizePosition}px`,
|
|
21
|
+
top: `${rect.top}px`,
|
|
22
|
+
height: `${rect.height}px`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { left: `${resizePosition}px` };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div ref={containerRef}>
|
|
31
|
+
{isResizing && resizePosition !== undefined && (
|
|
32
|
+
<div
|
|
33
|
+
className={classes.resizeIndicator}
|
|
34
|
+
style={getResizeIndicatorBounds()}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -2,13 +2,15 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
2
2
|
import { DynamicListColumn } from '../../components';
|
|
3
3
|
import { Column } from '../../components/List/List.model';
|
|
4
4
|
import { Data } from '../../types';
|
|
5
|
+
import { ResizeIndicator } from './ResizeIndicator';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Handles the resizing logic of the columns
|
|
8
9
|
* @param columns The list of column definitions
|
|
9
10
|
* @param onColumnSizesChanged Callback that will be called when the column sizes change
|
|
10
|
-
* @returns an object containing the refs to the columns (add these to all column header elements)
|
|
11
|
-
*
|
|
11
|
+
* @returns an object containing the refs to the columns (add these to all column header elements),
|
|
12
|
+
* the mouseDown handler (add this to the element that should be used to resize the column),
|
|
13
|
+
* and the ResizeIndicator element (render this to show the resize indicator)
|
|
12
14
|
*/
|
|
13
15
|
export const useResize = <T extends Data>(
|
|
14
16
|
columns: Column<T>[] | DynamicListColumn<T>[],
|
|
@@ -19,12 +21,9 @@ export const useResize = <T extends Data>(
|
|
|
19
21
|
orgSize: string | undefined;
|
|
20
22
|
}[];
|
|
21
23
|
mouseDown: (index: number) => void;
|
|
22
|
-
|
|
23
|
-
resizePosition: number | undefined;
|
|
24
|
-
containerRef: React.RefObject<HTMLDivElement>;
|
|
24
|
+
ResizeIndicator: JSX.Element;
|
|
25
25
|
} => {
|
|
26
26
|
const currentGridColumns = React.useRef<string | undefined>(undefined);
|
|
27
|
-
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
28
27
|
|
|
29
28
|
const minCellWidth = 50;
|
|
30
29
|
|
|
@@ -68,11 +67,9 @@ export const useResize = <T extends Data>(
|
|
|
68
67
|
return;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
// Calculate position
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setResizePosition(e.clientX - containerRect.left);
|
|
75
|
-
}
|
|
70
|
+
// Calculate position (clientX gives viewport position for fixed positioning)
|
|
71
|
+
|
|
72
|
+
setResizePosition(e.clientX);
|
|
76
73
|
|
|
77
74
|
const gridColumns = cols.map((col, i) => {
|
|
78
75
|
if (!col.ref.current) {
|
|
@@ -134,8 +131,11 @@ export const useResize = <T extends Data>(
|
|
|
134
131
|
return {
|
|
135
132
|
cols,
|
|
136
133
|
mouseDown,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
ResizeIndicator: (
|
|
135
|
+
<ResizeIndicator
|
|
136
|
+
resizePosition={resizePosition}
|
|
137
|
+
isResizing={activeIndex !== undefined}
|
|
138
|
+
/>
|
|
139
|
+
),
|
|
140
140
|
};
|
|
141
141
|
};
|