@wallarm-org/design-system 1.6.1 → 1.6.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cloneElement, useMemo, useState } from "react";
|
|
2
|
+
import { cloneElement, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
5
5
|
import { SortableContext, arrayMove, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
@@ -28,10 +28,25 @@ const TableSettingsMenu = ({ 'data-testid': testIdProp, children, ...rest })=>{
|
|
|
28
28
|
const hasTextDescription = table.getAllLeafColumns().some((col)=>col.columnDef.meta?.description?.type === 'text');
|
|
29
29
|
const [search, setSearch] = useState('');
|
|
30
30
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
31
|
+
const contentRef = useRef(null);
|
|
32
|
+
const [lockedWidth, setLockedWidth] = useState();
|
|
31
33
|
const handleOpenChange = (open)=>{
|
|
32
34
|
setMenuOpen(open);
|
|
35
|
+
if (open) setSearch('');
|
|
36
|
+
else setLockedWidth(void 0);
|
|
33
37
|
onSettingsOpenChange?.(open);
|
|
34
38
|
};
|
|
39
|
+
useLayoutEffect(()=>{
|
|
40
|
+
if (!menuOpen) return;
|
|
41
|
+
let raf = requestAnimationFrame(function measure() {
|
|
42
|
+
const el = contentRef.current;
|
|
43
|
+
if (el) setLockedWidth(el.offsetWidth);
|
|
44
|
+
else raf = requestAnimationFrame(measure);
|
|
45
|
+
});
|
|
46
|
+
return ()=>cancelAnimationFrame(raf);
|
|
47
|
+
}, [
|
|
48
|
+
menuOpen
|
|
49
|
+
]);
|
|
35
50
|
const allColumns = table.getAllLeafColumns().filter((col)=>col.id !== TABLE_SELECT_COLUMN_ID && col.id !== TABLE_EXPAND_COLUMN_ID);
|
|
36
51
|
const filteredColumns = useMemo(()=>{
|
|
37
52
|
if (!search) return allColumns;
|
|
@@ -131,7 +146,11 @@ const TableSettingsMenu = ({ 'data-testid': testIdProp, children, ...rest })=>{
|
|
|
131
146
|
})
|
|
132
147
|
}),
|
|
133
148
|
/*#__PURE__*/ jsxs(DropdownMenuContent, {
|
|
134
|
-
|
|
149
|
+
ref: contentRef,
|
|
150
|
+
className: cn('min-w-256 max-h-[430px]'),
|
|
151
|
+
style: lockedWidth ? {
|
|
152
|
+
width: lockedWidth
|
|
153
|
+
} : void 0,
|
|
135
154
|
children: [
|
|
136
155
|
searchOverride ?? /*#__PURE__*/ jsx(TableSettingsMenuSearch, {}),
|
|
137
156
|
/*#__PURE__*/ jsx(VStack, {
|