@wallarm-org/design-system 1.12.1 → 1.12.2-rc-fix-submenu-stays-open.1

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 { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Fragment as external_react_Fragment, useCallback, useMemo, useRef } from "react";
2
+ import { Fragment as external_react_Fragment, useMemo, useRef } from "react";
3
3
  import { cn } from "../../../../utils/cn.js";
4
4
  import { DropdownMenu, DropdownMenuContent, DropdownMenuFooter, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator } from "../../../DropdownMenu/index.js";
5
5
  import { useFloatingRecomputeOn } from "../../hooks/useFloatingRecomputeOn.js";
@@ -44,17 +44,14 @@ const NestedValueMenu = ({ values, onSelect, onCommit, open = false, onOpenChang
44
44
  };
45
45
  const openParentIdRef = useRef(state.openParentId);
46
46
  openParentIdRef.current = state.openParentId;
47
- const getSubmenuAnchorRect = useCallback(()=>{
48
- const id = openParentIdRef.current;
49
- return id && rowElsRef.current.get(id)?.getBoundingClientRect() || null;
50
- }, []);
51
47
  const submenuPositioning = useMemo(()=>({
52
48
  placement: 'right-start',
53
49
  gutter: 4,
54
- getAnchorRect: getSubmenuAnchorRect
55
- }), [
56
- getSubmenuAnchorRect
57
- ]);
50
+ getAnchorRect: ()=>{
51
+ const id = openParentIdRef.current;
52
+ return id && rowElsRef.current.get(id)?.getBoundingClientRect() || null;
53
+ }
54
+ }), []);
58
55
  useFloatingRecomputeOn(state.openParentId, null != state.openParentId);
59
56
  const openParentRow = state.openParentRow;
60
57
  const submenuSelectAllRow = openParentRow && multiSelect ? {
@@ -81,7 +78,6 @@ const NestedValueMenu = ({ values, onSelect, onCommit, open = false, onOpenChang
81
78
  className: cn(widthClass, 'max-h-[430px]', className),
82
79
  style: widthStyle,
83
80
  "data-filter-input-menu": "true",
84
- onMouseMove: state.handleMainMouseMove,
85
81
  children: [
86
82
  hasRows ? sections.map((section, index)=>{
87
83
  const rows = /*#__PURE__*/ jsx(DropdownMenuGroup, {
@@ -41,10 +41,6 @@ export declare const useNestedValueMenuState: ({ sections, allValues, open, mult
41
41
  closeParent: () => void;
42
42
  cancelClose: () => void;
43
43
  scheduleClose: () => void;
44
- handleMainMouseMove: (event: {
45
- clientX: number;
46
- clientY: number;
47
- }) => void;
48
44
  openParentRow: ValueMenuRow | undefined;
49
45
  submenuRows: ValueMenuRow[];
50
46
  selectRow: (row: ValueMenuRow, fromSubmenu: boolean) => void;
@@ -142,25 +142,6 @@ const useNestedValueMenuState = ({ sections, allValues, open, multiSelect, initi
142
142
  useEffect(()=>()=>cancelClose(), [
143
143
  cancelClose
144
144
  ]);
145
- const lastPointRef = useRef(null);
146
- const handleMainMouseMove = useCallback((event)=>{
147
- const prev = lastPointRef.current;
148
- const point = {
149
- x: event.clientX,
150
- y: event.clientY
151
- };
152
- lastPointRef.current = point;
153
- if (null == openParentId || !prev) return;
154
- const sub = submenuRef?.current?.getBoundingClientRect();
155
- if (!sub) return;
156
- const headingRight = point.x >= prev.x;
157
- const insideBand = point.y >= sub.top - 12 && point.y <= sub.bottom + 12;
158
- if (headingRight && insideBand && point.x <= sub.left) cancelClose();
159
- }, [
160
- openParentId,
161
- submenuRef,
162
- cancelClose
163
- ]);
164
145
  const toggleGroup = useCallback((option)=>{
165
146
  const leaves = collectLeaves(option.children).map((l)=>l.value);
166
147
  toggleMany(leaves, !allLeavesChecked(option));
@@ -293,7 +274,6 @@ const useNestedValueMenuState = ({ sections, allValues, open, multiSelect, initi
293
274
  closeParent,
294
275
  cancelClose,
295
276
  scheduleClose,
296
- handleMainMouseMove,
297
277
  openParentRow,
298
278
  submenuRows,
299
279
  selectRow,
@@ -49,6 +49,13 @@ const useValueMenuState = ({ values, open, multiSelect, initialValues, highlight
49
49
  blurCommitRef,
50
50
  commitChecked
51
51
  ]);
52
+ const selectedValues = useMemo(()=>multiSelect ? checkedValues : null != highlightValue ? [
53
+ highlightValue
54
+ ] : [], [
55
+ multiSelect,
56
+ checkedValues,
57
+ highlightValue
58
+ ]);
52
59
  const flatItems = useMemo(()=>{
53
60
  const items = values.map((opt)=>({
54
61
  id: String(opt.value),
@@ -56,23 +63,18 @@ const useValueMenuState = ({ values, open, multiSelect, initialValues, highlight
56
63
  value: opt.value
57
64
  }));
58
65
  const known = new Set(items.map((item)=>item.id));
59
- const selected = multiSelect ? checkedValues : null != highlightValue ? [
60
- highlightValue
61
- ] : [];
62
- const orphans = selected.filter((value)=>!known.has(String(value))).map((value)=>({
66
+ const orphans = selectedValues.filter((value)=>!known.has(String(value))).map((value)=>({
63
67
  id: String(value),
64
68
  label: String(value),
65
69
  value
66
70
  }));
67
- return orphans.length > 0 ? [
71
+ return [
68
72
  ...orphans,
69
73
  ...items
70
- ] : items;
74
+ ];
71
75
  }, [
72
76
  values,
73
- multiSelect,
74
- checkedValues,
75
- highlightValue
77
+ selectedValues
76
78
  ]);
77
79
  const handleItemSelect = (item)=>{
78
80
  if (multiSelect) {
@@ -94,9 +96,6 @@ const useValueMenuState = ({ values, open, multiSelect, initialValues, highlight
94
96
  inputRef,
95
97
  menuRef
96
98
  });
97
- const selectedValues = multiSelect ? checkedValues : null != highlightValue ? [
98
- highlightValue
99
- ] : [];
100
99
  const buildingMultiValue = multiSelect && checkedValues.length > 0 ? checkedValues.map((v)=>values.find((opt)=>opt.value === v)?.label ?? String(v)).join(', ') : void 0;
101
100
  useEffect(()=>{
102
101
  onBuildingValueChange?.(buildingMultiValue);
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.12.0",
3
- "generatedAt": "2026-09-01T11:01:25.480Z",
2
+ "version": "1.12.1",
3
+ "generatedAt": "2026-09-01T12:46:00.538Z",
4
4
  "components": [
5
5
  {
6
6
  "name": "Accordion",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallarm-org/design-system",
3
- "version": "1.12.1",
3
+ "version": "1.12.2-rc-fix-submenu-stays-open.1",
4
4
  "description": "Core design system library with React components and Storybook documentation",
5
5
  "publishConfig": {
6
6
  "access": "public",