@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.66.0-rc.19",
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": "d5bfb15cb919ad43e6ab189fa81429c2a5b600d1"
115
+ "gitHead": "b3810ba1b0cda52a789d68955d474086d8745eda"
116
116
  }
@@ -8,5 +8,4 @@
8
8
  grid-template-rows: 1fr;
9
9
  grid-template-columns: 1fr;
10
10
  row-gap: var(--dynamic-list-row-gap, $dynamic-list-row-gap);
11
- position: relative;
12
11
  }
@@ -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, isResizing, resizePosition, containerRef } =
74
- useResize(columns, onColumnSizesChanged);
73
+ const { cols, mouseDown, ResizeIndicator } = useResize(
74
+ columns,
75
+ onColumnSizesChanged,
76
+ );
75
77
 
76
78
  return (
77
79
  <>
78
- {isResizing && resizePosition !== undefined && (
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
  >
@@ -12,7 +12,6 @@
12
12
  $explorer-background-color
13
13
  );
14
14
  overflow-x: auto;
15
- position: relative;
16
15
 
17
16
  .LoadingData {
18
17
  margin: 1rem 0;
@@ -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, isResizing, resizePosition, containerRef } =
89
- useResize(columns, onColumnSizesChanged);
88
+ const { cols, mouseDown, ResizeIndicator } = useResize(
89
+ columns,
90
+ onColumnSizesChanged,
91
+ );
90
92
 
91
93
  return (
92
94
  <>
93
- {isResizing && resizePosition !== undefined && (
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,7 @@
1
+ .resizeIndicator {
2
+ position: fixed;
3
+ width: 1px;
4
+ background-color: var(--explorer-list-row-border, #dddddd);
5
+ pointer-events: none;
6
+ z-index: 10;
7
+ }
@@ -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
- * and the mouseDown handler (add this to the element that should be used to resize the column)
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
- isResizing: boolean;
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 relative to container
72
- if (containerRef.current) {
73
- const containerRect = containerRef.current.getBoundingClientRect();
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
- isResizing: activeIndex !== undefined,
138
- resizePosition,
139
- containerRef,
134
+ ResizeIndicator: (
135
+ <ResizeIndicator
136
+ resizePosition={resizePosition}
137
+ isResizing={activeIndex !== undefined}
138
+ />
139
+ ),
140
140
  };
141
141
  };