@topconsultnpm/sdkui-react 6.20.0-dev1.46 → 6.20.0-dev1.47

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.
@@ -211,6 +211,29 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], isConstrained
211
211
  };
212
212
  return createPinItems(contextMenuItems);
213
213
  }, [contextMenuItems, flattenMenuItems, togglePin, state.items]);
214
+ const getContextMenuItemsWithPinIcons = useCallback(() => {
215
+ const flatItems = flattenMenuItems(contextMenuItems);
216
+ const currentItemIds = new Set(state.items.map(i => i.id));
217
+ const addPinIcons = (items) => {
218
+ return items.map(item => {
219
+ const flatItem = flatItems.find(fi => fi.id === item.id);
220
+ const itemId = flatItem?.id || item.id || '';
221
+ const isPinned = currentItemIds.has(itemId);
222
+ const itemWithPin = {
223
+ ...item,
224
+ rightIcon: flatItem ? _jsx(IconPin, { color: isPinned ? 'red' : 'black' }) : undefined,
225
+ onRightIconClick: flatItem ? () => {
226
+ togglePin(flatItem);
227
+ } : undefined,
228
+ };
229
+ if (item.submenu) {
230
+ itemWithPin.submenu = addPinIcons(item.submenu);
231
+ }
232
+ return itemWithPin;
233
+ });
234
+ };
235
+ return addPinIcons(contextMenuItems);
236
+ }, [contextMenuItems, flattenMenuItems, togglePin, state.items]);
214
237
  const handleMouseDown = (e) => {
215
238
  if (state.isConfigMode)
216
239
  return;
@@ -519,6 +542,6 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], isConstrained
519
542
  currentOnClick();
520
543
  }
521
544
  }, disabled: state.isConfigMode ? isDisabled && !state.isConfigMode : isDisabled, children: item.icon }) }), state.isConfigMode && (_jsx(S.RemoveButton, { onClick: () => removeItem(item.id), children: "\u00D7" }))] }, item.id));
522
- }), !state.isConfigMode && contextMenuItems.length > 0 && (_jsx(ContextMenu, { items: contextMenuItems, trigger: "left", children: _jsx(S.ContextMenuButton, { children: _jsx(IconMenuVertical, {}) }) })), state.isConfigMode && state.items.length < maxItems && contextMenuItems.length > 0 && (_jsx(ContextMenu, { items: getPinContextMenuItems(), trigger: "left", keepOpenOnClick: true, children: _jsx(TMTooltip, { content: SDKUI_Localizator.Add, children: _jsx(S.AddButton, { children: _jsx(IconAdd, {}) }) }) })), state.isConfigMode && (_jsxs(_Fragment, { children: [_jsx(S.Separator, { "$orientation": state.orientation }), _jsxs(S.ButtonGroup, { "$orientation": state.orientation, children: [_jsx(TMTooltip, { content: SDKUI_Localizator.Undo, position: state.orientation === 'horizontal' ? 'right' : 'top', children: _jsx(S.UndoButton, { onClick: handleUndo, disabled: !hasChanges(), children: _jsx(IconUndo, { fontSize: 18 }) }) }), _jsx(TMTooltip, { content: state.items.length === 0 ? 'Devi aggiungere almeno un item' : SDKUI_Localizator.ApplyAndClose, position: state.orientation === 'horizontal' ? 'right' : 'top', children: _jsx(S.ApplyButton, { onClick: toggleConfigMode, disabled: state.items.length === 0, children: _jsx(IconApply, { fontSize: 20 }) }) })] })] }))] })] }));
545
+ }), !state.isConfigMode && contextMenuItems.length > 0 && (_jsx(ContextMenu, { items: getContextMenuItemsWithPinIcons(), trigger: "left", keepOpenOnClick: true, children: _jsx(S.ContextMenuButton, { children: _jsx(IconMenuVertical, {}) }) })), state.isConfigMode && state.items.length < maxItems && contextMenuItems.length > 0 && (_jsx(ContextMenu, { items: getPinContextMenuItems(), trigger: "left", keepOpenOnClick: true, children: _jsx(TMTooltip, { content: SDKUI_Localizator.Add, children: _jsx(S.AddButton, { children: _jsx(IconAdd, {}) }) }) })), state.isConfigMode && (_jsxs(_Fragment, { children: [_jsx(S.Separator, { "$orientation": state.orientation }), _jsxs(S.ButtonGroup, { "$orientation": state.orientation, children: [_jsx(TMTooltip, { content: SDKUI_Localizator.Undo, position: state.orientation === 'horizontal' ? 'right' : 'top', children: _jsx(S.UndoButton, { onClick: handleUndo, disabled: !hasChanges(), children: _jsx(IconUndo, { fontSize: 18 }) }) }), _jsx(TMTooltip, { content: state.items.length === 0 ? 'Devi aggiungere almeno un item' : SDKUI_Localizator.ApplyAndClose, position: state.orientation === 'horizontal' ? 'right' : 'top', children: _jsx(S.ApplyButton, { onClick: toggleConfigMode, disabled: state.items.length === 0, children: _jsx(IconApply, { fontSize: 20 }) }) })] })] }))] })] }));
523
546
  };
524
547
  export default TMFloatingMenuBar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev1.46",
3
+ "version": "6.20.0-dev1.47",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",